mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-11 20:40:47 +00:00
Use GL_LUMINANCE8 for 3d palette lookup texture on OpenGL versions older than 3.0
Fixes white screen when the GL_R8 format is not available
This commit is contained in:
parent
f7a8bedec1
commit
0894547d1a
1 changed files with 14 additions and 1 deletions
|
@ -3262,13 +3262,26 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int tex, 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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue