[Scummvm-cvs-logs] CVS: scummvm/backends/sdl fb2opengl.h,1.4,1.5 sdl_gl.cpp,1.12,1.13

Travis Howell kirben at users.sourceforge.net
Tue Oct 29 06:58:03 CET 2002


Update of /cvsroot/scummvm/scummvm/backends/sdl
In directory usw-pr-cvs1:/tmp/cvs-serv29714/backends/sdl

Modified Files:
	fb2opengl.h sdl_gl.cpp 
Log Message:

Add OpenGL GFX mode switch, patch #630448 


Index: fb2opengl.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/fb2opengl.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- fb2opengl.h	25 Oct 2002 14:56:58 -0000	1.4
+++ fb2opengl.h	29 Oct 2002 14:57:32 -0000	1.5
@@ -46,7 +46,7 @@
     // Framebuffer for 8 bpp
     unsigned char ogl_fb[256][256];
     unsigned char ogl_fbb[256][64];
-    // Framebuffer for RGBA */ 
+    // Framebuffer for RGBA
     unsigned char ogl_fb1[256][256][4];
     unsigned char ogl_fb2[256][64][4];
     // Framebuffer for the blit function (SDL Blitting)
@@ -134,7 +134,10 @@
   double yfix=(double)yf/128;
   // End of 256x256 (from -1.0 to 1.0)
   double texend = (double)96/160; // 160=320/2 (== 0.0), 256-160=96.
-  
+ 
+  if (glIsList(dlist)) 
+    glDeleteLists(dlist,1);
+      
   dlist=glGenLists(1);
   glNewList(dlist,GL_COMPILE);
 
@@ -211,7 +214,8 @@
     }
   }
   
