From 190fe3e78e21a63fd55064831e4e48de4a5e2a99 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 27 Apr 2006 05:30:05 +0000 Subject: [PATCH] Updated to 1.3.0, SDL_OPENGLBLIT is no longer supported --- TODO | 1 + configure.in | 8 +- include/SDL_version.h | 4 +- include/SDL_video.h | 10 +- src/main/macos/exports/SDL.x | 3 - src/video/SDL_video.c | 244 +---------------------------- src/video/cybergfx/SDL_cgxvideo.c | 2 +- src/video/quartz/SDL_QuartzVideo.m | 5 +- src/video/x11/SDL_x11video.c | 2 +- test/configure.in | 2 +- test/testgl.c | 101 +----------- 11 files changed, 21 insertions(+), 361 deletions(-) diff --git a/TODO b/TODO index 65bb01c17..1a3e29b27 100644 --- a/TODO +++ b/TODO @@ -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 diff --git a/configure.in b/configure.in index f6125ca75..b69d9846a 100644 --- a/configure.in +++ b/configure.in @@ -15,10 +15,10 @@ dnl Set various version strings - taken gratefully from the GTk sources # 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) diff --git a/include/SDL_version.h b/include/SDL_version.h index 52dd52f40..d1b7b56eb 100644 --- a/include/SDL_version.h +++ b/include/SDL_version.h @@ -36,8 +36,8 @@ extern "C" { /* 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; diff --git a/include/SDL_video.h b/include/SDL_video.h index ba7585340..d4d2cd56d 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -124,7 +124,7 @@ typedef struct SDL_Surface { #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 int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int* value); */ 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. */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/src/main/macos/exports/SDL.x b/src/main/macos/exports/SDL.x index 44db7a48e..388bf1dc8 100644 --- a/src/main/macos/exports/SDL.x +++ b/src/main/macos/exports/SDL.x @@ -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 diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 02a521de9..9848623e6 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -131,12 +131,8 @@ SDL_VideoDevice *current_video = NULL; /* 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 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) 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 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) #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 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) } } - /* 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 @@ void SDL_GL_SwapBuffers(void) } } -/* 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. */ diff --git a/src/video/cybergfx/SDL_cgxvideo.c b/src/video/cybergfx/SDL_cgxvideo.c index e3067464d..a723dc274 100644 --- a/src/video/cybergfx/SDL_cgxvideo.c +++ b/src/video/cybergfx/SDL_cgxvideo.c @@ -598,7 +598,7 @@ void CGX_DestroyWindow(_THIS, SDL_Surface *screen) /* Clean up OpenGL */ if ( screen ) { - screen->flags &= ~(SDL_OPENGL|SDL_OPENGLBLIT); + screen->flags &= ~SDL_OPENGL; } if ( screen && (screen->flags & SDL_FULLSCREEN) ) { diff --git a/src/video/quartz/SDL_QuartzVideo.m b/src/video/quartz/SDL_QuartzVideo.m index 1010473aa..8fe4b737d 100644 --- a/src/video/quartz/SDL_QuartzVideo.m +++ b/src/video/quartz/SDL_QuartzVideo.m @@ -1353,10 +1353,7 @@ static void QZ_DrawResizeIcon (_THIS, RgnHandle dirtyRegion) { 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 */ } diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index b419e352c..38919c7f2 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -585,7 +585,7 @@ static void X11_DestroyWindow(_THIS, SDL_Surface *screen) { /* Clean up OpenGL */ if ( screen ) { - screen->flags &= ~(SDL_OPENGL|SDL_OPENGLBLIT); + screen->flags &= ~SDL_OPENGL; } X11_GL_Shutdown(this); diff --git a/test/configure.in b/test/configure.in index 9499ad5ab..deccbf3fb 100644 --- a/test/configure.in +++ b/test/configure.in @@ -60,7 +60,7 @@ AC_SUBST(EXE) 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!]) diff --git a/test/testgl.c b/test/testgl.c index 60ebc6c97..283d7fe26 100644 --- a/test/testgl.c +++ b/test/testgl.c @@ -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 @@ void DrawLogoTexture(void) 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 @@ int RunGLTest( int argc, char* argv[], } /* 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 @@ int RunGLTest( int argc, char* argv[], /* Draw 2D logo onto the 3D display */ if ( logo ) { - if ( USE_DEPRECATED_OPENGLBLIT ) { - DrawLogoBlit(); - } else { - DrawLogoTexture(); - } + DrawLogoTexture(); } if ( logocursor ) { DrawLogoCursor(); @@ -780,11 +688,6 @@ int main(int argc, char *argv[]) } 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;