mirror of https://github.com/OpenRCT2/OpenRCT2.git
Change GL_TEXTURE_RECTANGLE to NPOT GL_TEXTURE_2D
This improves GLES compatiblity due to missing rectangle textures, but NPOT 2D ones being universally available.
This commit is contained in:
parent
16b3a96e66
commit
0aaac728b5
|
@ -4,7 +4,7 @@ uniform usampler2D uOpaqueTex;
|
|||
uniform sampler2D uOpaqueDepth;
|
||||
uniform usampler2D uTransparentTex;
|
||||
uniform sampler2D uTransparentDepth;
|
||||
uniform usampler2DRect uPaletteTex;
|
||||
uniform usampler2D uPaletteTex;
|
||||
|
||||
in vec2 fTextureCoordinate;
|
||||
|
||||
|
@ -22,5 +22,5 @@ void main()
|
|||
transparent = 0u;
|
||||
}
|
||||
|
||||
oColour = texture(uPaletteTex, vec2(opaque, transparent)).r;
|
||||
oColour = texture(uPaletteTex, vec2(opaque, transparent) / 256.f).r;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ const int FLAG_MASK = (1 << 3);
|
|||
const int FLAG_CROSS_HATCH = (1 << 4);
|
||||
|
||||
uniform usampler2DArray uTexture;
|
||||
uniform usampler2DRect uPaletteTex;
|
||||
uniform usampler2D uPaletteTex;
|
||||
|
||||
uniform sampler2D uPeelingTex;
|
||||
uniform bool uPeeling;
|
||||
|
@ -51,15 +51,15 @@ void main()
|
|||
int paletteCount = fFlags & MASK_REMAP_COUNT;
|
||||
if (paletteCount >= 3 && texel >= 0x2Eu && texel < 0x3Au)
|
||||
{
|
||||
texel = texture(uPaletteTex, vec2(texel + 0xC5u, fPalettes.z)).r;
|
||||
texel = texture(uPaletteTex, vec2(texel + 0xC5u, fPalettes.z) / 256.0f).r;
|
||||
}
|
||||
else if (paletteCount >= 2 && texel >= 0xCAu && texel < 0xD6u)
|
||||
{
|
||||
texel = texture(uPaletteTex, vec2(texel + 0x29u, fPalettes.y)).r;
|
||||
texel = texture(uPaletteTex, vec2(texel + 0x29u, fPalettes.y) / 256.f).r;
|
||||
}
|
||||
else if (paletteCount >= 1)
|
||||
{
|
||||
texel = texture(uPaletteTex, vec2(texel, fPalettes.x)).r;
|
||||
texel = texture(uPaletteTex, vec2(texel, fPalettes.x) / 256.f).r;
|
||||
}
|
||||
|
||||
if (texel == 0u)
|
||||
|
|
|
@ -81,7 +81,7 @@ void ApplyTransparencyShader::SetTextures(
|
|||
OpenGLAPI::SetTexture(1, GL_TEXTURE_2D, opaqueDepth);
|
||||
OpenGLAPI::SetTexture(2, GL_TEXTURE_2D, transparentTex);
|
||||
OpenGLAPI::SetTexture(3, GL_TEXTURE_2D, transparentDepth);
|
||||
OpenGLAPI::SetTexture(4, GL_TEXTURE_RECTANGLE, paletteTex);
|
||||
OpenGLAPI::SetTexture(4, GL_TEXTURE_2D, paletteTex);
|
||||
}
|
||||
|
||||
void ApplyTransparencyShader::Draw()
|
||||
|
|
|
@ -963,7 +963,7 @@ void OpenGLDrawingContext::FlushRectangles()
|
|||
return;
|
||||
|
||||
OpenGLAPI::SetTexture(0, GL_TEXTURE_2D_ARRAY, _textureCache->GetAtlasesTexture());
|
||||
OpenGLAPI::SetTexture(1, GL_TEXTURE_RECTANGLE, _textureCache->GetPaletteTexture());
|
||||
OpenGLAPI::SetTexture(1, GL_TEXTURE_2D, _textureCache->GetPaletteTexture());
|
||||
|
||||
_drawRectShader->Use();
|
||||
_drawRectShader->SetInstances(_commandBuffers.rects);
|
||||
|
@ -997,7 +997,7 @@ void OpenGLDrawingContext::HandleTransparency()
|
|||
}
|
||||
|
||||
OpenGLAPI::SetTexture(0, GL_TEXTURE_2D_ARRAY, _textureCache->GetAtlasesTexture());
|
||||
OpenGLAPI::SetTexture(1, GL_TEXTURE_RECTANGLE, _textureCache->GetPaletteTexture());
|
||||
OpenGLAPI::SetTexture(1, GL_TEXTURE_2D, _textureCache->GetPaletteTexture());
|
||||
|
||||
_drawRectShader->Use();
|
||||
_drawRectShader->DrawInstances();
|
||||
|
|
|
@ -156,9 +156,9 @@ void TextureCache::CreateTextures()
|
|||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
glGenTextures(1, &_paletteTexture);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE, _paletteTexture);
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glBindTexture(GL_TEXTURE_2D, _paletteTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
GeneratePaletteTexture();
|
||||
|
||||
|
@ -193,8 +193,8 @@ void TextureCache::GeneratePaletteTexture()
|
|||
}
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE, _paletteTexture);
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_R8UI, width, height, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, dpi.bits);
|
||||
glBindTexture(GL_TEXTURE_2D, _paletteTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8UI, width, height, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, dpi.bits);
|
||||
DeleteDPI(dpi);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue