···88 *
99 * Other functions in the Initialization module control how initialization is performed.
1010 *
1111+ *
1112 * \defgroup Logging Debugging, Logging, and Error Handling
1213 * Use GPU_Log() for normal logging output (e.g. to replace printf). Other logging priorities are handled by GPU_LogWarning() and GPU_LogError().
1314 *
···10741074 && get_GLSL_version(&renderer->max_shader_version));
10751075}
1076107610771077+static void update_stored_dimensions(GPU_Target* target)
10781078+{
10791079+ Uint8 is_fullscreen;
10801080+10811081+ if(target->context == NULL)
10821082+ return;
10831083+10841084+ #ifdef SDL_GPU_USE_SDL2
10851085+ {
10861086+ SDL_Window* window = SDL_GetWindowFromID(target->context->windowID);
10871087+ SDL_GetWindowSize(window, &target->context->window_w, &target->context->window_h);
10881088+ is_fullscreen = (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN);
10891089+ }
10901090+ #else
10911091+ {
10921092+ SDL_Surface* screen = SDL_GetVideoSurface();
10931093+ target->context->window_w = screen->w;
10941094+ target->context->window_h = screen->h;
10951095+ is_fullscreen = (screen->flags & SDL_FULLSCREEN);
10961096+ }
10971097+ #endif
10981098+10991099+ if(!is_fullscreen)
11001100+ {
11011101+ target->context->stored_window_w = target->context->window_w;
11021102+ target->context->stored_window_h = target->context->window_h;
11031103+ }
11041104+}
11051105+10771106static GPU_Target* CreateTargetFromWindow(GPU_Renderer* renderer, Uint32 windowID, GPU_Target* target)
10781107{
10791108 Uint8 created = 0; // Make a new one or repurpose an existing target?
···11561185 target->context->context = SDL_GL_CreateContext(window);
11571186 GPU_AddWindowMapping(target);
11581187 }
11591159-11601160- // Get window dimensions
11611161- SDL_GetWindowSize(window, &target->context->window_w, &target->context->window_h);
11621162- target->context->stored_window_w = target->context->window_w;
11631163- target->context->stored_window_h = target->context->window_h;
11881188+11641189 // We need a GL context before we can get the drawable size.
11651190 SDL_GL_GetDrawableSize(window, &target->context->drawable_w, &target->context->drawable_h);
11661191···11831208 }
1184120911851210 target->context->windowID = 1;
11861186- target->context->window_w = target->context->drawable_w = screen->w;
11871187- target->context->window_h = target->context->drawable_h = screen->h;
11881188- target->context->stored_window_w = target->context->window_w;
11891189- target->context->stored_window_h = target->context->window_h;
12111211+ target->context->drawable_w = screen->w;
12121212+ target->context->drawable_h = screen->h;
1190121311911214 #endif
12151215+12161216+ update_stored_dimensions(target);
12171217+1192121811931219 ((GPU_TARGET_DATA*)target->data)->handle = 0;
11941220 ((GPU_TARGET_DATA*)target->data)->format = GL_RGBA;
···16041630 extBindFramebuffer(renderer, ((GPU_TARGET_DATA*)target->data)->handle);
16051631}
1606163216331633+static void get_window_dimensions(GPU_Target* target, int* w, int* h)
16341634+{
16351635+#ifdef SDL_GPU_USE_SDL2
16361636+ SDL_GetWindowSize(SDL_GetWindowFromID(target->context->windowID), w, h);
16371637+#else
16381638+ SDL_Surface* screen = SDL_GetVideoSurface();
16391639+ *w = screen->w;
16401640+ *h = screen->h;
16411641+#endif
16421642+}
16431643+16441644+static void get_drawable_dimensions(GPU_Target* target, int* w, int* h)
16451645+{
16461646+#ifdef SDL_GPU_USE_SDL2
16471647+ SDL_GL_GetDrawableSize(SDL_GetWindowFromID(target->context->windowID), w, h);
16481648+#else
16491649+ get_window_dimensions(target, w, h);
16501650+#endif
16511651+}
16521652+16531653+static void resize_window(GPU_Target* target, int w, int h)
16541654+{
16551655+#ifdef SDL_GPU_USE_SDL2
16561656+ SDL_SetWindowSize(SDL_GetWindowFromID(target->context->windowID), w, h);
16571657+#else
16581658+ SDL_Surface* screen = SDL_GetVideoSurface();
16591659+ Uint32 flags = screen->flags;
16601660+16611661+ screen = SDL_SetVideoMode(w, h, 0, flags);
16621662+ // NOTE: There's a bug in SDL 1.2. This is a workaround. Let's resize again:
16631663+ screen = SDL_SetVideoMode(w, h, 0, flags);
16641664+#endif
16651665+}
16661666+16071667static Uint8 SetWindowResolution(GPU_Renderer* renderer, Uint16 w, Uint16 h)
16081668{
16091669 GPU_Target* target = renderer->current_context_target;
···16121672 if(isCurrent)
16131673 renderer->impl->FlushBlitBuffer(renderer);
1614167416151615-#ifdef SDL_GPU_USE_SDL2
16161616-16751675+ // Don't need to resize (only update internals) when resolution isn't changing.
16761676+ get_window_dimensions(target, &target->context->window_w, &target->context->window_h);
16771677+ get_drawable_dimensions(target, &target->context->drawable_w, &target->context->drawable_h);
16781678+ if(target->context->window_w != w || target->context->window_h != h)
16171679 {
16181618- SDL_Window* window = SDL_GetWindowFromID(target->context->windowID);
16191619-16201620- // Don't need to resize (only update internals) when resolution isn't changing.
16211621- SDL_GetWindowSize(window, &target->context->window_w, &target->context->window_h);
16221622- SDL_GL_GetDrawableSize(window, &target->context->drawable_w, &target->context->drawable_h);
16231623- if(target->context->window_w != w || target->context->window_h != h)
16241624- {
16251625- SDL_SetWindowSize(window, w, h);
16261626- SDL_GetWindowSize(window, &target->context->window_w, &target->context->window_h);
16271627- SDL_GL_GetDrawableSize(window, &target->context->drawable_w, &target->context->drawable_h);
16281628- }
16801680+ resize_window(target, w, h);
16811681+ get_window_dimensions(target, &target->context->window_w, &target->context->window_h);
16821682+ get_drawable_dimensions(target, &target->context->drawable_w, &target->context->drawable_h);
16291683 }
1630168416311631-#else
16321632- SDL_Surface* screen = SDL_GetVideoSurface();
16331633- Uint32 flags = screen->flags;
16341634- GPU_Context* context;
16851685+#ifdef SDL_GPU_USE_SDL1
1635168616361636- // Don't need to resize (only update internals) when resolution isn't changing.
16371637- if(screen->w != w || screen->h != h)
16871687+ // FIXME: Does the entire GL state need to be reset because the screen was recreated?
16381688 {
16391639- screen = SDL_SetVideoMode(w, h, 0, flags);
16401640- // There's a bug in SDL. This is a workaround. Let's resize again:
16411641- screen = SDL_SetVideoMode(w, h, 0, flags);
16891689+ GPU_Context* context;
1642169016431643- if(screen == NULL)
16441644- return 0;
16911691+ // Reset texturing state
16921692+ context = renderer->current_context_target->context;
16931693+ context->use_texturing = 1;
16941694+ ((GPU_CONTEXT_DATA*)context->data)->last_use_texturing = 0;
16451695 }
1646169616471647- target->context->window_w = target->context->drawable_w = screen->w;
16481648- target->context->window_h = target->context->drawable_h = screen->h;
16491649-16501650- // FIXME: Does the entire GL state need to be reset because the screen was recreated?
16511651-16521652- // Reset texturing state
16531653- context = renderer->current_context_target->context;
16541654- context->use_texturing = 1;
16551655- ((GPU_CONTEXT_DATA*)context->data)->last_use_texturing = 0;
16561656-16571697 // Clear target (no state change)
16581698 glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
16591699 glClear( GL_COLOR_BUFFER_BIT );
16601700#endif
1661170116621702 // Store the resolution for fullscreen_desktop changes
16631663- target->context->stored_window_w = target->context->window_w;
16641664- target->context->stored_window_h = target->context->window_h;
17031703+ update_stored_dimensions(target);
1665170416661705 // Update base dimensions
16671706 target->base_w = target->context->drawable_w;
···17681807 // If we're in windowed mode now and a resolution was stored, restore the original window resolution
17691808 if(was_fullscreen && !is_fullscreen && (target->context->stored_window_w != 0 && target->context->stored_window_h != 0))
17701809 SDL_SetWindowSize(window, target->context->stored_window_w, target->context->stored_window_h);
17711771-17721772- // Update window dims
17731773- SDL_GetWindowSize(window, &target->context->window_w, &target->context->window_h);
17741774- SDL_GL_GetDrawableSize(window, &target->context->drawable_w, &target->context->drawable_h);
17751810 }
1776181117771812#else
···17831818 {
17841819 SDL_WM_ToggleFullScreen(surf);
17851820 is_fullscreen = (surf->flags & SDL_FULLSCREEN);
17861786-17871787- // Update window dims
17881788- target->context->window_w = target->context->drawable_w = surf->w;
17891789- target->context->window_h = target->context->drawable_h = surf->h;
17901821 }
1791182217921823#endif
1793182417941825 if(is_fullscreen != was_fullscreen)
17951826 {
18271827+ // Update window dims
18281828+ get_window_dimensions(target, &target->context->window_w, &target->context->window_h);
18291829+ get_drawable_dimensions(target, &target->context->drawable_w, &target->context->drawable_h);
18301830+17961831 // If virtual res is not set, we need to update the target dims and reset stuff that no longer is right
17971832 if(!target->using_virtual_resolution)
17981833 {
+1
src/renderer_OpenGL_1_BASE.c
···1313// Most of the code pulled in from here...
1414#define SDL_GPU_USE_OPENGL
1515#define SDL_GPU_DISABLE_SHADERS
1616+#define SDL_GPU_DISABLE_RENDER_TO_TEXTURE
1617#define SDL_GPU_USE_FIXED_FUNCTION_PIPELINE
1718#define SDL_GPU_GL_TIER 1
1819#define SDL_GPU_GL_MAJOR_VERSION 1