- return is8bit;
-}
-
-typedef void (GLAPIENTRY *glColorTableEXT_FUNC) (GLenum, GLenum, GLsizei,
- GLenum, GLenum, const GLvoid *);
-typedef void (GLAPIENTRY *gl3DfxSetPaletteEXT_FUNC) (GLuint *pal);
-
-void VID_Init8bitPalette()
-{
- // Check for 8bit Extensions and initialize them.
- int i;
-
- dlhand = dlopen (NULL, RTLD_LAZY);
-
- Con_SafePrintf ("8-bit GL extensions: ");
-
- if (dlhand == NULL) {
- Con_SafePrintf ("unable to check.\n");
- return;
- }
-
- if (COM_CheckParm("-no8bit")) {
- Con_SafePrintf("disabled.\n");
- return;
- }
-
- if (strstr(gl_extensions, "3DFX_set_global_palette") && (qgl3DfxSetPaletteEXT = dlsym(dlhand, "gl3DfxSetPaletteEXT")) != NULL)
- {
- GLubyte table[256][4];
- char *oldpal;
-
- Con_SafePrintf("3DFX_set_global_palette.\n");
- glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
- oldpal = (char *) d_8to24table; //d_8to24table3dfx;
- for (i=0;i<256;i++)
- {
- table[i][2] = *oldpal++;
- table[i][1] = *oldpal++;
- table[i][0] = *oldpal++;
- table[i][3] = 255;
- oldpal++;
- }
- qgl3DfxSetPaletteEXT((GLuint *)table);
- is8bit = true;
- } else if (strstr(gl_extensions, "GL_EXT_shared_texture_palette")) {
- char thePalette[256*3];
- char *oldPalette, *newPalette;
- glColorTableEXT_FUNC load_texture = NULL;
-
- Con_SafePrintf("GL_EXT_shared.\n");
- load_texture = (void *) dlsym(dlhand, "glColorTableEXT");
-
- glEnable( GL_SHARED_TEXTURE_PALETTE_EXT );
- oldPalette = (char *) d_8to24table; //d_8to24table3dfx;
- newPalette = thePalette;
- for (i=0;i<256;i++) {
- *newPalette++ = *oldPalette++;
- *newPalette++ = *oldPalette++;
- *newPalette++ = *oldPalette++;
- oldPalette++;
- }
- load_texture(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, (void *) thePalette);
- is8bit = true;
- } else {
- Con_SafePrintf ("not found.\n");
- }
-
- dlclose(dlhand);
- dlhand = NULL;