-
Notifications
You must be signed in to change notification settings - Fork 64
Not getting any resize events #105
Comments
Are you doing anything in your html to change the size of the canvas? Resize events are fired when the browser window resizes, but if the canvas stays the same size SDL filters the events out. |
I've tried:
All of this in
When I changed the size of the canvas via Javascript, and then changed the size of the browser window, it seemed to resize the canvas back to its original size (before changing via js). Never did I get any resize related event in the C code (everything else works, I can also set the size from the C side, draw on the canvas, react to mouse / key events and so on) Do you have an example which should generate a resize event? |
Here's some test code: #include <SDL.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
static SDL_Window* sdlWindow = NULL;
static int run = 1;
void one_loop() {
SDL_Event event;
while (SDL_PollEvent(&event)) {
if (event.type == SDL_WINDOWEVENT) {
switch (event.window.event) {
case SDL_WINDOWEVENT_RESIZED:
SDL_Log("Window %d resized to %dx%d", event.window.windowID, event.window.data1, event.window.data2);
break;
}
}
if (event.type == SDL_QUIT)
run = 0;
}
}
int main(int argc, char** argv) {
SDL_Init(SDL_INIT_VIDEO);
sdlWindow = SDL_CreateWindow("test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_RESIZABLE);
#ifdef __EMSCRIPTEN__
emscripten_set_main_loop(one_loop, 0, 1);
#else
while (run)
one_loop();
#endif
return 0;
}
And If I remember correctly we're checking at "window creation" if CSS is causing the canvas size to change and the resize code only works if it is. |
I might be doing something wrong, but I'm not getting any resize events. Neither with the "default" html output nor with a minimal html template with an own canvas.
How can I get resize events?
Emscripten version: 1.38.28
SDL2 port version: 17
The text was updated successfully, but these errors were encountered: