mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-13 07:58:04 +00:00
Hook basepal up to highpal.
git-svn-id: https://svn.eduke32.com/eduke32@1782 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
b6dce8a559
commit
87b71fd3da
6 changed files with 77 additions and 47 deletions
|
@ -35,6 +35,7 @@ extern "C" {
|
||||||
#define MAXPLAYERS 16
|
#define MAXPLAYERS 16
|
||||||
#define MAXXDIM 3072
|
#define MAXXDIM 3072
|
||||||
#define MAXYDIM 2304
|
#define MAXYDIM 2304
|
||||||
|
#define MAXBASEPALS 8
|
||||||
#define MAXPALOOKUPS 256
|
#define MAXPALOOKUPS 256
|
||||||
#define MAXPSKYTILES 256
|
#define MAXPSKYTILES 256
|
||||||
#define MAXSPRITESONSCREEN 4096
|
#define MAXSPRITESONSCREEN 4096
|
||||||
|
|
|
@ -294,7 +294,7 @@ int16_t polymer_addlight(_prlight* light);
|
||||||
void polymer_deletelight(int16_t lighti);
|
void polymer_deletelight(int16_t lighti);
|
||||||
void polymer_invalidatelights(void);
|
void polymer_invalidatelights(void);
|
||||||
void polymer_texinvalidate(void);
|
void polymer_texinvalidate(void);
|
||||||
void polymer_definehighpalookup(char palnum, char *fn);
|
void polymer_definehighpalookup(char basepalnum, char palnum, char *fn);
|
||||||
|
|
||||||
# ifdef POLYMER_C
|
# ifdef POLYMER_C
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
#include "engine_priv.h"
|
||||||
#include "baselayer.h"
|
#include "baselayer.h"
|
||||||
#include "scriptfile.h"
|
#include "scriptfile.h"
|
||||||
#include "cache1d.h"
|
#include "cache1d.h"
|
||||||
|
@ -46,6 +47,7 @@ enum scripttoken_t
|
||||||
T_FPS,
|
T_FPS,
|
||||||
T_FLAGS,
|
T_FLAGS,
|
||||||
T_PAL,
|
T_PAL,
|
||||||
|
T_BASEPAL,
|
||||||
T_DETAIL,
|
T_DETAIL,
|
||||||
T_GLOW,
|
T_GLOW,
|
||||||
T_SPECULAR,
|
T_SPECULAR,
|
||||||
|
@ -1432,7 +1434,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
case T_HIGHPALOOKUP:
|
case T_HIGHPALOOKUP:
|
||||||
{
|
{
|
||||||
char *highpaltokptr = script->ltextptr;
|
char *highpaltokptr = script->ltextptr;
|
||||||
int32_t pal=-1, oldpathsearchmode;
|
int32_t basepal=-1, pal=-1, oldpathsearchmode;
|
||||||
char *fn = NULL, *tfn = NULL;
|
char *fn = NULL, *tfn = NULL;
|
||||||
char *highpalend;
|
char *highpalend;
|
||||||
#ifdef POLYMER
|
#ifdef POLYMER
|
||||||
|
@ -1441,6 +1443,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
#endif
|
#endif
|
||||||
static const tokenlist highpaltokens[] =
|
static const tokenlist highpaltokens[] =
|
||||||
{
|
{
|
||||||
|
{ "basepal", T_BASEPAL },
|
||||||
{ "pal", T_PAL },
|
{ "pal", T_PAL },
|
||||||
{ "file", T_FILE }
|
{ "file", T_FILE }
|
||||||
};
|
};
|
||||||
|
@ -1450,12 +1453,20 @@ static int32_t defsparser(scriptfile *script)
|
||||||
{
|
{
|
||||||
switch (getatoken(script,highpaltokens,sizeof(highpaltokens)/sizeof(tokenlist)))
|
switch (getatoken(script,highpaltokens,sizeof(highpaltokens)/sizeof(tokenlist)))
|
||||||
{
|
{
|
||||||
|
case T_BASEPAL:
|
||||||
|
scriptfile_getsymbol(script,&basepal); break;
|
||||||
case T_PAL:
|
case T_PAL:
|
||||||
scriptfile_getsymbol(script,&pal); break;
|
scriptfile_getsymbol(script,&pal); break;
|
||||||
case T_FILE:
|
case T_FILE:
|
||||||
scriptfile_getstring(script,&fn); break;
|
scriptfile_getstring(script,&fn); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((unsigned)basepal >= ((unsigned)basepalcount))
|
||||||
|
{
|
||||||
|
initprintf("Error: missing or invalid 'base palette number' for highpalookup definition "
|
||||||
|
"near line %s:%d\n", script->filename, scriptfile_getlinum(script,highpaltokptr));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if ((unsigned)pal >= ((unsigned)MAXPALOOKUPS - RESERVEDPALS))
|
if ((unsigned)pal >= ((unsigned)MAXPALOOKUPS - RESERVEDPALS))
|
||||||
{
|
{
|
||||||
|
@ -1463,6 +1474,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
"line %s:%d\n", script->filename, scriptfile_getlinum(script,highpaltokptr));
|
"line %s:%d\n", script->filename, scriptfile_getlinum(script,highpaltokptr));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fn)
|
if (!fn)
|
||||||
{
|
{
|
||||||
initprintf("Error: missing 'file name' for highpalookup definition near line %s:%d\n",
|
initprintf("Error: missing 'file name' for highpalookup definition near line %s:%d\n",
|
||||||
|
@ -1524,7 +1536,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
{ Bfree(highpaldata); initprintf("Error: failed rendering '%s'.\n", fn); break; }
|
{ Bfree(highpaldata); initprintf("Error: failed rendering '%s'.\n", fn); break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
polymer_definehighpalookup(pal, highpaldata);
|
polymer_definehighpalookup(basepal, pal, highpaldata);
|
||||||
|
|
||||||
Bfree(highpaldata);
|
Bfree(highpaldata);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11129,6 +11129,9 @@ void setvgapalette(void)
|
||||||
//
|
//
|
||||||
void setbasepaltable(uint8_t **thebasepaltable, uint8_t thebasepalcount)
|
void setbasepaltable(uint8_t **thebasepaltable, uint8_t thebasepalcount)
|
||||||
{
|
{
|
||||||
|
if (thebasepalcount >= MAXBASEPALS)
|
||||||
|
thebasepalcount = MAXBASEPALS - 1;
|
||||||
|
|
||||||
basepaltableptr = thebasepaltable;
|
basepaltableptr = thebasepaltable;
|
||||||
basepalcount = thebasepalcount;
|
basepalcount = thebasepalcount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ _prsector *prsectors[MAXSECTORS];
|
||||||
_prwall *prwalls[MAXWALLS];
|
_prwall *prwalls[MAXWALLS];
|
||||||
_prsprite *prsprites[MAXSPRITES];
|
_prsprite *prsprites[MAXSPRITES];
|
||||||
_prmaterial mdspritematerial;
|
_prmaterial mdspritematerial;
|
||||||
_prhighpalookup prhighpalookups[MAXPALOOKUPS];
|
_prhighpalookup prhighpalookups[MAXBASEPALS][MAXPALOOKUPS];
|
||||||
|
|
||||||
static const GLfloat vertsprite[4 * 5] =
|
static const GLfloat vertsprite[4 * 5] =
|
||||||
{
|
{
|
||||||
|
@ -614,7 +614,7 @@ int32_t polymersearching;
|
||||||
// EXTERNAL FUNCTIONS
|
// EXTERNAL FUNCTIONS
|
||||||
int32_t polymer_init(void)
|
int32_t polymer_init(void)
|
||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i, j;
|
||||||
|
|
||||||
if (pr_verbosity >= 1) OSD_Printf("Initializing Polymer subsystem...\n");
|
if (pr_verbosity >= 1) OSD_Printf("Initializing Polymer subsystem...\n");
|
||||||
|
|
||||||
|
@ -676,28 +676,33 @@ int32_t polymer_init(void)
|
||||||
|
|
||||||
// Prime highpalookup maps
|
// Prime highpalookup maps
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < MAXPALOOKUPS)
|
while (i < MAXBASEPALS)
|
||||||
{
|
{
|
||||||
if (prhighpalookups[i].data)
|
j = 0;
|
||||||
|
while (j < MAXPALOOKUPS)
|
||||||
{
|
{
|
||||||
bglGenTextures(1, &prhighpalookups[i].map);
|
if (prhighpalookups[i][j].data)
|
||||||
bglBindTexture(GL_TEXTURE_3D, prhighpalookups[i].map);
|
{
|
||||||
bglTexImage3D(GL_TEXTURE_3D, // target
|
bglGenTextures(1, &prhighpalookups[i][j].map);
|
||||||
0, // mip level
|
bglBindTexture(GL_TEXTURE_3D, prhighpalookups[i][j].map);
|
||||||
GL_RGBA, // internalFormat
|
bglTexImage3D(GL_TEXTURE_3D, // target
|
||||||
PR_HIGHPALOOKUP_DIM, // width
|
0, // mip level
|
||||||
PR_HIGHPALOOKUP_DIM, // height
|
GL_RGBA, // internalFormat
|
||||||
PR_HIGHPALOOKUP_DIM, // depth
|
PR_HIGHPALOOKUP_DIM, // width
|
||||||
0, // border
|
PR_HIGHPALOOKUP_DIM, // height
|
||||||
GL_BGRA, // upload format
|
PR_HIGHPALOOKUP_DIM, // depth
|
||||||
GL_UNSIGNED_BYTE, // upload component type
|
0, // border
|
||||||
prhighpalookups[i].data); // data pointer
|
GL_BGRA, // upload format
|
||||||
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
GL_UNSIGNED_BYTE, // upload component type
|
||||||
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
prhighpalookups[i][j].data); // data pointer
|
||||||
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
|
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
|
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
|
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
|
||||||
bglBindTexture(GL_TEXTURE_3D, 0);
|
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
|
||||||
|
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
|
||||||
|
bglBindTexture(GL_TEXTURE_3D, 0);
|
||||||
|
}
|
||||||
|
j++;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -709,21 +714,26 @@ int32_t polymer_init(void)
|
||||||
|
|
||||||
void polymer_uninit(void)
|
void polymer_uninit(void)
|
||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i, j;
|
||||||
|
|
||||||
polymer_freeboard();
|
polymer_freeboard();
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < MAXPALOOKUPS)
|
while (i < MAXBASEPALS)
|
||||||
{
|
{
|
||||||
if (prhighpalookups[i].data) {
|
j = 0;
|
||||||
Bfree(prhighpalookups[i].data);
|
while (j < MAXPALOOKUPS)
|
||||||
prhighpalookups[i].data = NULL;
|
{
|
||||||
}
|
if (prhighpalookups[i][j].data) {
|
||||||
if (prhighpalookups[i].map) {
|
Bfree(prhighpalookups[i][j].data);
|
||||||
bglDeleteTextures(1, &prhighpalookups[i].map);
|
prhighpalookups[i][j].data = NULL;
|
||||||
prhighpalookups[i].map = 0;
|
}
|
||||||
}
|
if (prhighpalookups[i][j].map) {
|
||||||
|
bglDeleteTextures(1, &prhighpalookups[i][j].map);
|
||||||
|
prhighpalookups[i][j].map = 0;
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1661,11 +1671,11 @@ void polymer_texinvalidate(void)
|
||||||
while (i >= 0);
|
while (i >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void polymer_definehighpalookup(char palnum, char *data)
|
void polymer_definehighpalookup(char basepalnum, char palnum, char *data)
|
||||||
{
|
{
|
||||||
prhighpalookups[palnum].data = Bmalloc(PR_HIGHPALOOKUP_DATA_SIZE);
|
prhighpalookups[basepalnum][palnum].data = Bmalloc(PR_HIGHPALOOKUP_DATA_SIZE);
|
||||||
|
|
||||||
Bmemcpy(prhighpalookups[palnum].data, data, PR_HIGHPALOOKUP_DATA_SIZE);
|
Bmemcpy(prhighpalookups[basepalnum][palnum].data, data, PR_HIGHPALOOKUP_DATA_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CORE
|
// CORE
|
||||||
|
@ -3825,8 +3835,8 @@ static void polymer_drawmdsprite(spritetype *tspr)
|
||||||
color[0] = color[1] = color[2] =
|
color[0] = color[1] = color[2] =
|
||||||
((float)(numpalookups-min(max((tspr->shade * shadescale)+m->shadeoff,0),numpalookups)))/((float)numpalookups) * 0xFF;
|
((float)(numpalookups-min(max((tspr->shade * shadescale)+m->shadeoff,0),numpalookups)))/((float)numpalookups) * 0xFF;
|
||||||
|
|
||||||
usinghighpal = (tspr->pal > 0 && pr_highpalookups &&
|
usinghighpal = (pr_highpalookups &&
|
||||||
prhighpalookups[tspr->pal].map);
|
prhighpalookups[curbasepal][tspr->pal].map);
|
||||||
|
|
||||||
// If that palette has a highpalookup, we'll never use tinting. We might use
|
// If that palette has a highpalookup, we'll never use tinting. We might use
|
||||||
// alternate skins if they exist later, though.
|
// alternate skins if they exist later, though.
|
||||||
|
@ -3842,9 +3852,10 @@ static void polymer_drawmdsprite(spritetype *tspr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fullscreen tint on global palette change
|
// fullscreen tint on global palette change
|
||||||
if (hictinting[MAXPALOOKUPS-1].r != 255 ||
|
if (!usinghighpal &&
|
||||||
hictinting[MAXPALOOKUPS-1].g != 255 ||
|
(hictinting[MAXPALOOKUPS-1].r != 255 ||
|
||||||
hictinting[MAXPALOOKUPS-1].b != 255)
|
hictinting[MAXPALOOKUPS-1].g != 255 ||
|
||||||
|
hictinting[MAXPALOOKUPS-1].b != 255))
|
||||||
{
|
{
|
||||||
color[0] *= hictinting[MAXPALOOKUPS-1].r / 255.0;
|
color[0] *= hictinting[MAXPALOOKUPS-1].r / 255.0;
|
||||||
color[1] *= hictinting[MAXPALOOKUPS-1].g / 255.0;
|
color[1] *= hictinting[MAXPALOOKUPS-1].g / 255.0;
|
||||||
|
@ -3981,7 +3992,7 @@ static void polymer_drawmdsprite(spritetype *tspr)
|
||||||
// We don't have a specific skin defined for this palette
|
// We don't have a specific skin defined for this palette
|
||||||
// Use the base skin instead and plug in our highpalookup map
|
// Use the base skin instead and plug in our highpalookup map
|
||||||
targetpal = 0;
|
targetpal = 0;
|
||||||
mdspritematerial.highpalookupmap = prhighpalookups[tspr->pal].map;
|
mdspritematerial.highpalookupmap = prhighpalookups[curbasepal][tspr->pal].map;
|
||||||
}
|
}
|
||||||
|
|
||||||
mdspritematerial.diffusemap =
|
mdspritematerial.diffusemap =
|
||||||
|
@ -4160,6 +4171,7 @@ static void polymer_getscratchmaterial(_prmaterial* material)
|
||||||
static void polymer_getbuildmaterial(_prmaterial* material, int16_t tilenum, char pal, int8_t shade, int32_t cmeth)
|
static void polymer_getbuildmaterial(_prmaterial* material, int16_t tilenum, char pal, int8_t shade, int32_t cmeth)
|
||||||
{
|
{
|
||||||
pthtyp* pth;
|
pthtyp* pth;
|
||||||
|
int32_t usinghighpal = 0;
|
||||||
|
|
||||||
polymer_getscratchmaterial(material);
|
polymer_getscratchmaterial(material);
|
||||||
|
|
||||||
|
@ -4168,11 +4180,12 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
|
||||||
loadtile(tilenum);
|
loadtile(tilenum);
|
||||||
|
|
||||||
// PR_BIT_HIGHPALOOKUP_MAP
|
// PR_BIT_HIGHPALOOKUP_MAP
|
||||||
if (pal > 0 && pr_highpalookups && prhighpalookups[pal].map &&
|
if (pr_highpalookups && prhighpalookups[curbasepal][pal].map &&
|
||||||
hicfindsubst(tilenum, 0, 0) && (hicfindsubst(tilenum, pal, 0)->palnum != pal))
|
hicfindsubst(tilenum, 0, 0) && (hicfindsubst(tilenum, pal, 0)->palnum != pal))
|
||||||
{
|
{
|
||||||
material->highpalookupmap = prhighpalookups[pal].map;
|
material->highpalookupmap = prhighpalookups[curbasepal][pal].map;
|
||||||
pal = 0;
|
pal = 0;
|
||||||
|
usinghighpal = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pth = gltexcache(tilenum, pal, cmeth)))
|
if ((pth = gltexcache(tilenum, pal, cmeth)))
|
||||||
|
@ -4207,7 +4220,7 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
|
||||||
|
|
||||||
// fullscreen tint on global palette change... this is used for nightvision and underwater tinting
|
// fullscreen tint on global palette change... this is used for nightvision and underwater tinting
|
||||||
// if ((hictinting[MAXPALOOKUPS-1].r + hictinting[MAXPALOOKUPS-1].g + hictinting[MAXPALOOKUPS-1].b) != 0x2FD)
|
// if ((hictinting[MAXPALOOKUPS-1].r + hictinting[MAXPALOOKUPS-1].g + hictinting[MAXPALOOKUPS-1].b) != 0x2FD)
|
||||||
if (((uint32_t)hictinting[MAXPALOOKUPS-1].r & 0xFFFFFF00) != 0xFFFFFF00)
|
if (!usinghighpal && ((uint32_t)hictinting[MAXPALOOKUPS-1].r & 0xFFFFFF00) != 0xFFFFFF00)
|
||||||
{
|
{
|
||||||
material->diffusemodulation[0] *= hictinting[MAXPALOOKUPS-1].r / 255.0;
|
material->diffusemodulation[0] *= hictinting[MAXPALOOKUPS-1].r / 255.0;
|
||||||
material->diffusemodulation[1] *= hictinting[MAXPALOOKUPS-1].g / 255.0;
|
material->diffusemodulation[1] *= hictinting[MAXPALOOKUPS-1].g / 255.0;
|
||||||
|
|
|
@ -227,6 +227,7 @@ extern palette_t DefaultCrosshairColors;
|
||||||
|
|
||||||
extern uint32_t g_frameDelay;
|
extern uint32_t g_frameDelay;
|
||||||
|
|
||||||
|
// Watch out for MAXBASEPALS in the engine before increasing this
|
||||||
#define BASEPALCOUNT 7
|
#define BASEPALCOUNT 7
|
||||||
|
|
||||||
extern uint8_t water_pal[768],slime_pal[768],title_pal[768],dre_alms[768],ending_pal[768],*anim_pal;
|
extern uint8_t water_pal[768],slime_pal[768],title_pal[768],dre_alms[768],ending_pal[768],*anim_pal;
|
||||||
|
|
Loading…
Reference in a new issue