int maxPalette;
PFNGLCOLORTABLEEXTPROC* glColorTableEXT;
PFNGLGETCOLORTABLEPARAMETERIVEXTPROC* glGetColorTableParameterivEXT;
// try to gain the pointer to the two functions
glColorTableEXT=(PFNGLCOLORTABLEEXTPROC)wglGetProcAddress("glColorTableEXT");
glGetColorTableParameterivEXT=(PFNGLGETCOLORTABLEPARAMETERIVEXTPROC)wglGetProcAddress("glGetColorTableParameterivEXT");
// were we succesfull?
if (glColorTableEXT==NULL || glGetColorTableParameterivEXT==NULL )
maxPalette = 0; // no: unluckly, we dont have any paletted texture support
else {
// yes: we seem to have some hardware support for paletted texture...
// ...but we'd better double-check
int res;
double d[0xFFFF]; // just a temporary buffer
// as a test, try to set a 16K palette...
(*glColorTableEXT)( GL_TEXTURE_2D,GL_RGBA8,0x4000, GL_RGBA,GL_FLOAT,d);
// now, is the palette size really 16K?
(*glGetColorTableParameterivEXT)(GL_TEXTURE_2D, GL_COLOR_TABLE_WIDTH_EXT , &res);
if (res==0x4000) maxPalette=0x4000 //yes!
else {
// no. something went wrong. The palette size was not found to be 16K.
// so, as a test, let's try to set at least a 256 palette...
(*glColorTableEXT)(GL_TEXTURE_2D,GL_RGBA8,0x100,GL_RGBA,GL_FLOAT,d);
// now, is the palette size really 256?
(*glGetColorTableParameterivEXT)(GL_TEXTURE_2D, GL_COLOR_TABLE_WIDTH_EXT , &res);
if (res==256) maxPalette=256; // yes: hardware support seems to work up to 256 sized palette
else maxPalette=0; // no: the hardware support was detected, but it does not seem to work!
}
}
|