Updated to 1.3.0, SDL_OPENGLBLIT is no longer supported SDL-1.3
authorSam Lantinga <slouken@libsdl.org>
Thu, 27 Apr 2006 05:30:05 +0000
branchSDL-1.3
changeset 1654 0a53c90a37f9
parent 1653 939d938d62df
child 1655 59227394023d
Updated to 1.3.0, SDL_OPENGLBLIT is no longer supported
TODO
configure.in
include/SDL_version.h
include/SDL_video.h
src/main/macos/exports/SDL.x
src/video/SDL_video.c
src/video/cybergfx/SDL_cgxvideo.c
src/video/quartz/SDL_QuartzVideo.m
src/video/x11/SDL_x11video.c
test/configure.in
test/testgl.c
--- a/TODO	Thu Apr 27 05:19:10 2006 +0000
+++ b/TODO	Thu Apr 27 05:30:05 2006 +0000
@@ -2,6 +2,7 @@
 Wish list for the 1.3 development branch:
 http://bugzilla.libsdl.org/
 
+ * Support querying and setting refresh rate with video modes
  * Add mousewheel events (new unified event architecture?)
  * DirectInput joystick support needs to be implemented
  * Be able to enumerate and select available audio and video drivers
--- a/configure.in	Thu Apr 27 05:19:10 2006 +0000
+++ b/configure.in	Thu Apr 27 05:30:05 2006 +0000
@@ -15,10 +15,10 @@
 # set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
 #
 SDL_MAJOR_VERSION=1
-SDL_MINOR_VERSION=2
-SDL_MICRO_VERSION=10
-SDL_INTERFACE_AGE=3
-SDL_BINARY_AGE=10
+SDL_MINOR_VERSION=3
+SDL_MICRO_VERSION=0
+SDL_INTERFACE_AGE=0
+SDL_BINARY_AGE=0
 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
 
 AC_SUBST(SDL_MAJOR_VERSION)
--- a/include/SDL_version.h	Thu Apr 27 05:19:10 2006 +0000
+++ b/include/SDL_version.h	Thu Apr 27 05:30:05 2006 +0000
@@ -36,8 +36,8 @@
 /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
 */
 #define SDL_MAJOR_VERSION	1
-#define SDL_MINOR_VERSION	2
-#define SDL_PATCHLEVEL		10
+#define SDL_MINOR_VERSION	3
+#define SDL_PATCHLEVEL		0
 
 typedef struct SDL_version {
 	Uint8 major;
--- a/include/SDL_video.h	Thu Apr 27 05:19:10 2006 +0000
+++ b/include/SDL_video.h	Thu Apr 27 05:30:05 2006 +0000
@@ -124,7 +124,7 @@
 #define SDL_DOUBLEBUF	0x40000000	/* Set up double-buffered video mode */
 #define SDL_FULLSCREEN	0x80000000	/* Surface is a full screen display */
 #define SDL_OPENGL      0x00000002      /* Create an OpenGL rendering context */
-#define SDL_OPENGLBLIT	0x0000000A	/* Create an OpenGL rendering context and use it for blitting */
+#define SDL_OPENGLBLIT_OBSOLETE 0x0000000A /* Obsolete, do not use! */
 #define SDL_RESIZABLE	0x00000010	/* This video mode may be resized */
 #define SDL_NOFRAME	0x00000020	/* No window caption or edge frame */
 /* Used internally (read-only) */
@@ -807,14 +807,6 @@
  */
 extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
 
-/*
- * Internal functions that should not be called unless you have read
- * and understood the source code for these functions.
- */
-extern DECLSPEC void SDLCALL SDL_GL_UpdateRects(int numrects, SDL_Rect* rects);
-extern DECLSPEC void SDLCALL SDL_GL_Lock(void);
-extern DECLSPEC void SDLCALL SDL_GL_Unlock(void);
-
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 /* These functions allow interaction with the window manager, if any.        */
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
--- a/src/main/macos/exports/SDL.x	Thu Apr 27 05:19:10 2006 +0000
+++ b/src/main/macos/exports/SDL.x	Thu Apr 27 05:30:05 2006 +0000
@@ -178,9 +178,6 @@
 	SDL_GL_SetAttribute
 	SDL_GL_GetAttribute
 	SDL_GL_SwapBuffers
-	SDL_GL_UpdateRects
-	SDL_GL_Lock
-	SDL_GL_Unlock
 	SDL_WM_SetCaption
 	SDL_WM_GetCaption
 	SDL_WM_SetIcon
--- a/src/video/SDL_video.c	Thu Apr 27 05:19:10 2006 +0000
+++ b/src/video/SDL_video.c	Thu Apr 27 05:30:05 2006 +0000
@@ -131,12 +131,8 @@
 /* Various local functions */
 int SDL_VideoInit(const char *driver_name, Uint32 flags);
 void SDL_VideoQuit(void);
-void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect* rects);
 
 static SDL_GrabMode SDL_WM_GrabInputOff(void);
