Use GL_LUMINANCE8 for 3d palette lookup texture on OpenGL versions older than 3.0
This commit is contained in:
1 parent
fba1c11861
commit
558963c57c
1 file changed
+15
-1
@@ -4355,13 +4355,27 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
|
||||
|
||||
EXPORT void HWRAPI(SetPaletteLookup)(UINT8 *lut)
|
||||
{
|
||||
GLenum internalFormat;
|
||||
if (gl_version[0] == '1' || gl_version[0] == '2')
|
||||
{
|
||||
// if the OpenGL version is below 3.0, then the GL_R8 format may not be available.
|
||||
// so use GL_LUMINANCE8 instead to get a single component 8-bit format
|
||||
// (it is possible to have access to shaders even in some OpenGL 1.x systems,
|
||||
// so palette rendering can still possibly be achieved there)
|
||||
internalFormat = GL_LUMINANCE8;
|
||||
}
|
||||
else
|
||||
{
|
||||
internalFormat = GL_R8;
|
||||
}
|
||||
|
||||
if (!paletteLookupTex)
|
||||
pglGenTextures(1, &paletteLookupTex);
|
||||
pglActiveTexture(GL_TEXTURE1);
|
||||
pglBindTexture(GL_TEXTURE_3D, paletteLookupTex);
|
||||
pglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
pglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
pglTexImage3D(GL_TEXTURE_3D, 0, GL_R8, HWR_PALETTE_LUT_SIZE, HWR_PALETTE_LUT_SIZE, HWR_PALETTE_LUT_SIZE,
|
||||
pglTexImage3D(GL_TEXTURE_3D, 0, internalFormat, HWR_PALETTE_LUT_SIZE, HWR_PALETTE_LUT_SIZE, HWR_PALETTE_LUT_SIZE,
|
||||
0, GL_RED, GL_UNSIGNED_BYTE, lut);
|
||||
pglActiveTexture(GL_TEXTURE0);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user