Rendering on PSP again.
This commit is contained in:
@@ -66,6 +66,7 @@ void textureInit(
|
||||
"Palette index out of range"
|
||||
);
|
||||
|
||||
// Get and validate the palette.
|
||||
const palette_t *pal = PALETTE_LIST[data.palette.palette];
|
||||
assertNotNull(pal, "Palette cannot be NULL");
|
||||
GLenum err = glGetError();
|
||||
@@ -75,18 +76,23 @@ void textureInit(
|
||||
|
||||
// Do we support paletted textures?
|
||||
bool_t havePalTex = false;
|
||||
GLint mask = 0;
|
||||
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
|
||||
if(mask & GL_CONTEXT_CORE_PROFILE_BIT) {
|
||||
GLint n=0; glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||
for (GLint i=0; i<n; ++i) {
|
||||
const char* e = (const char*)glGetStringi(GL_EXTENSIONS, i);
|
||||
if (e && strcmp(e, "GL_EXT_paletted_texture")==0) { havePalTex = true; break; }
|
||||
|
||||
#if PSP
|
||||
havePalTex = true;
|
||||
#else
|
||||
GLint mask = 0;
|
||||
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask);
|
||||
if(mask & GL_CONTEXT_CORE_PROFILE_BIT) {
|
||||
GLint n=0; glGetIntegerv(GL_NUM_EXTENSIONS, &n);
|
||||
for (GLint i=0; i<n; ++i) {
|
||||
const char* e = (const char*)glGetStringi(GL_EXTENSIONS, i);
|
||||
if (e && strcmp(e, "GL_EXT_paletted_texture")==0) { havePalTex = true; break; }
|
||||
}
|
||||
} else {
|
||||
const char* ext = (const char*)glGetString(GL_EXTENSIONS);
|
||||
havePalTex = ext && strstr(ext, "GL_EXT_paletted_texture");
|
||||
}
|
||||
} else {
|
||||
const char* ext = (const char*)glGetString(GL_EXTENSIONS);
|
||||
havePalTex = ext && strstr(ext, "GL_EXT_paletted_texture");
|
||||
}
|
||||
#endif
|
||||
|
||||
if(!havePalTex) {
|
||||
// Not supported, convert to RGBA using lookup
|
||||
@@ -105,10 +111,14 @@ void textureInit(
|
||||
);
|
||||
} else {
|
||||
// Supported.
|
||||
glColorTableEXT(
|
||||
GL_TEXTURE_2D, GL_RGBA, pal->colorCount, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, (const void*)pal->colors
|
||||
);
|
||||
#if PSP
|
||||
// PSP requires the color table itself to be a power of two
|
||||
assertTrue(
|
||||
pal->colorCount == mathNextPowTwo(pal->colorCount),
|
||||
"Palette color count must be a power of 2 for PSP"
|
||||
);
|
||||
#endif
|
||||
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0, GL_COLOR_INDEX8_EXT,
|
||||
@@ -116,6 +126,11 @@ void textureInit(
|
||||
0, GL_COLOR_INDEX8_EXT,
|
||||
GL_UNSIGNED_BYTE, (void*)data.palette.data
|
||||
);
|
||||
|
||||
glColorTableEXT(
|
||||
GL_TEXTURE_2D, GL_RGBA, pal->colorCount, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, (const void*)pal->colors
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -129,8 +144,6 @@ void textureInit(
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user