summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorPeter0x44 <[email protected]>2023-09-11 17:03:33 +0000
committerGitHub <[email protected]>2023-09-11 19:03:33 +0200
commit9d230d753b5dfb9c4f56b065833ac5ddaf265d8c (patch)
treeb74a3dd9d7e2a8e183a23511711a559ea581de6a /src
parente75f85ce58ccc73a54ec8116f4890247587727ab (diff)
downloadraylib-9d230d753b5dfb9c4f56b065833ac5ddaf265d8c.tar.gz
raylib-9d230d753b5dfb9c4f56b065833ac5ddaf265d8c.zip
Implement FLAG_WINDOW_RESIZABLE for web (#3305)
Fixes #3231
Diffstat (limited to 'src')
-rw-r--r--src/rcore.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/rcore.c b/src/rcore.c
index 8df087f8..beb61104 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -914,9 +914,9 @@ void InitWindow(int width, int height, const char *title)
// Check fullscreen change events(note this is done on the window since most browsers don't support this on #canvas)
//emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback);
// Check Resize event (note this is done on the window since most browsers don't support this on #canvas)
- //emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback);
+ emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 1, EmscriptenResizeCallback);
// Trigger this once to get initial window sizing
- //EmscriptenResizeCallback(EMSCRIPTEN_EVENT_RESIZE, NULL, NULL);
+ EmscriptenResizeCallback(EMSCRIPTEN_EVENT_RESIZE, NULL, NULL);
// Support keyboard events -> Not used, GLFW.JS takes care of that
//emscripten_set_keypress_callback("#canvas", NULL, 1, EmscriptenKeyboardCallback);
@@ -6165,8 +6165,8 @@ static EM_BOOL EmscriptenWindowResizedCallback(int eventType, const EmscriptenUi
return 1; // The event was consumed by the callback handler
}
-EM_JS(int, GetCanvasWidth, (), { return canvas.clientWidth; });
-EM_JS(int, GetCanvasHeight, (), { return canvas.clientHeight; });
+EM_JS(int, GetWindowInnerWidth, (), { return window.innerWidth; });
+EM_JS(int, GetWindowInnerHeight, (), { return window.innerHeight; });
// Register DOM element resize event
static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *event, void *userData)
@@ -6176,8 +6176,8 @@ static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *
// This event is called whenever the window changes sizes,
// so the size of the canvas object is explicitly retrieved below
- int width = GetCanvasWidth();
- int height = GetCanvasHeight();
+ int width = GetWindowInnerWidth();
+ int height = GetWindowInnerHeight();
emscripten_set_canvas_element_size("#canvas",width,height);
SetupViewport(width, height); // Reset viewport and projection matrix for new size