Fixing Paletted rendering for GLES

This commit is contained in:
Emile Belanger 2021-07-18 11:06:29 +01:00
parent fa092f9ec9
commit c1eee54511
2 changed files with 23 additions and 0 deletions

View file

@ -138,7 +138,23 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
#else #else
sourcetype = GL_BGRA; sourcetype = GL_BGRA;
texformat = GL_RGBA; texformat = GL_RGBA;
if (glTextureBytes > 0)
{
if (glTextureBytes < 4) glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
static const int ITypes[] = { GL_R8, GL_RG8, GL_RGB8, GL_RGBA8 };
static const int STypes[] = { GL_RED, GL_RG, GL_BGR, GL_BGRA };
texformat = ITypes[glTextureBytes - 1];
sourcetype = STypes[glTextureBytes - 1];
}
else
{
sourcetype = GL_BGRA;
}
#endif #endif
glTexImage2D(GL_TEXTURE_2D, 0, texformat, rw, rh, 0, sourcetype, GL_UNSIGNED_BYTE, buffer); glTexImage2D(GL_TEXTURE_2D, 0, texformat, rw, rh, 0, sourcetype, GL_UNSIGNED_BYTE, buffer);
if (deletebuffer && buffer) free(buffer); if (deletebuffer && buffer) free(buffer);

View file

@ -35,6 +35,9 @@
#include "gles_renderbuffers.h" #include "gles_renderbuffers.h"
#include "gles_hwtexture.h" #include "gles_hwtexture.h"
#include "gles_buffers.h" #include "gles_buffers.h"
#include "gles_framebuffer.h"
#include "gles_renderer.h"
#include "gles_samplers.h"
#include "hw_clock.h" #include "hw_clock.h"
#include "printf.h" #include "printf.h"
@ -454,6 +457,7 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
MaterialLayerInfo* layer; MaterialLayerInfo* layer;
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0, translation, &layer)); auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0, translation, &layer));
if (base->BindOrCreate(tex->GetTexture(), 0, clampmode, translation, layer->scaleFlags)) if (base->BindOrCreate(tex->GetTexture(), 0, clampmode, translation, layer->scaleFlags))
{ {
if (!(layer->scaleFlags & CTF_Indexed)) if (!(layer->scaleFlags & CTF_Indexed))
@ -472,6 +476,9 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
{ {
auto systex = static_cast<FHardwareTexture*>(mat->GetLayer(i, translation, &layer)); auto systex = static_cast<FHardwareTexture*>(mat->GetLayer(i, translation, &layer));
systex->Bind(i, false); systex->Bind(i, false);
//if (clampmode <= CLAMP_XY) clampmode += CLAMP_NOFILTER - CLAMP_NONE;
clampmode += CLAMP_NOFILTER - CLAMP_NONE;
GLRenderer->mSamplerManager->Bind(i, clampmode, 255);
maxbound = i; maxbound = i;
} }
} }