- removed the FGLBitmap class and replaced all uses with the regular FBitmap.

The only reason this ever existed is that the GL renderer used RGBA instead of BGRA but there's no reason why this is even necessary.
This commit is contained in:
Christoph Oelckers 2017-06-18 09:13:35 +02:00
commit a1694a79c6
12 changed files with 59 additions and 220 deletions

View file

@ -33,6 +33,7 @@
#include "sc_man.h"
#include "colormatcher.h"
#include "textures/warpbuffer.h"
#include "textures/bitmap.h"
//#include "gl/gl_intern.h"
@ -43,7 +44,6 @@
#include "gl/data/gl_data.h"
#include "gl/textures/gl_texture.h"
#include "gl/textures/gl_translate.h"
#include "gl/textures/gl_bitmap.h"
#include "gl/textures/gl_material.h"
#include "gl/textures/gl_samplers.h"
#include "gl/shaders/gl_shader.h"
@ -120,7 +120,7 @@ unsigned char *FGLTexture::LoadHiresTexture(FTexture *tex, int *width, int *heig
unsigned char * buffer=new unsigned char[w*(h+1)*4];
memset(buffer, 0, w * (h+1) * 4);
FGLBitmap bmp(buffer, w*4, w, h);
FBitmap bmp(buffer, w*4, w, h);
int trans = hirestexture->CopyTrueColorPixels(&bmp, 0, 0);
hirestexture->CheckTrans(buffer, w*h, trans);
@ -210,38 +210,58 @@ unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, F
buffer=new unsigned char[W*(H+1)*4];
memset(buffer, 0, W * (H+1) * 4);
FGLBitmap bmp(buffer, W*4, W, H);
bmp.SetTranslationInfo(translation, alphatrans);
FBitmap bmp(buffer, W*4, W, H);
if (tex->bComplex)
if (translation <= 0)
{
FBitmap imgCreate;
// The texture contains special processing so it must be composited using the
// base bitmap class and then be converted as a whole.
if (imgCreate.Create(W, H))
// Q: Is this special treatment still needed? Needs to be checked.
if (tex->bComplex)
{
memset(imgCreate.GetPixels(), 0, W * H * 4);
int trans = tex->CopyTrueColorPixels(&imgCreate, exx, exx);
bmp.CopyPixelDataRGB(0, 0, imgCreate.GetPixels(), W, H, 4, W * 4, 0, CF_BGRA);
FBitmap imgCreate;
// The texture contains special processing so it must be fully composited before being converted as a whole.
if (imgCreate.Create(W, H))
{
memset(imgCreate.GetPixels(), 0, W * H * 4);
int trans = tex->CopyTrueColorPixels(&imgCreate, exx, exx);
bmp.CopyPixelDataRGB(0, 0, imgCreate.GetPixels(), W, H, 4, W * 4, 0, CF_BGRA);
tex->CheckTrans(buffer, W*H, trans);
isTransparent = tex->gl_info.mIsTransparent;
if (bIsTransparent == -1) bIsTransparent = isTransparent;
}
}
else
{
int trans = tex->CopyTrueColorPixels(&bmp, exx, exx);
tex->CheckTrans(buffer, W*H, trans);
isTransparent = tex->gl_info.mIsTransparent;
if (bIsTransparent == -1) bIsTransparent = isTransparent;
}
}
else if (translation<=0)
{
int trans = tex->CopyTrueColorPixels(&bmp, exx, exx);
tex->CheckTrans(buffer, W*H, trans);
isTransparent = tex->gl_info.mIsTransparent;
if (bIsTransparent == -1) bIsTransparent = isTransparent;
}
else
{
// When using translations everything must be mapped to the base palette.
// Since FTexture's method is doing exactly that by calling GetPixels let's use that here
// to do all the dirty work for us. ;)
tex->FTexture::CopyTrueColorPixels(&bmp, exx, exx);
// so use CopyTrueColorTranslated
PalEntry penew[256];
PalEntry *pal;
// Todo: Give all palettes proper alpha and make sure the software renderer can handle it.
PalEntry *ptrans = GLTranslationPalette::GetPalette(translation);
if (ptrans && !alphatrans)
{
for (int i = 1; i < 256; i++)
{
penew[i] = (ptrans[i] | 0xff000000);
}
penew[0] = 0;
pal = penew;
}
else if (ptrans)
{
pal = ptrans;
}
tex->CopyTrueColorTranslated(&bmp, exx, exx, 0, pal);
isTransparent = 0;
// This is not conclusive for setting the texture's transparency info.
}