This commit is contained in:
Glenn Maynard
2004-03-13 07:38:46 +00:00
parent 7ea70ab1b3
commit 0a0f43e3bb
+18 -20
View File
@@ -454,25 +454,26 @@ bool HasExtension(CString ext)
static void CheckPalettedTextures( bool LowColor )
{
CString error;
do
{
if( GLExt::glColorTableEXT == NULL )
{
error = "glColorTableEXT missing";
goto fail;
break;
}
if( GLExt::glGetColorTableParameterivEXT == NULL )
{
error = "glGetColorTableParameterivEXT missing";
goto fail;
break;
}
/* Check to see if paletted textures really work. */
GLenum glTexFormat; glTexFormat = GL_PIXFMT_INFO[RageDisplay::FMT_PAL].internalfmt;
GLenum glImageFormat; glImageFormat = GL_PIXFMT_INFO[RageDisplay::FMT_PAL].format;
GLenum glImageType; glImageType = GL_PIXFMT_INFO[RageDisplay::FMT_PAL].type;
GLenum glTexFormat = GL_PIXFMT_INFO[RageDisplay::FMT_PAL].internalfmt;
GLenum glImageFormat = GL_PIXFMT_INFO[RageDisplay::FMT_PAL].format;
GLenum glImageType = GL_PIXFMT_INFO[RageDisplay::FMT_PAL].type;
int bits; bits = 8;
int bits = 8;
if( LowColor )
{
@@ -482,13 +483,13 @@ static void CheckPalettedTextures( bool LowColor )
FlushGLErrors();
#define GL_CHECK_ERROR(f) \
{ \
{ \
GLenum glError = glGetError(); \
if( glError != GL_NO_ERROR ) { \
error = ssprintf(f " failed (%s)", GLToString(glError).c_str() ); \
goto fail; \
break; \
} \
}
}
glTexImage2D(GL_PROXY_TEXTURE_2D,
0, glTexFormat,
@@ -496,7 +497,6 @@ static void CheckPalettedTextures( bool LowColor )
glImageFormat, glImageType, NULL);
GL_CHECK_ERROR( "glTexImage2D" );
{
GLuint ifmt = 0;
glGetTexLevelParameteriv( GL_PROXY_TEXTURE_2D, 0, GLenum(GL_TEXTURE_INTERNAL_FORMAT), (GLint *)&ifmt );
if( ifmt != glTexFormat )
@@ -504,8 +504,7 @@ static void CheckPalettedTextures( bool LowColor )
error = ssprintf( "Expected format %s, got %s instead",
GLToString(glTexFormat).c_str(),
GLToString(ifmt).c_str() );
goto fail;
}
break;
}
GLubyte palette[256*4];
@@ -513,14 +512,13 @@ static void CheckPalettedTextures( bool LowColor )
GLExt::glColorTableEXT(GL_PROXY_TEXTURE_2D, GL_RGBA8, 1 << bits, GL_RGBA, GL_UNSIGNED_BYTE, palette);
GL_CHECK_ERROR( "glColorTableEXT" );
{ // in brackets to hush VC6 error
GLint size = 0;
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GLenum(GL_TEXTURE_INDEX_SIZE_EXT), &size);
GL_CHECK_ERROR( "glGetTexLevelParameteriv(GL_TEXTURE_INDEX_SIZE_EXT)" );
if( bits > size || size > 8 )
{
error = ssprintf("Expected %i-bit palette, got a %i-bit one instead", bits, int(size));
goto fail;
break;
}
GLint RealWidth = 0;
@@ -529,7 +527,7 @@ static void CheckPalettedTextures( bool LowColor )
if( RealWidth != 1 << bits )
{
error = ssprintf("GL_COLOR_TABLE_WIDTH returned %i instead of %i", int(RealWidth), 1 << bits );
goto fail;
break;
}
GLint RealFormat = 0;
@@ -538,13 +536,14 @@ static void CheckPalettedTextures( bool LowColor )
if( RealFormat != GL_RGBA8 )
{
error = ssprintf("GL_COLOR_TABLE_FORMAT returned %s instead of GL_RGBA8", GLToString(RealFormat).c_str() );
goto fail;
}
break;
}
} while(0);
#undef GL_CHECK_ERROR
if( error == "" )
return;
fail:
if( LowColor )
{
/* Disable 4-bit palettes, but allow 8-bit ones. */
@@ -557,7 +556,6 @@ fail:
GLExt::glGetColorTableParameterivEXT = NULL;
LOG->Info("Paletted textures disabled: %s.", error.c_str());
}
#undef GL_CHECK_ERROR
}
static void CheckReversePackedPixels()