src/video/SDL_video.c
branchSDL-1.3
changeset 1654 0a53c90a37f9
parent 1545 8d9bb0cf2c2a
child 1655 59227394023d
     1.1 --- a/src/video/SDL_video.c	Thu Apr 27 05:19:10 2006 +0000
     1.2 +++ b/src/video/SDL_video.c	Thu Apr 27 05:30:05 2006 +0000
     1.3 @@ -131,12 +131,8 @@
     1.4  /* Various local functions */
     1.5  int SDL_VideoInit(const char *driver_name, Uint32 flags);
     1.6  void SDL_VideoQuit(void);
     1.7 -void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect* rects);
     1.8  
     1.9  static SDL_GrabMode SDL_WM_GrabInputOff(void);
    1.10 -#if SDL_VIDEO_OPENGL
    1.11 -static int lock_count = 0;
    1.12 -#endif
    1.13  
    1.14  
    1.15  /*
    1.16 @@ -577,6 +573,12 @@
    1.17  	int is_opengl;
    1.18  	SDL_GrabMode saved_grab;
    1.19  
    1.20 +	/* Handle obsolete flags */
    1.21 +	if ( (flags & SDL_OPENGLBLIT_OBSOLETE) == SDL_OPENGLBLIT_OBSOLETE ) {
    1.22 +		SDL_SetError("SDL_OPENGLBLIT is no longer supported");
    1.23 +		return(NULL);
    1.24 +	}
    1.25 +
    1.26  	/* Start up the video driver, if necessary..
    1.27  	   WARNING: This is the only function protected this way!
    1.28  	 */
    1.29 @@ -748,7 +750,7 @@
    1.30  
    1.31  #if SDL_VIDEO_OPENGL
    1.32  	/* Load GL symbols (before MakeCurrent, where we need glGetString). */
    1.33 -	if ( flags & (SDL_OPENGL | SDL_OPENGLBLIT) ) {
    1.34 +	if ( flags & SDL_OPENGL ) {
    1.35  
    1.36  #if defined(__QNXNTO__) && (_NTO_VERSION < 630)
    1.37  #define __SDL_NOGETPROCADDR__
    1.38 @@ -782,89 +784,6 @@
    1.39  		}
    1.40  	}
    1.41  
    1.42 -	/* Set up a fake SDL surface for OpenGL "blitting" */
    1.43 -	if ( (flags & SDL_OPENGLBLIT) == SDL_OPENGLBLIT ) {
    1.44 -		/* Load GL functions for performing the texture updates */
    1.45 -#if SDL_VIDEO_OPENGL
    1.46 -
    1.47 -		/* Create a software surface for blitting */
    1.48 -#ifdef GL_VERSION_1_2
    1.49 -		/* If the implementation either supports the packed pixels
    1.50 -		   extension, or implements the core OpenGL 1.2 API, it will
    1.51 -		   support the GL_UNSIGNED_SHORT_5_6_5 texture format.
    1.52 -		 */
    1.53 -		if ( (bpp == 16) &&
    1.54 -		     (SDL_strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") ||
    1.55 -		     (SDL_atof((const char *)video->glGetString(GL_VERSION)) >= 1.2f))
    1.56 -		   ) {
    1.57 -			video->is_32bit = 0;
    1.58 -			SDL_VideoSurface = SDL_CreateRGBSurface(
    1.59 -				flags, 
    1.60 -				width, 
    1.61 -				height,  
    1.62 -				16,
    1.63 -				31 << 11,
    1.64 -				63 << 5,
    1.65 -				31,
    1.66 -				0
    1.67 -				);
    1.68 -		}
    1.69 -		else
    1.70 -#endif /* OpenGL 1.2 */
    1.71 -		{
    1.72 -			video->is_32bit = 1;
    1.73 -			SDL_VideoSurface = SDL_CreateRGBSurface(
    1.74 -				flags, 
    1.75 -				width, 
    1.76 -				height, 
    1.77 -				32, 
    1.78 -#if SDL_BYTEORDER == SDL_LIL_ENDIAN
    1.79 -				0x000000FF,
    1.80 -				0x0000FF00,
    1.81 -				0x00FF0000,
    1.82 -				0xFF000000
    1.83 -#else
    1.84 -				0xFF000000,
    1.85 -				0x00FF0000,
    1.86 -				0x0000FF00,
    1.87 -				0x000000FF
    1.88 -#endif
    1.89 -				);
    1.90 -		}
    1.91 -		if ( ! SDL_VideoSurface ) {
    1.92 -			return(NULL);
    1.93 -		}
    1.94 -		SDL_VideoSurface->flags = mode->flags | SDL_OPENGLBLIT;
    1.95 -
    1.96 -		/* Free the original video mode surface (is this safe?) */
    1.97 -		SDL_FreeSurface(mode);
    1.98 -
    1.99 -		/* Set the surface completely opaque & white by default */
   1.100 -		SDL_memset( SDL_VideoSurface->pixels, 255, SDL_VideoSurface->h * SDL_VideoSurface->pitch );
   1.101 -		video->glGenTextures( 1, &video->texture );
   1.102 -		video->glBindTexture( GL_TEXTURE_2D, video->texture );
   1.103 -		video->glTexImage2D(
   1.104 -			GL_TEXTURE_2D,
   1.105 -			0,
   1.106 -			video->is_32bit ? GL_RGBA : GL_RGB,
   1.107 -			256,
   1.108 -			256,
   1.109 -			0,
   1.110 -			video->is_32bit ? GL_RGBA : GL_RGB,
   1.111 -#ifdef GL_VERSION_1_2
   1.112 -			video->is_32bit ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5,
   1.113 -#else
   1.114 -			GL_UNSIGNED_BYTE,
   1.115 -#endif
   1.116 -			NULL);
   1.117 -
   1.118 -		video->UpdateRects = SDL_GL_UpdateRectsLock;
   1.119 -#else
   1.120 -		SDL_SetError("Somebody forgot to #define SDL_VIDEO_OPENGL");
   1.121 -		return(NULL);
   1.122 -#endif
   1.123 -	}
   1.124 -
   1.125  	/* Create a shadow surface if necessary */
   1.126  	/* There are three conditions under which we create a shadow surface:
   1.127  		1.  We need a particular bits-per-pixel that we didn't get.
   1.128 @@ -1511,155 +1430,6 @@
   1.129  	}
   1.130  }
   1.131  
   1.132 -/* Update rects with locking */
   1.133 -void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect *rects)
   1.134 -{
   1.135 -	SDL_GL_Lock();
   1.136 - 	SDL_GL_UpdateRects(numrects, rects);
   1.137 -	SDL_GL_Unlock();
   1.138 -}
   1.139 -
   1.140 -/* Update rects without state setting and changing (the caller is responsible for it) */
   1.141 -void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects)
   1.142 -{
   1.143 -#if SDL_VIDEO_OPENGL
   1.144 -	SDL_VideoDevice *this = current_video;
   1.145 -	SDL_Rect update, tmp;
   1.146 -	int x, y, i;
   1.147 -
   1.148 -	for ( i = 0; i < numrects; i++ )
   1.149 -	{
   1.150 -		tmp.y = rects[i].y;
   1.151 -		tmp.h = rects[i].h;
   1.152 -		for ( y = 0; y <= rects[i].h / 256; y++ )
   1.153 -		{
   1.154 -			tmp.x = rects[i].x;
   1.155 -			tmp.w = rects[i].w;
   1.156 -			for ( x = 0; x <= rects[i].w / 256; x++ )
   1.157 -			{
   1.158 -				update.x = tmp.x;
   1.159 -				update.y = tmp.y;
   1.160 -				update.w = tmp.w;
   1.161 -				update.h = tmp.h;
   1.162 -
   1.163 -				if ( update.w > 256 )
   1.164 -					update.w = 256;
   1.165 -
   1.166 -				if ( update.h > 256 )
   1.167 -					update.h = 256;
   1.168 -			
   1.169 -				this->glFlush();
   1.170 -				this->glTexSubImage2D( 
   1.171 -					GL_TEXTURE_2D, 
   1.172 -					0, 
   1.173 -					0, 
   1.174 -					0, 
   1.175 -					update.w, 
   1.176 -					update.h, 
   1.177 -					this->is_32bit? GL_RGBA : GL_RGB,
   1.178 -#ifdef GL_VERSION_1_2
   1.179 -					this->is_32bit ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5,
   1.180 -#else
   1.181 -					GL_UNSIGNED_BYTE,
   1.182 -#endif
   1.183 -					(Uint8 *)this->screen->pixels + 
   1.184 -						this->screen->format->BytesPerPixel * update.x + 
   1.185 -						update.y * this->screen->pitch );
   1.186 -	
   1.187 -				this->glFlush();
   1.188 -				/*
   1.189 -				* Note the parens around the function name:
   1.190 -				* This is because some OpenGL implementations define glTexCoord etc 
   1.191 -				* as macros, and we don't want them expanded here.
   1.192 -				*/
   1.193 -				this->glBegin(GL_TRIANGLE_STRIP);
   1.194 -					(this->glTexCoord2f)( 0.0, 0.0 );	
   1.195 -					(this->glVertex2i)( update.x, update.y );
   1.196 -					(this->glTexCoord2f)( (float)(update.w / 256.0), 0.0 );	
   1.197 -					(this->glVertex2i)( update.x + update.w, update.y );
   1.198 -					(this->glTexCoord2f)( 0.0, (float)(update.h / 256.0) );
   1.199 -					(this->glVertex2i)( update.x, update.y + update.h );
   1.200 -					(this->glTexCoord2f)( (float)(update.w / 256.0), (float)(update.h / 256.0) );	
   1.201 -					(this->glVertex2i)( update.x + update.w	, update.y + update.h );
   1.202 -				this->glEnd();	
   1.203 -			
   1.204 -				tmp.x += 256;
   1.205 -				tmp.w -= 256;
   1.206 -			}
   1.207 -			tmp.y += 256;
   1.208 -			tmp.h -= 256;
   1.209 -		}
   1.210 -	}
   1.211 -#endif
   1.212 -}
   1.213 -
   1.214 -/* Lock == save current state */
   1.215 -void SDL_GL_Lock()
   1.216 -{
   1.217 -#if SDL_VIDEO_OPENGL
   1.218 -	lock_count--;
   1.219 -	if (lock_count==-1)
   1.220 -	{
   1.221 -		SDL_VideoDevice *this = current_video;
   1.222 -
   1.223 -		this->glPushAttrib( GL_ALL_ATTRIB_BITS );	/* TODO: narrow range of what is saved */
   1.224 -#ifdef GL_CLIENT_PIXEL_STORE_BIT
   1.225 -		this->glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT );
   1.226 -#endif
   1.227 -
   1.228 -		this->glEnable(GL_TEXTURE_2D);
   1.229 -		this->glEnable(GL_BLEND);
   1.230 -		this->glDisable(GL_FOG);
   1.231 -		this->glDisable(GL_ALPHA_TEST);
   1.232 -		this->glDisable(GL_DEPTH_TEST);
   1.233 -		this->glDisable(GL_SCISSOR_TEST);	
   1.234 -		this->glDisable(GL_STENCIL_TEST);
   1.235 -		this->glDisable(GL_CULL_FACE);
   1.236 -
   1.237 -		this->glBindTexture( GL_TEXTURE_2D, this->texture );
   1.238 -		this->glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
   1.239 -		this->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
   1.240 -		this->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
   1.241 -		this->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
   1.242 -		this->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
   1.243 -
   1.244 -		this->glPixelStorei( GL_UNPACK_ROW_LENGTH, this->screen->pitch / this->screen->format->BytesPerPixel );
   1.245 -		this->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   1.246 -		(this->glColor4f)(1.0, 1.0, 1.0, 1.0);		/* Solaris workaround */
   1.247 -
   1.248 -		this->glViewport(0, 0, this->screen->w, this->screen->h);
   1.249 -		this->glMatrixMode(GL_PROJECTION);
   1.250 -		this->glPushMatrix();
   1.251 -		this->glLoadIdentity();
   1.252 -
   1.253 -		this->glOrtho(0.0, (GLdouble) this->screen->w, (GLdouble) this->screen->h, 0.0, 0.0, 1.0);
   1.254 -
   1.255 -		this->glMatrixMode(GL_MODELVIEW);
   1.256 -		this->glPushMatrix();
   1.257 -		this->glLoadIdentity();
   1.258 -	}
   1.259 -#endif
   1.260 -}
   1.261 -
   1.262 -/* Unlock == restore saved state */
   1.263 -void SDL_GL_Unlock()
   1.264 -{
   1.265 -#if SDL_VIDEO_OPENGL
   1.266 -	lock_count++;
   1.267 -	if (lock_count==0)
   1.268 -	{
   1.269 -		SDL_VideoDevice *this = current_video;
   1.270 -
   1.271 -		this->glPopMatrix();
   1.272 -		this->glMatrixMode(GL_PROJECTION);
   1.273 -		this->glPopMatrix();
   1.274 -
   1.275 -		this->glPopClientAttrib();
   1.276 -		this->glPopAttrib();
   1.277 -	}
   1.278 -#endif
   1.279 -}
   1.280 -
   1.281  /*
   1.282   * Sets/Gets the title and icon text of the display window, if any.
   1.283   */