- fixed display of alpha textures without shaders.

As it turned out, the translation's alpha channel was clobbered by the whole setup.
This commit is contained in:
Christoph Oelckers 2016-04-26 19:11:32 +02:00
parent 7e6e2bc0a8
commit 913e3df7e3
6 changed files with 22 additions and 13 deletions

View file

@ -297,6 +297,7 @@ void FRenderState::ApplyFixedFunction()
col.vec[3] *= (mObjectColor.a / 255.f);
glColor4fv(col.vec);
glEnable(GL_BLEND);
if (mAlphaThreshold > 0)
{
glEnable(GL_ALPHA_TEST);

View file

@ -287,7 +287,7 @@ void gl_PrintStartupLog()
for (int i = 0; i < 256; i++)
{
remap->Remap[i] = i;
remap->Palette[i] = PalEntry(i, 255, 255);
remap->Palette[i] = PalEntry(i, 255, 255, 255);
}
}

View file

@ -124,13 +124,17 @@ void FGLBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int
if (translation > 0)
{
PalEntry *ptrans = GLTranslationPalette::GetPalette(translation);
if (ptrans)
if (ptrans && !alphatrans)
{
for (i = 0; i < 256; i++)
{
penew[i] = (ptrans[i] & 0xffffff) | (palette[i] & 0xff000000);
}
}
else if (ptrans)
{
memcpy(penew, ptrans, 256 * sizeof(PalEntry));
}
}
else
{

View file

@ -7,23 +7,22 @@
class FGLBitmap : public FBitmap
{
int translation;
int translation = 0;
bool alphatrans = false;
public:
FGLBitmap()
{
translation = 0;
}
FGLBitmap(BYTE *buffer, int pitch, int width, int height)
: FBitmap(buffer, pitch, width, height)
{
translation = 0;
}
void SetTranslationInfo(int _trans)
void SetTranslationInfo(int _trans, bool _alphatrans = false)
{
if (_trans != -1337) translation = _trans;
alphatrans = _alphatrans;
}
virtual void CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int srcwidth,

View file

@ -182,7 +182,7 @@ void FGLTexture::Clean(bool all)
//
//===========================================================================
unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded)
unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded, bool alphatrans)
{
unsigned char * buffer;
int W, H;
@ -190,7 +190,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F
// Textures that are already scaled in the texture lump will not get replaced
// by hires textures
if (gl_texture_usehires && hirescheck != NULL)
if (gl_texture_usehires && hirescheck != NULL && !alphatrans)
{
buffer = LoadHiresTexture (hirescheck, &w, &h);
if (buffer)
@ -209,7 +209,7 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F
memset(buffer, 0, W * (H+1) * 4);
FGLBitmap bmp(buffer, W*4, W, H);
bmp.SetTranslationInfo(translation);
bmp.SetTranslationInfo(translation, alphatrans);
if (tex->bComplex)
{
@ -275,9 +275,14 @@ FHardwareTexture *FGLTexture::CreateHwTexture()
const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int translation, FTexture *hirescheck)
{
int usebright = false;
bool alphatrans = false;
if (translation <= 0) translation = -translation;
else translation = GLTranslationPalette::GetInternalTranslation(translation);
else
{
alphatrans = (gl.glslversion == 0 && translation == TRANSLATION(TRANSLATION_Standard, 8));
translation = GLTranslationPalette::GetInternalTranslation(translation);
}
bool needmipmap = (clampmode <= CLAMP_XY) || !(gl.flags & RFL_SAMPLER_OBJECTS);
@ -303,7 +308,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla
if (!tex->bHasCanvas)
{
buffer = CreateTexBuffer(translation, w, h, hirescheck);
buffer = CreateTexBuffer(translation, w, h, hirescheck, true, alphatrans);
tex->ProcessData(buffer, w, h, false);
}
if (!hwtex->CreateTexture(buffer, w, h, texunit, needmipmap, translation))

View file

@ -77,7 +77,7 @@ public:
FGLTexture(FTexture * tx, bool expandpatches);
~FGLTexture();
unsigned char * CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded = true);
unsigned char * CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded = true, bool alphatrans = false);
void Clean(bool all);
int Dump(int i);