mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +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 MAXXDIM 3072
|
||||
#define MAXYDIM 2304
|
||||
#define MAXBASEPALS 8
|
||||
#define MAXPALOOKUPS 256
|
||||
#define MAXPSKYTILES 256
|
||||
#define MAXSPRITESONSCREEN 4096
|
||||
|
|
|
@ -294,7 +294,7 @@ int16_t polymer_addlight(_prlight* light);
|
|||
void polymer_deletelight(int16_t lighti);
|
||||
void polymer_invalidatelights(void);
|
||||
void polymer_texinvalidate(void);
|
||||
void polymer_definehighpalookup(char palnum, char *fn);
|
||||
void polymer_definehighpalookup(char basepalnum, char palnum, char *fn);
|
||||
|
||||
# ifdef POLYMER_C
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "build.h"
|
||||
#include "compat.h"
|
||||
#include "engine_priv.h"
|
||||
#include "baselayer.h"
|
||||
#include "scriptfile.h"
|
||||
#include "cache1d.h"
|
||||
|
@ -46,6 +47,7 @@ enum scripttoken_t
|
|||
T_FPS,
|
||||
T_FLAGS,
|
||||
T_PAL,
|
||||
T_BASEPAL,
|
||||
T_DETAIL,
|
||||
T_GLOW,
|
||||
T_SPECULAR,
|
||||
|
@ -1432,7 +1434,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
case T_HIGHPALOOKUP:
|
||||
{
|
||||
char *highpaltokptr = script->ltextptr;
|
||||
int32_t pal=-1, oldpathsearchmode;
|
||||
int32_t basepal=-1, pal=-1, oldpathsearchmode;
|
||||
char *fn = NULL, *tfn = NULL;
|
||||
char *highpalend;
|
||||
#ifdef POLYMER
|
||||
|
@ -1441,6 +1443,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
#endif
|
||||
static const tokenlist highpaltokens[] =
|
||||
{
|
||||
{ "basepal", T_BASEPAL },
|
||||
{ "pal", T_PAL },
|
||||
{ "file", T_FILE }
|
||||
};
|
||||
|
@ -1450,12 +1453,20 @@ static int32_t defsparser(scriptfile *script)
|
|||
{
|
||||
switch (getatoken(script,highpaltokens,sizeof(highpaltokens)/sizeof(tokenlist)))
|
||||
{
|
||||
case T_BASEPAL:
|
||||
scriptfile_getsymbol(script,&basepal); break;
|
||||
case T_PAL:
|
||||
scriptfile_getsymbol(script,&pal); break;
|
||||
case T_FILE:
|
||||
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))
|
||||
{
|
||||
|
@ -1463,6 +1474,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
"line %s:%d\n", script->filename, scriptfile_getlinum(script,highpaltokptr));
|
||||
break;
|
||||
}
|
||||
|
||||
if (!fn)
|
||||
{
|
||||
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; }
|
||||
}
|
||||
|
||||
polymer_definehighpalookup(pal, highpaldata);
|
||||
polymer_definehighpalookup(basepal, pal, highpaldata);
|
||||
|
||||
Bfree(highpaldata);
|
||||
#endif
|
||||
|
|
|
@ -11129,6 +11129,9 @@ void setvgapalette(void)
|
|||
//
|
||||
void setbasepaltable(uint8_t **thebasepaltable, uint8_t thebasepalcount)
|
||||
{
|
||||
if (thebasepalcount >= MAXBASEPALS)
|
||||
thebasepalcount = MAXBASEPALS - 1;
|
||||
|
||||
basepaltableptr = thebasepaltable;
|
||||
basepalcount = thebasepalcount;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ _prsector *prsectors[MAXSECTORS];
|
|||
_prwall *prwalls[MAXWALLS];
|
||||
_prsprite *prsprites[MAXSPRITES];
|
||||
_prmaterial mdspritematerial;
|
||||
_prhighpalookup prhighpalookups[MAXPALOOKUPS];
|
||||
_prhighpalookup prhighpalookups[MAXBASEPALS][MAXPALOOKUPS];
|
||||
|
||||
static const GLfloat vertsprite[4 * 5] =
|
||||
{
|
||||
|
@ -614,7 +614,7 @@ int32_t polymersearching;
|
|||
// EXTERNAL FUNCTIONS
|
||||
int32_t polymer_init(void)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t i, j;
|
||||
|
||||
if (pr_verbosity >= 1) OSD_Printf("Initializing Polymer subsystem...\n");
|
||||
|
||||
|
@ -676,28 +676,33 @@ int32_t polymer_init(void)
|
|||
|
||||
// Prime highpalookup maps
|
||||
i = 0;
|
||||
while (i < MAXPALOOKUPS)
|
||||
while (i < MAXBASEPALS)
|
||||
{
|
||||
if (prhighpalookups[i].data)
|
||||
j = 0;
|
||||
while (j < MAXPALOOKUPS)
|
||||
{
|
||||
bglGenTextures(1, &prhighpalookups[i].map);
|
||||
bglBindTexture(GL_TEXTURE_3D, prhighpalookups[i].map);
|
||||
bglTexImage3D(GL_TEXTURE_3D, // target
|
||||
0, // mip level
|
||||
GL_RGBA, // internalFormat
|
||||
PR_HIGHPALOOKUP_DIM, // width
|
||||
PR_HIGHPALOOKUP_DIM, // height
|
||||
PR_HIGHPALOOKUP_DIM, // depth
|
||||
0, // border
|
||||
GL_BGRA, // upload format
|
||||
GL_UNSIGNED_BYTE, // upload component type
|
||||
prhighpalookups[i].data); // data pointer
|
||||
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
|
||||
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);
|
||||
if (prhighpalookups[i][j].data)
|
||||
{
|
||||
bglGenTextures(1, &prhighpalookups[i][j].map);
|
||||
bglBindTexture(GL_TEXTURE_3D, prhighpalookups[i][j].map);
|
||||
bglTexImage3D(GL_TEXTURE_3D, // target
|
||||
0, // mip level
|
||||
GL_RGBA, // internalFormat
|
||||
PR_HIGHPALOOKUP_DIM, // width
|
||||
PR_HIGHPALOOKUP_DIM, // height
|
||||
PR_HIGHPALOOKUP_DIM, // depth
|
||||
0, // border
|
||||
GL_BGRA, // upload format
|
||||
GL_UNSIGNED_BYTE, // upload component type
|
||||
prhighpalookups[i][j].data); // data pointer
|
||||
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
bglTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, glinfo.clamptoedge?GL_CLAMP_TO_EDGE:GL_CLAMP);
|
||||
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++;
|
||||
}
|
||||
|
@ -709,21 +714,26 @@ int32_t polymer_init(void)
|
|||
|
||||
void polymer_uninit(void)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t i, j;
|
||||
|
||||
polymer_freeboard();
|
||||
|
||||
i = 0;
|
||||
while (i < MAXPALOOKUPS)
|
||||
while (i < MAXBASEPALS)
|
||||
{
|
||||
if (prhighpalookups[i].data) {
|
||||
Bfree(prhighpalookups[i].data);
|
||||
prhighpalookups[i].data = NULL;
|
||||
}
|
||||
if (prhighpalookups[i].map) {
|
||||
bglDeleteTextures(1, &prhighpalookups[i].map);
|
||||
prhighpalookups[i].map = 0;
|
||||
}
|
||||
j = 0;
|
||||
while (j < MAXPALOOKUPS)
|
||||
{
|
||||
if (prhighpalookups[i][j].data) {
|
||||
Bfree(prhighpalookups[i][j].data);
|
||||
prhighpalookups[i][j].data = NULL;
|
||||
}
|
||||
if (prhighpalookups[i][j].map) {
|
||||
bglDeleteTextures(1, &prhighpalookups[i][j].map);
|
||||
prhighpalookups[i][j].map = 0;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -1661,11 +1671,11 @@ void polymer_texinvalidate(void)
|
|||
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
|
||||
|
@ -3825,8 +3835,8 @@ static void polymer_drawmdsprite(spritetype *tspr)
|
|||
color[0] = color[1] = color[2] =
|
||||
((float)(numpalookups-min(max((tspr->shade * shadescale)+m->shadeoff,0),numpalookups)))/((float)numpalookups) * 0xFF;
|
||||
|
||||
usinghighpal = (tspr->pal > 0 && pr_highpalookups &&
|
||||
prhighpalookups[tspr->pal].map);
|
||||
usinghighpal = (pr_highpalookups &&
|
||||
prhighpalookups[curbasepal][tspr->pal].map);
|
||||
|
||||
// If that palette has a highpalookup, we'll never use tinting. We might use
|
||||
// alternate skins if they exist later, though.
|
||||
|
@ -3842,9 +3852,10 @@ static void polymer_drawmdsprite(spritetype *tspr)
|
|||
}
|
||||
|
||||
// fullscreen tint on global palette change
|
||||
if (hictinting[MAXPALOOKUPS-1].r != 255 ||
|
||||
hictinting[MAXPALOOKUPS-1].g != 255 ||
|
||||
hictinting[MAXPALOOKUPS-1].b != 255)
|
||||
if (!usinghighpal &&
|
||||
(hictinting[MAXPALOOKUPS-1].r != 255 ||
|
||||
hictinting[MAXPALOOKUPS-1].g != 255 ||
|
||||
hictinting[MAXPALOOKUPS-1].b != 255))
|
||||
{
|
||||
color[0] *= hictinting[MAXPALOOKUPS-1].r / 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
|
||||
// Use the base skin instead and plug in our highpalookup map
|
||||
targetpal = 0;
|
||||
mdspritematerial.highpalookupmap = prhighpalookups[tspr->pal].map;
|
||||
mdspritematerial.highpalookupmap = prhighpalookups[curbasepal][tspr->pal].map;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
pthtyp* pth;
|
||||
int32_t usinghighpal = 0;
|
||||
|
||||
polymer_getscratchmaterial(material);
|
||||
|
||||
|
@ -4168,11 +4180,12 @@ static void polymer_getbuildmaterial(_prmaterial* material, int16_t tile
|
|||
loadtile(tilenum);
|
||||
|
||||
// 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))
|
||||
{
|
||||
material->highpalookupmap = prhighpalookups[pal].map;
|
||||
material->highpalookupmap = prhighpalookups[curbasepal][pal].map;
|
||||
pal = 0;
|
||||
usinghighpal = 1;
|
||||
}
|
||||
|
||||
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
|
||||
// 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[1] *= hictinting[MAXPALOOKUPS-1].g / 255.0;
|
||||
|
|
|
@ -227,6 +227,7 @@ extern palette_t DefaultCrosshairColors;
|
|||
|
||||
extern uint32_t g_frameDelay;
|
||||
|
||||
// Watch out for MAXBASEPALS in the engine before increasing this
|
||||
#define BASEPALCOUNT 7
|
||||
|
||||
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