-#if SDL_VIDEO_OPENGL
-static int lock_count = 0;
-#endif
 
 
 /*
@@ -577,6 +573,12 @@
 	int is_opengl;
 	SDL_GrabMode saved_grab;
 
+	/* Handle obsolete flags */
+	if ( (flags & SDL_OPENGLBLIT_OBSOLETE) == SDL_OPENGLBLIT_OBSOLETE ) {
+		SDL_SetError("SDL_OPENGLBLIT is no longer supported");
+		return(NULL);
+	}
+
 	/* Start up the video driver, if necessary..
 	   WARNING: This is the only function protected this way!
 	 */
@@ -748,7 +750,7 @@
 
 #if SDL_VIDEO_OPENGL
 	/* Load GL symbols (before MakeCurrent, where we need glGetString). */
-	if ( flags & (SDL_OPENGL | SDL_OPENGLBLIT) ) {
+	if ( flags & SDL_OPENGL ) {
 
 #if defined(__QNXNTO__) && (_NTO_VERSION < 630)
 #define __SDL_NOGETPROCADDR__
@@ -782,89 +784,6 @@
 		}
 	}
 
-	/* Set up a fake SDL surface for OpenGL "blitting" */
-	if ( (flags & SDL_OPENGLBLIT) == SDL_OPENGLBLIT ) {
-		/* Load GL functions for performing the texture updates */
-#if SDL_VIDEO_OPENGL
-
-		/* Create a software surface for blitting */
-#ifdef GL_VERSION_1_2
-		/* If the implementation either supports the packed pixels
-		   extension, or implements the core OpenGL 1.2 API, it will
-		   support the GL_UNSIGNED_SHORT_5_6_5 texture format.
-		 */
-		if ( (bpp == 16) &&
-		     (SDL_strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") ||
-		     (SDL_atof((const char *)video->glGetString(GL_VERSION)) >= 1.2f))
-		   ) {
-			video->is_32bit = 0;
-			SDL_VideoSurface = SDL_CreateRGBSurface(
-				flags, 
-				width, 
-				height,  
-				16,
-				31 << 11,
-				63 << 5,
-				31,
-				0
-				);
-		}
-		else
-#endif /* OpenGL 1.2 */
-		{
-			video->is_32bit = 1;
-			SDL_VideoSurface = SDL_CreateRGBSurface(
-				flags, 
-				width, 
-				height, 
-				32, 
-#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-				0x000000FF,
-				0x0000FF00,
-				0x00FF0000,
-				0xFF000000
-#else
-				0xFF000000,
-				0x00FF0000,
-				0x0000FF00,
-				0x000000FF
-#endif
-				);
-		}
-		if ( ! SDL_VideoSurface ) {
-			return(NULL);
-		}
-		SDL_VideoSurface->flags = mode->flags | SDL_OPENGLBLIT;
-
-		/* Free the original video mode surface (is this safe?) */
-		SDL_FreeSurface(mode);
-
-		/* Set the surface completely opaque & white by default */
-		SDL_memset( SDL_VideoSurface->pixels, 255, SDL_VideoSurface->h * SDL_VideoSurface->pitch );
-		video->glGenTextures( 1, &video->texture );
-		video->glBindTexture( GL_TEXTURE_2D, video->texture );
-		video->glTexImage2D(
-			GL_TEXTURE_2D,
-			0,
-			video->is_32bit ? GL_RGBA : GL_RGB,
-			256,
-			256,
-			0,
-			video->is_32bit ? GL_RGBA : GL_RGB,
-#ifdef GL_VERSION_1_2
-			video->is_32bit ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5,
-#else
-			GL_UNSIGNED_BYTE,
-#endif
-			NULL);
-
-		video->UpdateRects = SDL_GL_UpdateRectsLock;
-#else
-		SDL_SetError("Somebody forgot to #define SDL_VIDEO_OPENGL");
-		return(NULL);
-#endif
-	}
-
 	/* Create a shadow surface if necessary */
 	/* There are three conditions under which we create a shadow surface:
 		1.  We need a particular bits-per-pixel that we didn't get.
@@ -1511,155 +1430,6 @@
 	}
 }
 
-/* Update rects with locking */
-void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect *rects)
-{
-	SDL_GL_Lock();
- 	SDL_GL_UpdateRects(numrects, rects);
-	SDL_GL_Unlock();
-}
-
-/* Update rects without state setting and changing (the caller is responsible for it) */
-void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects)
-{
-#if SDL_VIDEO_OPENGL
-	SDL_VideoDevice *this = current_video;
-	SDL_Rect update, tmp;
-	int x, y, i;
-
-	for ( i = 0; i < numrects; i++ )
-	{
-		tmp.y = rects[i].y;
-		tmp.h = rects[i].h;
-		for ( y = 0; y <= rects[i].h / 256; y++ )
-		{
-			tmp.x = rects[i].x;
-			tmp.w = rects[i].w;
-			for ( x = 0; x <= rects[i].w / 256; x++ )
-			{
-				update.x = tmp.x;
-				update.y = tmp.y;
-				update.w = tmp.w;
-				update.h = tmp.h;
-
-				if ( update.w > 256 )
-					update.w = 256;
-
-				if ( update.h > 256 )
-					update.h = 256;
-			
-				this->glFlush();
-				this->glTexSubImage2D( 
-					GL_TEXTURE_2D, 
-					0, 
-					0, 
-					0, 
-					update.w, 
-					update.h, 
-					this->is_32bit? GL_RGBA : GL_RGB,
-#ifdef GL_VERSION_1_2
-					this->is_32bit ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5,
-#else
-					GL_UNSIGNED_BYTE,
-#endif
-					(Uint8 *)this->screen->pixels + 
-						this->screen->format->BytesPerPixel * update.x + 
-						update.y * this->screen->pitch );
-	
-				this->glFlush();
-				/*
-				* Note the parens around the function name:
-				* This is because some OpenGL implementations define glTexCoord etc 
-				* as macros, and we don't want them expanded here.
-				*/
-				this->glBegin(GL_TRIANGLE_STRIP);
-					(this->glTexCoord2f)( 0.0, 0.0 );	
-					(this->glVertex2i)( update.x, update.y );
-					(this->glTexCoord2f)( (float)(update.w / 256.0), 0.0 );	
-					(this->glVertex2i)( update.x + update.w, update.y );
-					(this->glTexCoord2f)( 0.0, (float)(update.h / 256.0) );
-					(this->glVertex2i)( update.x, update.y + update.h );
-					(this->glTexCoord2f)( (float)(update.w / 256.0), (float)(update.h / 256.0) );	
-					(this->glVertex2i)( update.x + update.w	, update.y + update.h );
-				this->glEnd();	
-			
-				tmp.x += 256;
-				tmp.w -= 256;
-			}
-			tmp.y += 256;
-			tmp.h -= 256;
-		}
-	}
-#endif
-}
-
-/* Lock == save current state */
-void SDL_GL_Lock()
-{
-#if SDL_VIDEO_OPENGL
-	lock_count--;
-	if (lock_count==-1)
-	{
-		SDL_VideoDevice *this = current_video;
-
-		this->glPushAttrib( GL_ALL_ATTRIB_BITS );	/* TODO: narrow range of what is saved */
-#ifdef GL_CLIENT_PIXEL_STORE_BIT
-		this->glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT );
-#endif
-
-		this->glEnable(GL_TEXTURE_2D);
-		this->glEnable(GL_BLEND);
-		this->glDisable(GL_FOG);
-		this->glDisable(GL_ALPHA_TEST);
-		this->glDisable(GL_DEPTH_TEST);
-		this->glDisable(GL_SCISSOR_TEST);	
-		this->glDisable(GL_STENCIL_TEST);
-		this->glDisable(GL_CULL_FACE);
-
-		this->glBindTexture( GL_TEXTURE_2D, this->texture );
-		this->glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
-		this->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
-		this->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
-		this->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
-		this->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
-
-		this->glPixelStorei( GL_UNPACK_ROW_LENGTH, this->screen->pitch / this->screen->format->BytesPerPixel );
-		this->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-		(this->glColor4f)(1.0, 1.0, 1.0, 1.0);		/* Solaris workaround */
-
-		this->glViewport(0, 0, this->screen->w, this->screen->h);
-		this->glMatrixMode(GL_PROJECTION);
-		this->glPushMatrix();
-		this->glLoadIdentity();
-
-		this->glOrtho(0.0, (GLdouble) this->screen->w, (GLdouble) this->screen->h, 0.0, 0.0, 1.0);
-
-		this->glMatrixMode(GL_MODELVIEW);
-		this->glPushMatrix();
-		this->glLoadIdentity();
-	}
-#endif
-}
-
-/* Unlock == restore saved state */
-void SDL_GL_Unlock()
-{
-#if SDL_VIDEO_OPENGL
-	lock_count++;
-	if (lock_count==0)
-	{
-		SDL_VideoDevice *this = current_video;
-
-		this->glPopMatrix();
-		this->glMatrixMode(GL_PROJECTION);
-		this->glPopMatrix();
-
-		this->glPopClientAttrib();
-		this->glPopAttrib();
-	}
-#endif
-}
-
 /*
  * Sets/Gets the title and icon text of the display window, if any.
  */
