0
0
Fork 0
mirror of https://github.com/ZDoom/raze-gles.git synced 2025-03-04 16:01:29 +00:00

- added lookup for brightmap palettes.

This commit is contained in:
Christoph Oelckers 2019-10-18 12:11:53 +02:00
parent 530a9944f7
commit 542994cc20
2 changed files with 29 additions and 5 deletions
source

View file

@ -214,7 +214,6 @@ bool GLInstance::SetTexture(FTexture* tex, int palette, int method, int samplero
}
else if (TextureType == TT_TRUECOLOR)
{
// Todo: brightmaps for true color tiles
lookuppal = palmanager.LookupPalette(usepalette, usepalswap, true);
if (lookuppal >= 0)
{

View file

@ -261,18 +261,43 @@ int PaletteManager::LookupPalette(int palette, int palswap, bool brightmap)
{
int realpal = palettemap[palette];
int realswap = palswapmap[palswap];
int combined = realpal * 0x10000 + realswap;
int combined = (brightmap? 0x1000000 : 0) + realpal * 0x10000 + realswap;
int* combinedindex = swappedpalmap.CheckKey(combined);
if (combinedindex) return *combinedindex;
PaletteData* paldata = &palettes[realpal];
PalswapData* swapdata = &palswaps[realswap];
PalEntry swappedpalette[256];
for (int i = 0; i < 256; i++)
if (!brightmap)
{
int swapi = swapdata->lookup[i];
swappedpalette[i] = paldata->colors[swapi];
for (int i = 0; i < 255; i++)
{
int swapi = swapdata->lookup[i];
swappedpalette[i] = paldata->colors[swapi];
swappedpalette[i].a = 255;
}
}
else
{
bool found = false;
memset(swappedpalette, 0, sizeof(swappedpalette));
for (int i = 0; i < 255; i++)
{
int swapi = swapdata->lookup[i];
auto swapc = paldata->colors[swapi];
if (swapc.a)
{
found = true;
swappedpalette[i] = 0xffffffff;
}
}
if (!found)
{
swappedpalmap.Insert(combined, -1);
return -1;
}
}
swappedpalette[255] = 0;
int palid = FindPalette((uint8_t*)swappedpalette);
swappedpalmap.Insert(combined, palid);
return palid;