-  maketex();
+  if (width>0 && height>0) 
+    maketex();
   makedlist(xfix, yfix);
 
 /*  glEnable(GL_ALPHA_TEST);

Index: sdl_gl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl_gl.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- sdl_gl.cpp	25 Oct 2002 14:56:58 -0000	1.12
+++ sdl_gl.cpp	29 Oct 2002 14:57:32 -0000	1.13
@@ -31,11 +31,10 @@
 #endif
 
 #include "fb2opengl.h"
-int _screenStart = 20;
 
 class OSystem_SDL_Normal : public OSystem_SDL_Common {
 public:
-	OSystem_SDL_Normal() : sdl_tmpscreen(0), sdl_hwscreen(0), _overlay_visible(false) {}
+	OSystem_SDL_Normal() : sdl_tmpscreen(0), sdl_hwscreen(0), _overlay_visible(false) { _glScreenStart = 0; }
 
 	// Set colors of the palette
 	void set_palette(const byte *colors, uint start, uint num);
@@ -55,8 +54,11 @@
 
 protected:
 	FB2GL fb2gl;
+	int gl_flags;
+	int _glScreenStart;
 	SDL_Surface *tmpSurface; // Used for black rectangles blitting 
 	SDL_Rect tmpBlackRect; // Black rectangle at end of the GL screen
+
 	typedef void ScalerProc(uint8 *srcPtr, uint32 srcPitch, uint8 *deltaPtr,
 								uint8 *dstPtr, uint32 dstPitch, int width, int height);
 
@@ -222,7 +224,6 @@
 
 	sdl_tmpscreen = NULL;
 	TMP_SCREEN_WIDTH = (_screenWidth + 3);
-//	TMP_SCREEN_WIDTH = (_screenWidth);
 	
 	//
 	// Create the surface that contains the 8 bit game data
@@ -236,10 +237,13 @@
 	// Create the surface that contains the scaled graphics in 16 bit mode
 	//
 
-	int gl_flags =  FB2GL_320 | FB2GL_RGBA | FB2GL_16BIT;
-        if (_full_screen) gl_flags |= (FB2GL_FS);
+	gl_flags =  FB2GL_320 | FB2GL_RGBA | FB2GL_16BIT;
+        if (_full_screen) {
+	  gl_flags |= (FB2GL_FS);
+	  _glScreenStart = 0;
+	}
 	// 640x480 screen resolution
-	fb2gl.init(640,480,0,_screenStart? 15: 70,gl_flags);
+	fb2gl.init(640,480,0,_glScreenStart? 15: 70,gl_flags);
 
 	SDL_SetGamma(1.25,1.25,1.25);
 
@@ -261,7 +265,7 @@
 	
 	tmpSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, _screenWidth, 
 						// 320x256 texture (black end)
-						256-_screenHeight-_screenStart,
+						256-_screenHeight-_glScreenStart,
 						16,
 						Rmask,
 						Gmask,
@@ -271,7 +275,7 @@
 	tmpBlackRect.x = 0;
 	tmpBlackRect.y = 0;
 	tmpBlackRect.w = _screenWidth;
-	tmpBlackRect.h = 256-_screenHeight-_screenStart;
+	tmpBlackRect.h = 256-_screenHeight-_glScreenStart;
 	
 	if (sdl_tmpscreen == NULL)
 		error("sdl_tmpscreen failed");
@@ -290,11 +294,6 @@
 		_screen = NULL; 
 	}
 
-	if (sdl_hwscreen) {
-		SDL_FreeSurface(sdl_hwscreen); 
-		sdl_hwscreen = NULL;
-	}
-	
 	if (sdl_tmpscreen) {
 		free((uint16*)sdl_tmpscreen->pixels);
 		SDL_FreeSurface(sdl_tmpscreen);
@@ -306,7 +305,7 @@
 	
 	// If the shake position changed, fill the dirty area with blackness
 	if (_currentShakePos != _newShakePos) {
-		SDL_Rect blackrect = {0, _screenStart, _screenWidth, _newShakePos+_screenStart};
+		SDL_Rect blackrect = {0, _glScreenStart, _screenWidth, _newShakePos+_glScreenStart};
 		
 		SDL_FillRect(tmpSurface, &blackrect, 0);
 		fb2gl.blit16(tmpSurface,1,&blackrect,0,0);
@@ -361,11 +360,11 @@
 
 		// Almost the same thing as SDL_UpdateRects
 		fb2gl.blit16(sdl_tmpscreen,_num_dirty_rects,_dirty_rect_list,0,
-		    _currentShakePos+_screenStart);
+		    _currentShakePos+_glScreenStart);
 
 		
 		SDL_FillRect(tmpSurface, &tmpBlackRect, 0);
-		fb2gl.blit16(tmpSurface,1,&tmpBlackRect,0,_screenHeight+_screenStart);
+		fb2gl.blit16(tmpSurface,1,&tmpBlackRect,0,_screenHeight+_glScreenStart);
 
 		fb2gl.display();
 	}
@@ -400,20 +399,31 @@
 uint32 OSystem_SDL_Normal::property(int param, Property *value) {
 
 	if (param == PROP_TOGGLE_FULLSCREEN) {
-//		assert(sdl_hwscreen != 0);
 		_full_screen ^= true;
-
-//		if (!SDL_WM_ToggleFullScreen(sdl_hwscreen)) {
-			// if ToggleFullScreen fails, achieve the same effect with hotswap gfx mode
-//			hotswap_gfx_mode();
-		  
-//		}
+	
 		SDL_WM_ToggleFullScreen(fb2gl.screen);
 		return 1;
 	} else if (param == PROP_OVERLAY_IS_565) {
 		assert(sdl_tmpscreen != 0);
 		return (sdl_tmpscreen->format->Rmask != 0x7C00);
 	}
+	else if (param == PROP_SET_GFX_MODE) {
+		if (value->gfx_mode==0) {
+		  fb2gl.init(0,0,0,15,gl_flags);
+		  _glScreenStart = 20;
+		  SDL_FillRect(tmpSurface,&tmpBlackRect,0);
+		  fb2gl.blit16(tmpSurface,1,&tmpBlackRect,0,0);
+		}
+		else {
+		  fb2gl.init(0,0,0,70,gl_flags);
+		  _glScreenStart = 0;
+		}
+		SDL_Rect full = {0,0,_screenWidth,_screenHeight};
+		fb2gl.blit16(sdl_tmpscreen,1,&full,0,_glScreenStart);
+		fb2gl.display();
+		return 1;
+	}
+	
 	
 	return OSystem_SDL_Common::property(param, value);
 }





More information about the Scummvm-git-logs mailing list