r1177 - in trunk/code: renderer sdl

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Sep 12 14:02:39 EDT 2007


Author: tma
Date: 2007-09-12 14:02:38 -0400 (Wed, 12 Sep 2007)
New Revision: 1177

Modified:
   trunk/code/renderer/qgl.h
   trunk/code/renderer/tr_backend.c
   trunk/code/renderer/tr_image.c
   trunk/code/renderer/tr_init.c
   trunk/code/renderer/tr_local.h
   trunk/code/renderer/tr_shade.c
   trunk/code/renderer/tr_shader.c
   trunk/code/sdl/sdl_glimp.c
Log:
* Revert 1176 -- MinGW's headers are too old *sigh*
* Revert to using literal function pointers for GL extensions rather than PFN*
  typedefs as some platforms' headers are broken enough that they prevent
  SDL_opengl.h from fixing things up if the PFN* typedefs are missing


Modified: trunk/code/renderer/qgl.h
===================================================================
--- trunk/code/renderer/qgl.h	2007-09-10 22:28:58 UTC (rev 1176)
+++ trunk/code/renderer/qgl.h	2007-09-12 18:02:38 UTC (rev 1177)
@@ -28,9 +28,14 @@
 
 #include "SDL_opengl.h"
 
-extern PFNGLLOCKARRAYSEXTPROC qglLockArraysEXT;
-extern PFNGLUNLOCKARRAYSEXTPROC qglUnlockArraysEXT;
+extern void (APIENTRYP qglActiveTextureARB) (GLenum texture);
+extern void (APIENTRYP qglClientActiveTextureARB) (GLenum texture);
+extern void (APIENTRYP qglMultiTexCoord2fARB) (GLenum target, GLfloat s, GLfloat t);
 
+extern void (APIENTRYP qglLockArraysEXT) (GLint first, GLsizei count);
+extern void (APIENTRYP qglUnlockArraysEXT) (void);
+
+
 //===========================================================================
 
 #define qglAccum glAccum
@@ -367,23 +372,5 @@
 #define qglVertex4sv glVertex4sv
 #define qglVertexPointer glVertexPointer
 #define qglViewport glViewport
-#define qglMultiTexCoord1s glMultiTexCoord1s
-#define qglMultiTexCoord1i glMultiTexCoord1i
-#define qglMultiTexCoord1f glMultiTexCoord1f
-#define qglMultiTexCoord1d glMultiTexCoord1d
-#define qglMultiTexCoord2s glMultiTexCoord2s
-#define qglMultiTexCoord2i glMultiTexCoord2i
-#define qglMultiTexCoord2f glMultiTexCoord2f
-#define qglMultiTexCoord2d glMultiTexCoord2d
-#define qglMultiTexCoord3s glMultiTexCoord3s
-#define qglMultiTexCoord3i glMultiTexCoord3i
-#define qglMultiTexCoord3f glMultiTexCoord3f
-#define qglMultiTexCoord3d glMultiTexCoord3d
-#define qglMultiTexCoord4s glMultiTexCoord4s
-#define qglMultiTexCoord4i glMultiTexCoord4i
-#define qglMultiTexCoord4f glMultiTexCoord4f
-#define qglMultiTexCoord4d glMultiTexCoord4d
-#define qglActiveTexture glActiveTexture
-#define qglClientActiveTexture glClientActiveTexture
 
 #endif

Modified: trunk/code/renderer/tr_backend.c
===================================================================
--- trunk/code/renderer/tr_backend.c	2007-09-10 22:28:58 UTC (rev 1176)
+++ trunk/code/renderer/tr_backend.c	2007-09-12 18:02:38 UTC (rev 1177)
@@ -71,17 +71,17 @@
 
 	if ( unit == 0 )
 	{
-		qglActiveTexture( GL_TEXTURE0 );
-		GLimp_LogComment( "glActiveTexture( GL_TEXTURE0 )\n" );
-		qglClientActiveTexture( GL_TEXTURE0 );
-		GLimp_LogComment( "glClientActiveTexture( GL_TEXTURE0 )\n" );
+		qglActiveTextureARB( GL_TEXTURE0_ARB );
+		GLimp_LogComment( "glActiveTextureARB( GL_TEXTURE0_ARB )\n" );
+		qglClientActiveTextureARB( GL_TEXTURE0_ARB );
+		GLimp_LogComment( "glClientActiveTextureARB( GL_TEXTURE0_ARB )\n" );
 	}
 	else if ( unit == 1 )
 	{
-		qglActiveTexture( GL_TEXTURE1 );
-		GLimp_LogComment( "glActiveTexture( GL_TEXTURE1 )\n" );
-		qglClientActiveTexture( GL_TEXTURE1 );
-		GLimp_LogComment( "glClientActiveTexture( GL_TEXTURE1 )\n" );
+		qglActiveTextureARB( GL_TEXTURE1_ARB );
+		GLimp_LogComment( "glActiveTextureARB( GL_TEXTURE1_ARB )\n" );
+		qglClientActiveTextureARB( GL_TEXTURE1_ARB );
+		GLimp_LogComment( "glClientActiveTextureARB( GL_TEXTURE1_ARB )\n" );
 	} else {
 		ri.Error( ERR_DROP, "GL_SelectTexture: unit = %i", unit );
 	}

