diff --git a/src/platform/sdl/gl-common.c b/src/platform/sdl/gl-common.c index 2ec8227ca..e4d400b29 100644 --- a/src/platform/sdl/gl-common.c +++ b/src/platform/sdl/gl-common.c @@ -51,9 +51,9 @@ void mSDLGLCommonInit(struct mSDLRenderer* renderer) { #else SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); #ifdef COLOR_16_BIT - SDL_SetVideoMode(renderer->viewportWidth, renderer->viewportHeight, 16, SDL_OPENGL | (SDL_FULLSCREEN * renderer->fullscreen)); + SDL_SetVideoMode(renderer->viewportWidth, renderer->viewportHeight, 16, SDL_OPENGL | SDL_RESIZABLE | (SDL_FULLSCREEN * renderer->fullscreen)); #else - SDL_SetVideoMode(renderer->viewportWidth, renderer->viewportHeight, 32, SDL_OPENGL | (SDL_FULLSCREEN * renderer->fullscreen)); + SDL_SetVideoMode(renderer->viewportWidth, renderer->viewportHeight, 32, SDL_OPENGL | SDL_RESIZABLE | (SDL_FULLSCREEN * renderer->fullscreen)); #endif SDL_WM_SetCaption(projectName, ""); #endif diff --git a/src/platform/sdl/gl-sdl.c b/src/platform/sdl/gl-sdl.c index de572db41..38e0a2164 100644 --- a/src/platform/sdl/gl-sdl.c +++ b/src/platform/sdl/gl-sdl.c @@ -52,14 +52,18 @@ void mSDLGLRunloop(struct mSDLRenderer* renderer, void* user) { while (mCoreThreadIsActive(context)) { while (SDL_PollEvent(&event)) { mSDLHandleEvent(context, &renderer->player, &event); -#if SDL_VERSION_ATLEAST(2, 0, 0) // Event handling can change the size of the screen if (renderer->player.windowUpdated) { +#if SDL_VERSION_ATLEAST(2, 0, 0) SDL_GetWindowSize(renderer->window, &renderer->viewportWidth, &renderer->viewportHeight); +#else + renderer->viewportWidth = renderer->player.newWidth; + renderer->viewportHeight = renderer->player.newHeight; + mSDLGLCommonInit(renderer); +#endif mSDLGLDoViewport(renderer->viewportWidth, renderer->viewportHeight, v); renderer->player.windowUpdated = 0; } -#endif } renderer->core->desiredVideoDimensions(renderer->core, &renderer->width, &renderer->height); if (renderer->width != v->width || renderer->height != v->height) { diff --git a/src/platform/sdl/gles2-sdl.c b/src/platform/sdl/gles2-sdl.c index 409e94183..582df9f9b 100644 --- a/src/platform/sdl/gles2-sdl.c +++ b/src/platform/sdl/gles2-sdl.c @@ -128,14 +128,18 @@ void mSDLGLES2Runloop(struct mSDLRenderer* renderer, void* user) { while (mCoreThreadIsActive(context)) { while (SDL_PollEvent(&event)) { mSDLHandleEvent(context, &renderer->player, &event); -#if SDL_VERSION_ATLEAST(2, 0, 0) // Event handling can change the size of the screen if (renderer->player.windowUpdated) { +#if SDL_VERSION_ATLEAST(2, 0, 0) SDL_GetWindowSize(renderer->window, &renderer->viewportWidth, &renderer->viewportHeight); +#else + renderer->viewportWidth = renderer->player.newWidth; + renderer->viewportHeight = renderer->player.newHeight; + mSDLGLCommonInit(renderer); +#endif mSDLGLDoViewport(renderer->viewportWidth, renderer->viewportHeight, v); renderer->player.windowUpdated = 0; } -#endif } if (mCoreSyncWaitFrameStart(&context->impl->sync)) { diff --git a/src/platform/sdl/sdl-events.c b/src/platform/sdl/sdl-events.c index 9f4b218b2..93243a1db 100644 --- a/src/platform/sdl/sdl-events.c +++ b/src/platform/sdl/sdl-events.c @@ -601,6 +601,12 @@ void mSDLHandleEvent(struct mCoreThread* context, struct mSDLPlayer* sdlContext, case SDL_WINDOWEVENT: _mSDLHandleWindowEvent(sdlContext, &event->window); break; +#else + case SDL_VIDEORESIZE: + sdlContext->newWidth = event->resize.w; + sdlContext->newHeight = event->resize.h; + sdlContext->windowUpdated = 1; + break; #endif case SDL_KEYDOWN: case SDL_KEYUP: diff --git a/src/platform/sdl/sdl-events.h b/src/platform/sdl/sdl-events.h index c9d7b386f..7df0672c3 100644 --- a/src/platform/sdl/sdl-events.h +++ b/src/platform/sdl/sdl-events.h @@ -63,10 +63,10 @@ struct mSDLPlayer { size_t playerId; struct mInputMap* bindings; struct SDL_JoystickCombo* joystick; + int windowUpdated; #if SDL_VERSION_ATLEAST(2, 0, 0) SDL_Window* window; int fullscreen; - int windowUpdated; struct mSDLRumble { struct mRumble d; @@ -76,6 +76,9 @@ struct mSDLPlayer { float activeLevel; struct CircleBuffer history; } rumble; +#else + int newWidth; + int newHeight; #endif struct mSDLRotation {