Ticket #8196: sdl_gl.cpp.patch

File sdl_gl.cpp.patch, 3.0 KB (added by SF/luke_br, 22 years ago)

SDL/GL hotswap and black rectangle fix

Line 
137c37,41
2< OSystem_SDL_OpenGL() { _glScreenStart = 0; _glBilinearFilter = true; }
3---
4> OSystem_SDL_OpenGL() {
5> _glScreenStart = 0;
6> _glBilinearFilter = true;
7> _glBottomOfTexture = 256; // height is always 256
8> }
950c54
10< int gl_flags;
11---
12> int _glFlags;
1355c59,60
14<
15---
16> int _glBottomOfTexture;
17>
1857a63
19> void hotswap_gfx_mode();
20110c116
21< gl_flags = FB2GL_320 | FB2GL_RGBA | FB2GL_16BIT;
22---
23> _glFlags = FB2GL_320 | FB2GL_RGBA | FB2GL_16BIT;
24112c118
25< gl_flags |= (FB2GL_FS);
26---
27> _glFlags |= (FB2GL_FS);
28116c122
29< fb2gl.init(640, 480, 0,_glScreenStart? 15: 70,gl_flags);
30---
31> fb2gl.init(640, 480, 0,_glScreenStart? 15: 70,_glFlags);
32158a165
33> SDL_SetGamma(1.0, 1.0, 1.0);
34170a178,209
35> void OSystem_SDL_OpenGL::hotswap_gfx_mode() {
36> if (!_screen)
37> return;
38>
39> // Keep around the old _screen & _tmpscreen so we can restore the screen data
40> // after the mode switch.
41> SDL_Surface *old_screen = _screen;
42> SDL_Surface *old_tmpscreen = _tmpscreen;
43>
44> // Release the HW screen surface
45> SDL_FreeSurface(fb2gl.getScreen());
46> fb2gl.setScreen(NULL);
47>
48> // Setup the new GFX mode
49> load_gfx_mode();
50>
51> // reset palette
52> SDL_SetColors(_screen, _currentPalette, 0, 256);
53>
54> // Restore old screen content
55> SDL_BlitSurface(old_screen, NULL, _screen, NULL);
56> SDL_BlitSurface(old_tmpscreen, NULL, _tmpscreen, NULL);
57>
58> // Free the old surfaces
59> SDL_FreeSurface(old_screen);
60> free(old_tmpscreen->pixels);
61> SDL_FreeSurface(old_tmpscreen);
62>
63> // Finally, blit everything to the screen
64> update_screen();
65> }
66>
67231,235c270,278
68< tmpBlackRect.h = 256 - _screenHeight - _glScreenStart - _currentShakePos;
69<
70< SDL_FillRect(tmpSurface, &tmpBlackRect, 0);
71< fb2gl.blit16(tmpSurface, 1, &tmpBlackRect, 0,_screenHeight
72< + _glScreenStart+_currentShakePos);
73---
74> int _glBottomOfGameScreen = _screenHeight + _glScreenStart + _currentShakePos;
75> // Bottom black border height
76> tmpBlackRect.h = _glBottomOfTexture - _glBottomOfGameScreen;
77>
78> if (!(_full_screen) && (tmpBlackRect.h > 0)) {
79> SDL_FillRect(tmpSurface, &tmpBlackRect, 0);
80> fb2gl.blit16(tmpSurface, 1, &tmpBlackRect, 0,
81> _glBottomOfGameScreen);
82> }
83248a292,302
84> #ifdef MACOSX
85> // On OS X, SDL_WM_ToggleFullScreen is currently not implemented. Worse,
86> // it still always returns -1. So we simply don't call it at all and
87> // use hotswap_gfx_mode() directly to switch to fullscreen mode.
88> hotswap_gfx_mode();
89> #else
90> if (!SDL_WM_ToggleFullScreen(fb2gl.getScreen())) {
91> // if ToggleFullScreen fails, achieve the same effect with hotswap gfx mode
92> hotswap_gfx_mode();
93> }
94> #endif
95250d303
96< SDL_WM_ToggleFullScreen(fb2gl.screen);
97271,272c324,325
98< case 1: // Don't fit the whole screen
99< fb2gl.init(0, 0, 0, 15, gl_flags);
100---
101> case 1: // Don't use the whole screen
102> fb2gl.init(0, 0, 0, 15, _glFlags);
103277,278c330,331
104< case 2: // Fit the whole screen
105< fb2gl.init(0, 0, 0, 70, gl_flags);
106---
107> case 2: // Use the whole screen
108> fb2gl.init(0, 0, 0, 70, _glFlags);