Skip to content

Commit

Permalink
Fix resizing under EGL
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeOsborn committed Feb 17, 2025
1 parent be1e02d commit a97229c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
11 changes: 5 additions & 6 deletions Makefile.emscripten
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ HAVE_SCREENSHOTS = 1
HAVE_REWIND = 1
HAVE_AUDIOMIXER = 1
HAVE_CC_RESAMPLER = 1
HAVE_EGL ?= 0
HAVE_EGL ?= 1
HAVE_OPENGLES = 1
HAVE_RJPEG = 0
HAVE_RPNG = 1
Expand All @@ -56,6 +56,7 @@ HAVE_AL = 1
HAVE_CHD ?= 0
HAVE_WASMFS ?= 1
HAVE_WORKER ?= 1
PROXY_TO_PTHREAD ?= 0

DEFINES += -DHAVE_NETWORKING -DHAVE_ONLINE_UPDATER -DHAVE_UPDATE_ASSETS -DHAVE_COMPRESSION
DEFINES += -DHAVE_UPDATE_CORE_INFO
Expand All @@ -77,7 +78,7 @@ FS_DEBUG = 1
HAVE_OPENGLES ?= 1
HAVE_OPENGLES3 ?= 0

ASYNC ?= 0
ASYNC ?= 1
LTO ?= 0
PTHREAD ?= 4

Expand Down Expand Up @@ -114,15 +115,13 @@ endif

ifeq ($(HAVE_WORKER), 1)
LIBS += -s USE_ES6_IMPORT_META=0 -sENVIRONMENT=worker,web
else
ifeq ($(HAVE_AL), 1)
override ASYNC = 1
endif
endif

ifeq ($(PROXY_TO_PTHREAD),1)
LIBS += -sPROXY_TO_PTHREAD -sOFFSCREENCANVAS_SUPPORT
DEFINES += -DUSE_OFFSCREENCANVAS=1 -DPROXY_TO_PTHREAD=1
else
override ASYNC = 1
endif

ifeq ($(HAVE_SDL2), 1)
Expand Down
15 changes: 7 additions & 8 deletions frontend/drivers/platform_emscripten.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,13 @@ void PlatformEmscriptenWatchCanvasSize(void) {
var h = Module.canvas.height;
if (w == 0 || h == 0 || width == 0 || height == 0) { return; }
/* Module.print("Setting real canvas size: " + width + " x " + height); */
if (Module.canvas.controlTransferredOffscreen) {
var new_w = `${width}px`;
var new_h = `${height}px`;
if (Module.canvas.style.width != new_w || Module.canvas.style.height != new_h) {
Module.canvas.style.width = new_w;
Module.canvas.style.height = new_h;
}
} else {
var new_w = `${width}px`;
var new_h = `${height}px`;
if (Module.canvas.style.width != new_w || Module.canvas.style.height != new_h) {
Module.canvas.style.width = new_w;
Module.canvas.style.height = new_h;
}
if (!Module.canvas.controlTransferredOffscreen) {
Module.Browser.setCanvasSize(width, height);
}
});
Expand Down
10 changes: 5 additions & 5 deletions gfx/drivers_context/emscriptenegl_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ static void gfx_ctx_emscripten_check_window(void *data, bool *quit,
emscripten_ctx_data_t *emscripten = (emscripten_ctx_data_t*)data;

gfx_ctx_emscripten_get_canvas_size(&input_width, &input_height);

*resize = (emscripten->fb_width != input_width || emscripten->fb_height != input_height);
*width = emscripten->fb_width = (unsigned)input_width;
*height = emscripten->fb_height = (unsigned)input_height;
*quit = false;
*resize = false;
}

static void gfx_ctx_emscripten_swap_buffers(void *data)
Expand All @@ -94,9 +93,10 @@ static void gfx_ctx_emscripten_get_video_size(void *data,

if (!emscripten)
return;

*width = emscripten->fb_width;
*height = emscripten->fb_height;
int w, h;
gfx_ctx_emscripten_get_canvas_size(&w, &h);
*width = w;
*height = h;
}

static bool gfx_ctx_emscripten_get_metrics(void *data,
Expand Down

0 comments on commit a97229c

Please sign in to comment.