mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-26 00:40:56 +00:00
- refactoring of palette loader.
This commit is contained in:
parent
6e7db1b63a
commit
449a5a4717
6 changed files with 20 additions and 43 deletions
|
@ -79,7 +79,7 @@ extern void setup_blend(int32_t blend, int32_t doreverse);
|
||||||
extern uint8_t basepalreset;
|
extern uint8_t basepalreset;
|
||||||
extern int32_t curbrightness;
|
extern int32_t curbrightness;
|
||||||
|
|
||||||
extern int32_t paletteLoadLookupTable(buildvfs_kfd fp);
|
extern int32_t paletteLoadLookupTable(FileReader &fp);
|
||||||
extern void paletteSetupDefaultFog(void);
|
extern void paletteSetupDefaultFog(void);
|
||||||
extern void palettePostLoadLookups(void);
|
extern void palettePostLoadLookups(void);
|
||||||
extern void paletteFixTranslucencyMask(void);
|
extern void paletteFixTranslucencyMask(void);
|
||||||
|
|
|
@ -462,19 +462,19 @@ void paletteFixTranslucencyMask(void)
|
||||||
// - on success, 0
|
// - on success, 0
|
||||||
// - on error, -1 (didn't read enough data)
|
// - on error, -1 (didn't read enough data)
|
||||||
// - -2: error, we already wrote an error message ourselves
|
// - -2: error, we already wrote an error message ourselves
|
||||||
int32_t paletteLoadLookupTable(buildvfs_kfd fp)
|
int32_t paletteLoadLookupTable(FileReader &fp)
|
||||||
{
|
{
|
||||||
uint8_t numlookups;
|
uint8_t numlookups;
|
||||||
char remapbuf[256];
|
char remapbuf[256];
|
||||||
|
|
||||||
if (kread_and_test(fp, &numlookups, 1))
|
if (1 != fp.Read(&numlookups, 1))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (bssize_t j=0; j<numlookups; j++)
|
for (bssize_t j=0; j<numlookups; j++)
|
||||||
{
|
{
|
||||||
uint8_t palnum;
|
uint8_t palnum;
|
||||||
|
|
||||||
if (kread_and_test(fp, &palnum, 1))
|
if (1 != fp.Read(&palnum, 1))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (palnum >= 256-RESERVEDPALS)
|
if (palnum >= 256-RESERVEDPALS)
|
||||||
|
@ -483,7 +483,7 @@ int32_t paletteLoadLookupTable(buildvfs_kfd fp)
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kread_and_test(fp, remapbuf, 256))
|
if (256 != fp.Read(remapbuf, 256))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
paletteMakeLookupTable(palnum, remapbuf, 0, 0, 0, 0);
|
paletteMakeLookupTable(palnum, remapbuf, 0, 0, 0, 0);
|
||||||
|
|
|
@ -121,7 +121,6 @@ int32_t r_yshearing = 0;
|
||||||
|
|
||||||
// used for fogcalc
|
// used for fogcalc
|
||||||
static float fogresult, fogresult2;
|
static float fogresult, fogresult2;
|
||||||
coltypef fogcol, fogtable[MAXPALOOKUPS];
|
|
||||||
|
|
||||||
int32_t r_useindexedcolortextures = -1;
|
int32_t r_useindexedcolortextures = -1;
|
||||||
|
|
||||||
|
@ -245,14 +244,6 @@ static void calcmat(vec3f_t a0, const vec2f_t *offset, float f, float mat[16], i
|
||||||
|
|
||||||
void polymost_glreset()
|
void polymost_glreset()
|
||||||
{
|
{
|
||||||
for (bssize_t i=0; i<=MAXPALOOKUPS-1; i++)
|
|
||||||
{
|
|
||||||
fogtable[i].r = palookupfog[i].r * (1.f/255.f);
|
|
||||||
fogtable[i].g = palookupfog[i].g * (1.f/255.f);
|
|
||||||
fogtable[i].b = palookupfog[i].b * (1.f/255.f);
|
|
||||||
fogtable[i].a = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Reset if this is -1 (meaning 1st texture call ever), or > 0 (textures in memory)
|
//Reset if this is -1 (meaning 1st texture call ever), or > 0 (textures in memory)
|
||||||
if (gltexcacnum < 0)
|
if (gltexcacnum < 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1022,20 +1022,19 @@ void G_DoAutoload(const char *dirname)
|
||||||
void G_LoadLookups(void)
|
void G_LoadLookups(void)
|
||||||
{
|
{
|
||||||
int32_t j;
|
int32_t j;
|
||||||
buildvfs_kfd fp;
|
|
||||||
|
|
||||||
if ((fp=kopen4loadfrommod("lookup.dat",0)) == buildvfs_kfd_invalid)
|
auto fr = kopenFileReader("lookup.dat", 0);
|
||||||
if ((fp=kopen4loadfrommod("lookup.dat",1)) == buildvfs_kfd_invalid)
|
if (!fr.isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
j = paletteLoadLookupTable(fp);
|
j = paletteLoadLookupTable(fr);
|
||||||
|
|
||||||
if (j < 0)
|
if (j < 0)
|
||||||
{
|
{
|
||||||
if (j == -1)
|
if (j == -1)
|
||||||
initprintf("ERROR loading \"lookup.dat\": failed reading enough data.\n");
|
initprintf("ERROR loading \"lookup.dat\": failed reading enough data.\n");
|
||||||
|
|
||||||
return kclose(fp);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t paldata[768];
|
uint8_t paldata[768];
|
||||||
|
@ -1045,16 +1044,14 @@ void G_LoadLookups(void)
|
||||||
// Account for TITLE and REALMS swap between basepal number and on-disk order.
|
// Account for TITLE and REALMS swap between basepal number and on-disk order.
|
||||||
int32_t basepalnum = (j == 3 || j == 4) ? 4+3-j : j;
|
int32_t basepalnum = (j == 3 || j == 4) ? 4+3-j : j;
|
||||||
|
|
||||||
if (kread_and_test(fp, paldata, 768))
|
if (fr.Read(paldata, 768) != 768)
|
||||||
return kclose(fp);
|
return;
|
||||||
|
|
||||||
for (unsigned char & k : paldata)
|
for (unsigned char & k : paldata)
|
||||||
k <<= 2;
|
k <<= 2;
|
||||||
|
|
||||||
paletteSetColorTable(basepalnum, paldata);
|
paletteSetColorTable(basepalnum, paldata);
|
||||||
}
|
}
|
||||||
|
|
||||||
kclose(fp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
|
|
|
@ -992,20 +992,20 @@ void G_DoAutoload(const char *dirname)
|
||||||
|
|
||||||
void G_LoadLookups(void)
|
void G_LoadLookups(void)
|
||||||
{
|
{
|
||||||
int32_t fp, j;
|
int32_t j;
|
||||||
|
|
||||||
if ((fp=kopen4loadfrommod("lookup.dat",0)) == -1)
|
auto fr = kopenFileReader("lookup.dat", 0);
|
||||||
if ((fp=kopen4loadfrommod("lookup.dat",1)) == -1)
|
if (!fr.isOpen())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
j = paletteLoadLookupTable(fp);
|
j = paletteLoadLookupTable(fr);
|
||||||
|
|
||||||
if (j < 0)
|
if (j < 0)
|
||||||
{
|
{
|
||||||
if (j == -1)
|
if (j == -1)
|
||||||
initprintf("ERROR loading \"lookup.dat\": failed reading enough data.\n");
|
initprintf("ERROR loading \"lookup.dat\": failed reading enough data.\n");
|
||||||
|
|
||||||
return kclose(fp);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t paldata[768];
|
uint8_t paldata[768];
|
||||||
|
@ -1015,8 +1015,8 @@ void G_LoadLookups(void)
|
||||||
// Account for TITLE and REALMS swap between basepal number and on-disk order.
|
// Account for TITLE and REALMS swap between basepal number and on-disk order.
|
||||||
int32_t basepalnum = (j == 3 || j == 4) ? 4+3-j : j;
|
int32_t basepalnum = (j == 3 || j == 4) ? 4+3-j : j;
|
||||||
|
|
||||||
if (kread_and_test(fp, paldata, 768))
|
if (fr.Read(paldata, 768) != 768)
|
||||||
return kclose(fp);
|
return;
|
||||||
|
|
||||||
for (bssize_t k = 0; k < 768; k++)
|
for (bssize_t k = 0; k < 768; k++)
|
||||||
paldata[k] <<= 2;
|
paldata[k] <<= 2;
|
||||||
|
@ -1028,8 +1028,6 @@ void G_LoadLookups(void)
|
||||||
paldata[767] = palette[767];
|
paldata[767] = palette[767];
|
||||||
paletteSetColorTable(DRUGPAL, paldata);
|
paletteSetColorTable(DRUGPAL, paldata);
|
||||||
|
|
||||||
kclose(fp);
|
|
||||||
|
|
||||||
if (RR)
|
if (RR)
|
||||||
{
|
{
|
||||||
char table[256];
|
char table[256];
|
||||||
|
|
|
@ -28,8 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "savegame.h"
|
#include "savegame.h"
|
||||||
#include "cmdline.h"
|
#include "cmdline.h"
|
||||||
|
|
||||||
extern coltypef fogtable[MAXPALOOKUPS];
|
|
||||||
|
|
||||||
BEGIN_RR_NS
|
BEGIN_RR_NS
|
||||||
|
|
||||||
static int32_t g_whichPalForPlayer = 9;
|
static int32_t g_whichPalForPlayer = 9;
|
||||||
|
@ -2646,13 +2644,6 @@ void G_SetFog(int fogtype)
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
if (videoGetRenderMode() >= REND_POLYMOST)
|
if (videoGetRenderMode() >= REND_POLYMOST)
|
||||||
{
|
{
|
||||||
for (bssize_t i=0; i<=MAXPALOOKUPS-1; i++)
|
|
||||||
{
|
|
||||||
fogtable[i].r = palookupfog[i].r * (1.f/255.f);
|
|
||||||
fogtable[i].g = palookupfog[i].g * (1.f/255.f);
|
|
||||||
fogtable[i].b = palookupfog[i].b * (1.f/255.f);
|
|
||||||
fogtable[i].a = 0;
|
|
||||||
}
|
|
||||||
//gltexinvalidatetype(INVALIDATE_ALL_NON_INDEXED);
|
//gltexinvalidatetype(INVALIDATE_ALL_NON_INDEXED);
|
||||||
static int swaps[] = { 0, 30, 33, 23, 8 };
|
static int swaps[] = { 0, 30, 33, 23, 8 };
|
||||||
uploadpalswaps(5, swaps);
|
uploadpalswaps(5, swaps);
|
||||||
|
|
Loading…
Reference in a new issue