Modified: trunk/code/renderer/tr_image.c
===================================================================
--- trunk/code/renderer/tr_image.c	2007-09-10 22:28:58 UTC (rev 1176)
+++ trunk/code/renderer/tr_image.c	2007-09-12 18:02:38 UTC (rev 1177)
@@ -765,13 +765,13 @@
 	image->wrapClampMode = glWrapClampMode;
 
 	// lightmaps are always allocated on TMU 1
-	if ( glConfig.numTextureUnits > 1 && isLightmap ) {
+	if ( qglActiveTextureARB && isLightmap ) {
 		image->TMU = 1;
 	} else {
 		image->TMU = 0;
 	}
 
-	if ( glConfig.numTextureUnits > 1 ) {
+	if ( qglActiveTextureARB ) {
 		GL_SelectTexture( image->TMU );
 	}
 
@@ -4849,7 +4849,7 @@
 	tr.numImages = 0;
 
 	Com_Memset( glState.currenttextures, 0, sizeof( glState.currenttextures ) );
-	if ( glConfig.numTextureUnits > 1 ) {
+	if ( qglActiveTextureARB ) {
 		GL_SelectTexture( 1 );
 		qglBindTexture( GL_TEXTURE_2D, 0 );
 		GL_SelectTexture( 0 );

Modified: trunk/code/renderer/tr_init.c
===================================================================
--- trunk/code/renderer/tr_init.c	2007-09-10 22:28:58 UTC (rev 1176)
+++ trunk/code/renderer/tr_init.c	2007-09-12 18:02:38 UTC (rev 1177)
@@ -80,6 +80,7 @@
 cvar_t	*r_allowExtensions;
 
 cvar_t	*r_ext_compressed_textures;
+cvar_t	*r_ext_multitexture;
 cvar_t	*r_ext_compiled_vertex_array;
 cvar_t	*r_ext_texture_env_add;
 cvar_t	*r_ext_texture_filter_anisotropic;
@@ -759,7 +760,7 @@
 
 	// initialize downstream texture unit if we're running
 	// in a multitexture environment
-	if ( glConfig.numTextureUnits > 1 ) {
+	if ( qglActiveTextureARB ) {
 		GL_SelectTexture( 1 );
 		GL_TextureMode( r_textureMode->string );
 		GL_TexEnv( GL_MODULATE );
@@ -815,7 +816,7 @@
 	ri.Printf( PRINT_ALL, "GL_VERSION: %s\n", glConfig.version_string );
 	ri.Printf( PRINT_ALL, "GL_EXTENSIONS: %s\n", glConfig.extensions_string );
 	ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_SIZE: %d\n", glConfig.maxTextureSize );
-	ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_UNITS: %d\n", glConfig.numTextureUnits );
+	ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_UNITS_ARB: %d\n", glConfig.numTextureUnits );
 	ri.Printf( PRINT_ALL, "\nPIXELFORMAT: color(%d-bits) Z(%d-bit) stencil(%d-bits)\n", glConfig.colorBits, glConfig.depthBits, glConfig.stencilBits );
 	ri.Printf( PRINT_ALL, "MODE: %d, %d x %d %s hz:", r_mode->integer, glConfig.vidWidth, glConfig.vidHeight, fsstrings[r_fullscreen->integer == 1] );
 	if ( glConfig.displayFrequency )
@@ -863,7 +864,7 @@
 	ri.Printf( PRINT_ALL, "texturemode: %s\n", r_textureMode->string );
 	ri.Printf( PRINT_ALL, "picmip: %d\n", r_picmip->integer );
 	ri.Printf( PRINT_ALL, "texture bits: %d\n", r_texturebits->integer );
-	ri.Printf( PRINT_ALL, "multitexture: %s\n", enablestrings[glConfig.numTextureUnits > 1] );
+	ri.Printf( PRINT_ALL, "multitexture: %s\n", enablestrings[qglActiveTextureARB != 0] );
 	ri.Printf( PRINT_ALL, "compiled vertex arrays: %s\n", enablestrings[qglLockArraysEXT != 0 ] );
 	ri.Printf( PRINT_ALL, "texenv add: %s\n", enablestrings[glConfig.textureEnvAddAvailable != 0] );
 	ri.Printf( PRINT_ALL, "compressed textures: %s\n", enablestrings[glConfig.textureCompression!=TC_NONE] );
@@ -899,6 +900,7 @@
 	//
 	r_allowExtensions = ri.Cvar_Get( "r_allowExtensions", "1", CVAR_ARCHIVE | CVAR_LATCH );
 	r_ext_compressed_textures = ri.Cvar_Get( "r_ext_compressed_textures", "0", CVAR_ARCHIVE | CVAR_LATCH );
+	r_ext_multitexture = ri.Cvar_Get( "r_ext_multitexture", "1", CVAR_ARCHIVE | CVAR_LATCH );
 	r_ext_compiled_vertex_array = ri.Cvar_Get( "r_ext_compiled_vertex_array", "1", CVAR_ARCHIVE | CVAR_LATCH);
 	r_ext_texture_env_add = ri.Cvar_Get( "r_ext_texture_env_add", "1", CVAR_ARCHIVE | CVAR_LATCH);
 

Modified: trunk/code/renderer/tr_local.h
===================================================================
--- trunk/code/renderer/tr_local.h	2007-09-10 22:28:58 UTC (rev 1176)
+++ trunk/code/renderer/tr_local.h	2007-09-12 18:02:38 UTC (rev 1177)
@@ -1041,6 +1041,7 @@
 
 extern cvar_t	*r_allowExtensions;				// global enable/disable of OpenGL extensions
 extern cvar_t	*r_ext_compressed_textures;		// these control use of specific extensions
+extern cvar_t	*r_ext_multitexture;
 extern cvar_t	*r_ext_compiled_vertex_array;
 extern cvar_t	*r_ext_texture_env_add;
 

Modified: trunk/code/renderer/tr_shade.c
===================================================================
--- trunk/code/renderer/tr_shade.c	2007-09-10 22:28:58 UTC (rev 1176)
+++ trunk/code/renderer/tr_shade.c	2007-09-12 18:02:38 UTC (rev 1177)
@@ -43,8 +43,8 @@
 static void APIENTRY R_ArrayElementDiscrete( GLint index ) {
 	qglColor4ubv( tess.svars.colors[ index ] );
 	if ( glState.currenttmu ) {
-		qglMultiTexCoord2f( 0, tess.svars.texcoords[ 0 ][ index ][0], tess.svars.texcoords[ 0 ][ index ][1] );
-		qglMultiTexCoord2f( 1, tess.svars.texcoords[ 1 ][ index ][0], tess.svars.texcoords[ 1 ][ index ][1] );
+		qglMultiTexCoord2fARB( 0, tess.svars.texcoords[ 0 ][ index ][0], tess.svars.texcoords[ 0 ][ index ][1] );
+		qglMultiTexCoord2fARB( 1, tess.svars.texcoords[ 1 ][ index ][0], tess.svars.texcoords[ 1 ][ index ][1] );
 	} else {
 		qglTexCoord2fv( tess.svars.texcoords[ 0 ][ index ] );
 	}

Modified: trunk/code/renderer/tr_shader.c
===================================================================
--- trunk/code/renderer/tr_shader.c	2007-09-10 22:28:58 UTC (rev 1176)
+++ trunk/code/renderer/tr_shader.c	2007-09-12 18:02:38 UTC (rev 1177)
@@ -1761,7 +1761,7 @@
 	int i;
 	textureBundle_t tmpBundle;
 
-	if ( glConfig.numTextureUnits < 2 ) {
+	if ( !qglActiveTextureARB ) {
 		return qfalse;
 	}
 

Modified: trunk/code/sdl/sdl_glimp.c
===================================================================
--- trunk/code/sdl/sdl_glimp.c	2007-09-10 22:28:58 UTC (rev 1176)
+++ trunk/code/sdl/sdl_glimp.c	2007-09-12 18:02:38 UTC (rev 1177)
@@ -70,9 +70,13 @@
 
 cvar_t *r_allowSoftwareGL; // Don't abort out if a hardware visual can't be obtained
 
-PFNGLLOCKARRAYSEXTPROC qglLockArraysEXT;
-PFNGLUNLOCKARRAYSEXTPROC qglUnlockArraysEXT;
+void (APIENTRYP qglActiveTextureARB) (GLenum texture);
+void (APIENTRYP qglClientActiveTextureARB) (GLenum texture);
+void (APIENTRYP qglMultiTexCoord2fARB) (GLenum target, GLfloat s, GLfloat t);
 
+void (APIENTRYP qglLockArraysEXT) (GLint first, GLsizei count);
+void (APIENTRYP qglUnlockArraysEXT) (void);
+
 /*
 ===============
 GLimp_Shutdown
@@ -85,8 +89,8 @@
 	SDL_QuitSubSystem( SDL_INIT_VIDEO );
 	screen = NULL;
 
-	memset( &glConfig, 0, sizeof( glConfig ) );
-	memset( &glState, 0, sizeof( glState ) );
+	Com_Memset( &glConfig, 0, sizeof( glConfig ) );
+	Com_Memset( &glState, 0, sizeof( glState ) );
 }
 
 /*
@@ -376,6 +380,46 @@
 		ri.Printf( PRINT_ALL, "...GL_EXT_texture_env_add not found\n" );
 	}
 
+	// GL_ARB_multitexture
+	qglMultiTexCoord2fARB = NULL;
+	qglActiveTextureARB = NULL;
+	qglClientActiveTextureARB = NULL;
+	if ( Q_stristr( glConfig.extensions_string, "GL_ARB_multitexture" ) )
+	{
+		if ( r_ext_multitexture->value )
+		{
+			qglMultiTexCoord2fARB = ( PFNGLMULTITEXCOORD2FARBPROC ) SDL_GL_GetProcAddress( "glMultiTexCoord2fARB" );
+			qglActiveTextureARB = ( PFNGLACTIVETEXTUREARBPROC ) SDL_GL_GetProcAddress( "glActiveTextureARB" );
+			qglClientActiveTextureARB = ( PFNGLCLIENTACTIVETEXTUREARBPROC ) SDL_GL_GetProcAddress( "glClientActiveTextureARB" );
+
+			if ( qglActiveTextureARB )
+			{
+				GLint glint = 0;
+				qglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glint );
+				glConfig.numTextureUnits = (int) glint;
+				if ( glConfig.numTextureUnits > 1 )
+				{
+					ri.Printf( PRINT_ALL, "...using GL_ARB_multitexture\n" );
+				}
+				else
+				{
+					qglMultiTexCoord2fARB = NULL;
+					qglActiveTextureARB = NULL;
+					qglClientActiveTextureARB = NULL;
+					ri.Printf( PRINT_ALL, "...not using GL_ARB_multitexture, < 2 texture units\n" );
+				}
+			}
+		}
+		else
+		{
+			ri.Printf( PRINT_ALL, "...ignoring GL_ARB_multitexture\n" );
+		}
+	}
+	else
+	{
+		ri.Printf( PRINT_ALL, "...GL_ARB_multitexture not found\n" );
+	}
+
 	// GL_EXT_compiled_vertex_array
 	if ( Q_stristr( glConfig.extensions_string, "GL_EXT_compiled_vertex_array" ) )
 	{
@@ -471,11 +515,6 @@
 	Q_strncpyz( glConfig.version_string, (char *) qglGetString (GL_VERSION), sizeof( glConfig.version_string ) );
 	Q_strncpyz( glConfig.extensions_string, (char *) qglGetString (GL_EXTENSIONS), sizeof( glConfig.extensions_string ) );
 
-	// multitexturing
-	qglGetIntegerv( GL_MAX_TEXTURE_UNITS, (GLint *)&glConfig.numTextureUnits );
-	if( glConfig.numTextureUnits < 2 )
-		ri.Printf( PRINT_ALL, "Insufficient texture units for multitexturing\n" );
-
 	// initialize extensions
 	GLimp_InitExtensions( );
 




More information about the quake3-commits mailing list