[Scummvm-cvs-logs] CVS: scummvm/backends/sdl sdl_gl.cpp,1.37,1.38

Travis Howell kirben at users.sourceforge.net
Sun Jun 22 05:32:02 CEST 2003


Update of /cvsroot/scummvm/scummvm/backends/sdl
In directory sc8-pr-cvs1:/tmp/cvs-serv27566/backends/sdl

Modified Files:
	sdl_gl.cpp 
Log Message:

Aspect ratio works with all sclaers in opengl backend


Index: sdl_gl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl_gl.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- sdl_gl.cpp	22 Jun 2003 11:55:40 -0000	1.37
+++ sdl_gl.cpp	22 Jun 2003 12:30:58 -0000	1.38
@@ -199,8 +199,8 @@
 		
 	} else { // SDL backend
 	  
-		_hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, _screenHeight * _scaleFactor, 16, 
-		  _full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
+		_hwscreen = SDL_SetVideoMode(_screenWidth * _scaleFactor, (_adjustAspectRatio ? 240 : _screenHeight) * _scaleFactor, 16, 
+		_full_screen ? (SDL_FULLSCREEN|SDL_SWSURFACE) : SDL_SWSURFACE
 		);
 		if (_hwscreen == NULL)
 			error("_hwscreen failed");
@@ -421,7 +421,7 @@
 			fb2gl.display();
 		} else { // SDL backend
 			
-			if (_scaler_proc == Normal1x) {
+			if (_scaler_proc == Normal1x && !_adjustAspectRatio) {
 				SDL_Surface *target = _overlayVisible ? _tmpscreen : _screen;
 				for (r = _dirty_rect_list; r != last_rect; ++r) {
 					dst = *r;
@@ -454,6 +454,8 @@
 				for (r = _dirty_rect_list; r != last_rect; ++r) {
 					register int dst_y = r->y + _currentShakePos;
 					register int dst_h = 0;
+					register int orig_dst_y = 0;
+
 					if (dst_y < _screenHeight) {
 						dst_h = r->h;
 						if (dst_h > _screenHeight - dst_y)
@@ -461,6 +463,11 @@
 			
 							dst_y *= _scaleFactor;
 			
+							if (_adjustAspectRatio) {
+								orig_dst_y = dst_y;
+								dst_y = real2Aspect(dst_y);
+							}
+
 							_scaler_proc((byte *)_tmpscreen->pixels + (r->x * 2 + 2) + (r->y + 1) * srcPitch, srcPitch,
 							(byte *)_hwscreen->pixels + r->x * 2 * _scaleFactor + dst_y * dstPitch, dstPitch, r->w, dst_h);
 					}
@@ -469,6 +476,9 @@
 					r->y = dst_y;
 					r->w *= _scaleFactor;
 					r->h = dst_h * _scaleFactor;
+
+					if (_adjustAspectRatio && orig_dst_y / _scaleFactor < _screenHeight)
+						r->h = stretch200To240((uint8 *) _hwscreen->pixels, dstPitch, r->w, r->h, r->x, r->y, orig_dst_y);
 				}
 			
 				SDL_UnlockSurface(_tmpscreen);
@@ -479,7 +489,7 @@
 			// This is necessary if shaking is active.
 			if (_forceFull) {
 				_dirty_rect_list[0].y = 0;
-				_dirty_rect_list[0].h = _screenHeight * _scaleFactor;
+				_dirty_rect_list[0].h = (_adjustAspectRatio ? 240 : _screenHeight) * _scaleFactor;
 			}
 			
 			// Finally, blit all our changes to the screen
@@ -541,28 +551,31 @@
 
 		return 1;
 	} else if (param == PROP_TOGGLE_ASPECT_RATIO) {
-		if (!_usingOpenGL) {
-			_usingOpenGL = true;
-			_mode = GFX_NORMAL;
-			hotswap_gfx_mode();
-		}
 
 		_adjustAspectRatio ^= true;
-		if (_adjustAspectRatio) {
-			// Don't use the whole screen (black borders)
-			fb2gl.init(0, 0, 0, 15, _glFlags);
-			_glScreenStart = 20;
-			SDL_FillRect(tmpSurface, &tmpBlackRect, 0);
-			fb2gl.blit16(tmpSurface, 1, &tmpBlackRect, 0, 0);
+		if (_usingOpenGL) {
+			if (_adjustAspectRatio) {
+				// Don't use the whole screen (black borders)
+				fb2gl.init(0, 0, 0, 15, _glFlags);
+				_glScreenStart = 20;
+				SDL_FillRect(tmpSurface, &tmpBlackRect, 0);
+				fb2gl.blit16(tmpSurface, 1, &tmpBlackRect, 0, 0);
+			} else {
+				// Use the whole screen
+				fb2gl.init(0, 0, 0, 70, _glFlags);
+				_glScreenStart = 0;
+			}
+
+			SDL_Rect full = {0, 0, _screenWidth, _screenHeight};
+			fb2gl.blit16(_tmpscreen, 1, &full, 0, _glScreenStart);
+			fb2gl.display();
 		} else {
-			// Use the whole screen
-			fb2gl.init(0, 0, 0, 70, _glFlags);
-			_glScreenStart = 0;
+			if (_screenHeight == 200) {
+				assert(_hwscreen != 0);
+				hotswap_gfx_mode();
+			}
 		}
 
-		SDL_Rect full = {0, 0, _screenWidth, _screenHeight};
-		fb2gl.blit16(_tmpscreen, 1, &full, 0, _glScreenStart);
-		fb2gl.display();
 	} else if (param == PROP_SET_GFX_MODE) {
 
 		if (value->gfx_mode > 10) { // OpenGL modes





More information about the Scummvm-git-logs mailing list