--- a/src/video/cybergfx/SDL_cgxvideo.c	Thu Apr 27 05:19:10 2006 +0000
+++ b/src/video/cybergfx/SDL_cgxvideo.c	Thu Apr 27 05:30:05 2006 +0000
@@ -598,7 +598,7 @@
 
 		/* Clean up OpenGL */
 		if ( screen ) {
-		screen->flags &= ~(SDL_OPENGL|SDL_OPENGLBLIT);
+		screen->flags &= ~SDL_OPENGL;
 		}
 
 		if ( screen && (screen->flags & SDL_FULLSCREEN) ) {
--- a/src/video/quartz/SDL_QuartzVideo.m	Thu Apr 27 05:19:10 2006 +0000
+++ b/src/video/quartz/SDL_QuartzVideo.m	Thu Apr 27 05:30:05 2006 +0000
@@ -1353,10 +1353,7 @@
 
 static void QZ_UpdateRects (_THIS, int numRects, SDL_Rect *rects) {
 
-    if (SDL_VideoSurface->flags & SDL_OPENGLBLIT) {
-        QZ_GL_SwapBuffers (this);
-    }
-    else if ( [ qz_window isMiniaturized ] ) {
+    if ( [ qz_window isMiniaturized ] ) {
     
         /* Do nothing if miniaturized */
     }
--- a/src/video/x11/SDL_x11video.c	Thu Apr 27 05:19:10 2006 +0000
+++ b/src/video/x11/SDL_x11video.c	Thu Apr 27 05:30:05 2006 +0000
@@ -585,7 +585,7 @@
 {
 	/* Clean up OpenGL */
 	if ( screen ) {
-		screen->flags &= ~(SDL_OPENGL|SDL_OPENGLBLIT);
+		screen->flags &= ~SDL_OPENGL;
 	}
 	X11_GL_Shutdown(this);
 
--- a/test/configure.in	Thu Apr 27 05:19:10 2006 +0000
+++ b/test/configure.in	Thu Apr 27 05:30:05 2006 +0000
@@ -60,7 +60,7 @@
 AC_SUBST(MATHLIB)
 
 dnl Check for SDL
-SDL_VERSION=1.2.10
+SDL_VERSION=1.3.0
 AM_PATH_SDL($SDL_VERSION,
             :,
 	    AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
--- a/test/testgl.c	Thu Apr 27 05:19:10 2006 +0000
+++ b/test/testgl.c	Thu Apr 27 05:30:05 2006 +0000
@@ -15,12 +15,6 @@
 /* Define this to be the name of the logo image to use with -logo */
 #define LOGO_FILE	"icon.bmp"
 
-/* The SDL_OPENGLBLIT interface is deprecated.
-   The code is still available for benchmark purposes though.
-*/
-
-static SDL_bool USE_DEPRECATED_OPENGLBLIT = SDL_FALSE;
-
 static SDL_Surface *global_image = NULL;
 static GLuint global_texture = 0;
 static GLuint cursor_texture = 0;
@@ -366,84 +360,6 @@
 	SDL_GL_Leave2DMode();
 }
 
-/* This code is deprecated, but available for speed comparisons */
-void DrawLogoBlit(void)
-{
-	static int x = 0;
-	static int y = 0;
-	static int w, h;
-	static int delta_x = 1;
-	static int delta_y = 1;
-
-	SDL_Rect dst;
-	SDL_Surface *screen = SDL_GetVideoSurface();
-
-	if ( global_image == NULL ) {
-		SDL_Surface *temp;
-
-		/* Load the image (could use SDL_image library here) */
-		temp = SDL_LoadBMP(LOGO_FILE);
-		if ( temp == NULL ) {
-			return;
-		}
-		w = temp->w;
-		h = temp->h;
-
-		/* Convert the image into the screen format */
-		global_image = SDL_CreateRGBSurface(
-				SDL_SWSURFACE,
-				w, h,
-				screen->format->BitsPerPixel,
-				screen->format->Rmask,
-				screen->format->Gmask,
-				screen->format->Bmask,
-				screen->format->Amask);
-		if ( global_image ) {
-			SDL_BlitSurface(temp, NULL, global_image, NULL);
-		}
-		SDL_FreeSurface(temp);
-
-		/* Make sure that the texture conversion is okay */
-		if ( ! global_image ) {
-			return;
-		}
-	}
-
-	/* Move the image around
-           Note that we do not clear the old position.  This is because we
-           perform a glClear() which clears the framebuffer and then only
-           update the new area.
-           Note that you can also achieve interesting effects by modifying
-           the screen surface alpha channel.  It's set to 255 by default..
-         */
-	x += delta_x;
-	if ( x < 0 ) {
-		x = 0;
-		delta_x = -delta_x;
-	} else
-	if ( (x+w) > screen->w ) {
-		x = screen->w-w;
-		delta_x = -delta_x;
-	}
-	y += delta_y;
-	if ( y < 0 ) {
-		y = 0;
-		delta_y = -delta_y;
-	} else
-	if ( (y+h) > screen->h ) {
-		y = screen->h-h;
-		delta_y = -delta_y;
-	}
-	dst.x = x;
-	dst.y = y;
-	dst.w = w;
-	dst.h = h;
-	SDL_BlitSurface(global_image, NULL, screen, &dst);
-
-	/* Show the image on the screen */
-	SDL_UpdateRects(screen, 1, &dst);
-}
-
 int RunGLTest( int argc, char* argv[],
                int logo, int logocursor, int slowly, int bpp, float gamma, int noframe, int fsaa )
 {
@@ -488,11 +404,7 @@
 	}
 
 	/* Set the flags we want to use for setting the video mode */
-	if ( logo && USE_DEPRECATED_OPENGLBLIT ) {
-		video_flags = SDL_OPENGLBLIT;
-	} else {
-		video_flags = SDL_OPENGL;
-	}
+	video_flags = SDL_OPENGL;
 	for ( i=1; argv[i]; ++i ) {
 		if ( strcmp(argv[i], "-fullscreen") == 0 ) {
 			video_flags |= SDL_FULLSCREEN;
@@ -698,11 +610,7 @@
 
 		/* Draw 2D logo onto the 3D display */
 		if ( logo ) {
-			if ( USE_DEPRECATED_OPENGLBLIT ) {
-				DrawLogoBlit();
-			} else {
-				DrawLogoTexture();
-			}
+			DrawLogoTexture();
 		}
 		if ( logocursor ) {
 			DrawLogoCursor();
@@ -780,11 +688,6 @@
 		}
 		if ( strcmp(argv[i], "-logo") == 0 ) {
 			logo = 1;
-			USE_DEPRECATED_OPENGLBLIT = SDL_FALSE;
-		}
-		if ( strcmp(argv[i], "-logoblit") == 0 ) {
-			logo = 1;
-			USE_DEPRECATED_OPENGLBLIT = SDL_TRUE;
 		}
 		if ( strcmp(argv[i], "-logocursor") == 0 ) {
 			logocursor = 1;