mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-02-02 20:01:23 +00:00
You'll Cowards Don't Even Indent
git-svn-id: https://svn.eduke32.com/eduke32@5712 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
73459ede47
commit
b40f9b5b80
2 changed files with 139 additions and 132 deletions
|
@ -162,7 +162,14 @@ enum {
|
||||||
DAMETH_ONEBITALPHA = 131072,
|
DAMETH_ONEBITALPHA = 131072,
|
||||||
DAMETH_ARTIMMUNITY = 262144,
|
DAMETH_ARTIMMUNITY = 262144,
|
||||||
|
|
||||||
DAMETH_UPLOADTEXTURE_MASK = DAMETH_HI|DAMETH_NODOWNSIZE|DAMETH_NOFIX|DAMETH_NOTEXCOMPRESS|DAMETH_HASALPHA|DAMETH_ONEBITALPHA|DAMETH_ARTIMMUNITY,
|
DAMETH_UPLOADTEXTURE_MASK =
|
||||||
|
DAMETH_HI |
|
||||||
|
DAMETH_NODOWNSIZE |
|
||||||
|
DAMETH_NOFIX |
|
||||||
|
DAMETH_NOTEXCOMPRESS |
|
||||||
|
DAMETH_HASALPHA |
|
||||||
|
DAMETH_ONEBITALPHA |
|
||||||
|
DAMETH_ARTIMMUNITY,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DAMETH_NARROW_MASKPROPS(dameth) (((dameth)&(~DAMETH_TRANS1))|(((dameth)&DAMETH_TRANS1)>>1))
|
#define DAMETH_NARROW_MASKPROPS(dameth) (((dameth)&(~DAMETH_TRANS1))|(((dameth)&DAMETH_TRANS1)>>1))
|
||||||
|
|
|
@ -1030,167 +1030,167 @@ static void polymost_setuptexture(const int32_t dameth, int filter)
|
||||||
void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t dashade, int32_t dameth, pthtyp *pth, int32_t doalloc)
|
void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t dashade, int32_t dameth, pthtyp *pth, int32_t doalloc)
|
||||||
{
|
{
|
||||||
static int32_t fullbrightloadingpass = 0;
|
static int32_t fullbrightloadingpass = 0;
|
||||||
|
vec2_t siz = { 0, 0 }, tsiz = tilesiz[dapic];
|
||||||
vec2_t siz, tsiz = tilesiz[dapic];
|
|
||||||
|
|
||||||
if (!glinfo.texnpot)
|
|
||||||
{
|
|
||||||
for (siz.x = 1; siz.x < tsiz.x; siz.x += siz.x) { }
|
|
||||||
for (siz.y = 1; siz.y < tsiz.y; siz.y += siz.y) { }
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ((tsiz.x|tsiz.y) == 0)
|
|
||||||
siz.x = siz.y = 1;
|
|
||||||
else
|
|
||||||
siz = tsiz;
|
|
||||||
}
|
|
||||||
|
|
||||||
coltype *pic = (coltype *)Xmalloc(siz.x*siz.y*sizeof(coltype));
|
|
||||||
char hasalpha = 0, hasfullbright = 0;
|
char hasalpha = 0, hasfullbright = 0;
|
||||||
|
int32_t npoty = 0;
|
||||||
|
|
||||||
if (!waloff[dapic])
|
|
||||||
{
|
{
|
||||||
//Force invalid textures to draw something - an almost purely transparency texture
|
if (!glinfo.texnpot)
|
||||||
//This allows the Z-buffer to be updated for mirrors (which are invalidated textures)
|
|
||||||
pic[0].r = pic[0].g = pic[0].b = 0; pic[0].a = 1;
|
|
||||||
tsiz.x = tsiz.y = 1; hasalpha = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const int dofullbright = !(picanm[dapic].sf & PICANM_NOFULLBRIGHT_BIT) && !(globalflags & GLOBAL_NO_GL_FULLBRIGHT);
|
|
||||||
|
|
||||||
for (int y = 0; y < siz.y; y++)
|
|
||||||
{
|
{
|
||||||
coltype *wpptr = &pic[y * siz.x];
|
for (siz.x = 1; siz.x < tsiz.x; siz.x += siz.x) { }
|
||||||
int32_t y2 = (y < tsiz.y) ? y : y - tsiz.y;
|
for (siz.y = 1; siz.y < tsiz.y; siz.y += siz.y) { }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((tsiz.x|tsiz.y) == 0)
|
||||||
|
siz.x = siz.y = 1;
|
||||||
|
else
|
||||||
|
siz = tsiz;
|
||||||
|
}
|
||||||
|
|
||||||
for (int x = 0; x < siz.x; x++, wpptr++)
|
coltype *pic = (coltype *)Xmalloc(siz.x*siz.y*sizeof(coltype));
|
||||||
|
|
||||||
|
if (!waloff[dapic])
|
||||||
|
{
|
||||||
|
//Force invalid textures to draw something - an almost purely transparency texture
|
||||||
|
//This allows the Z-buffer to be updated for mirrors (which are invalidated textures)
|
||||||
|
pic[0].r = pic[0].g = pic[0].b = 0; pic[0].a = 1;
|
||||||
|
tsiz.x = tsiz.y = 1; hasalpha = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const int dofullbright = !(picanm[dapic].sf & PICANM_NOFULLBRIGHT_BIT) && !(globalflags & GLOBAL_NO_GL_FULLBRIGHT);
|
||||||
|
|
||||||
|
for (int y = 0; y < siz.y; y++)
|
||||||
{
|
{
|
||||||
int32_t dacol;
|
coltype *wpptr = &pic[y * siz.x];
|
||||||
int32_t x2 = (x < tsiz.x) ? x : x-tsiz.x;
|
int32_t y2 = (y < tsiz.y) ? y : y - tsiz.y;
|
||||||
|
|
||||||
if ((dameth & DAMETH_CLAMPED) && (x >= tsiz.x || y >= tsiz.y)) //Clamp texture
|
for (int x = 0; x < siz.x; x++, wpptr++)
|
||||||
{
|
{
|
||||||
wpptr->r = wpptr->g = wpptr->b = wpptr->a = 0;
|
int32_t dacol;
|
||||||
continue;
|
int32_t x2 = (x < tsiz.x) ? x : x-tsiz.x;
|
||||||
}
|
|
||||||
|
|
||||||
dacol = *(char *)(waloff[dapic]+x2*tsiz.y+y2);
|
if ((dameth & DAMETH_CLAMPED) && (x >= tsiz.x || y >= tsiz.y)) //Clamp texture
|
||||||
|
{
|
||||||
|
wpptr->r = wpptr->g = wpptr->b = wpptr->a = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (dacol == 255)
|
dacol = *(char *)(waloff[dapic]+x2*tsiz.y+y2);
|
||||||
{
|
|
||||||
wpptr->a = 0;
|
|
||||||
hasalpha = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
wpptr->a = 255;
|
|
||||||
|
|
||||||
{
|
if (dacol == 255)
|
||||||
char *p = (char *)(palookup[dapal])+(int32_t)(dashade<<8);
|
|
||||||
dacol = (uint8_t)p[dacol];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fullbrightloadingpass)
|
|
||||||
{
|
|
||||||
// regular texture
|
|
||||||
if (IsPaletteIndexFullbright(dacol) && dofullbright)
|
|
||||||
hasfullbright = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// texture with only fullbright areas
|
|
||||||
if (!IsPaletteIndexFullbright(dacol)) // regular colors
|
|
||||||
{
|
{
|
||||||
wpptr->a = 0;
|
wpptr->a = 0;
|
||||||
hasalpha = 1;
|
hasalpha = 1;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
wpptr->a = 255;
|
||||||
|
|
||||||
bricolor((palette_t *)wpptr, dacol);
|
|
||||||
|
|
||||||
if (!fullbrightloadingpass && tintpalnum >= 0)
|
|
||||||
{
|
|
||||||
uint8_t const r = hictinting[tintpalnum].r;
|
|
||||||
uint8_t const g = hictinting[tintpalnum].g;
|
|
||||||
uint8_t const b = hictinting[tintpalnum].b;
|
|
||||||
uint8_t const effect = hictinting[tintpalnum].f;
|
|
||||||
|
|
||||||
if (effect & HICTINT_GRAYSCALE)
|
|
||||||
{
|
{
|
||||||
wpptr->g = wpptr->r = wpptr->b = (uint8_t) ((wpptr->r * GRAYSCALE_COEFF_RED) +
|
char *p = (char *)(palookup[dapal])+(int32_t)(dashade<<8);
|
||||||
(wpptr->g * GRAYSCALE_COEFF_GREEN) +
|
dacol = (uint8_t)p[dacol];
|
||||||
(wpptr->b * GRAYSCALE_COEFF_BLUE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (effect & HICTINT_INVERT)
|
if (!fullbrightloadingpass)
|
||||||
{
|
{
|
||||||
wpptr->b = 255 - wpptr->b;
|
// regular texture
|
||||||
wpptr->g = 255 - wpptr->g;
|
if (IsPaletteIndexFullbright(dacol) && dofullbright)
|
||||||
wpptr->r = 255 - wpptr->r;
|
hasfullbright = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// texture with only fullbright areas
|
||||||
|
if (!IsPaletteIndexFullbright(dacol)) // regular colors
|
||||||
|
{
|
||||||
|
wpptr->a = 0;
|
||||||
|
hasalpha = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (effect & HICTINT_COLORIZE)
|
bricolor((palette_t *)wpptr, dacol);
|
||||||
{
|
|
||||||
wpptr->b = min((int32_t)((wpptr->b) * b) >> 6, 255);
|
|
||||||
wpptr->g = min((int32_t)((wpptr->g) * g) >> 6, 255);
|
|
||||||
wpptr->r = min((int32_t)((wpptr->r) * r) >> 6, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (effect & HICTINT_BLENDMASK)
|
if (!fullbrightloadingpass && tintpalnum >= 0)
|
||||||
{
|
{
|
||||||
case HICTINT_BLEND_SCREEN:
|
uint8_t const r = hictinting[tintpalnum].r;
|
||||||
wpptr->b = 255 - (((255 - wpptr->b) * (255 - b)) >> 8);
|
uint8_t const g = hictinting[tintpalnum].g;
|
||||||
wpptr->g = 255 - (((255 - wpptr->g) * (255 - g)) >> 8);
|
uint8_t const b = hictinting[tintpalnum].b;
|
||||||
wpptr->r = 255 - (((255 - wpptr->r) * (255 - r)) >> 8);
|
uint8_t const effect = hictinting[tintpalnum].f;
|
||||||
break;
|
|
||||||
case HICTINT_BLEND_OVERLAY:
|
if (effect & HICTINT_GRAYSCALE)
|
||||||
wpptr->b = wpptr->b < 128 ? (wpptr->b * b) >> 7 : 255 - (((255 - wpptr->b) * (255 - b)) >> 7);
|
{
|
||||||
wpptr->g = wpptr->g < 128 ? (wpptr->g * g) >> 7 : 255 - (((255 - wpptr->g) * (255 - g)) >> 7);
|
wpptr->g = wpptr->r = wpptr->b = (uint8_t) ((wpptr->r * GRAYSCALE_COEFF_RED) +
|
||||||
wpptr->r = wpptr->r < 128 ? (wpptr->r * r) >> 7 : 255 - (((255 - wpptr->r) * (255 - r)) >> 7);
|
(wpptr->g * GRAYSCALE_COEFF_GREEN) +
|
||||||
break;
|
(wpptr->b * GRAYSCALE_COEFF_BLUE));
|
||||||
case HICTINT_BLEND_HARDLIGHT:
|
}
|
||||||
wpptr->b = b < 128 ? (wpptr->b * b) >> 7 : 255 - (((255 - wpptr->b) * (255 - b)) >> 7);
|
|
||||||
wpptr->g = g < 128 ? (wpptr->g * g) >> 7 : 255 - (((255 - wpptr->g) * (255 - g)) >> 7);
|
if (effect & HICTINT_INVERT)
|
||||||
wpptr->r = r < 128 ? (wpptr->r * r) >> 7 : 255 - (((255 - wpptr->r) * (255 - r)) >> 7);
|
{
|
||||||
break;
|
wpptr->b = 255 - wpptr->b;
|
||||||
|
wpptr->g = 255 - wpptr->g;
|
||||||
|
wpptr->r = 255 - wpptr->r;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (effect & HICTINT_COLORIZE)
|
||||||
|
{
|
||||||
|
wpptr->b = min((int32_t)((wpptr->b) * b) >> 6, 255);
|
||||||
|
wpptr->g = min((int32_t)((wpptr->g) * g) >> 6, 255);
|
||||||
|
wpptr->r = min((int32_t)((wpptr->r) * r) >> 6, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (effect & HICTINT_BLENDMASK)
|
||||||
|
{
|
||||||
|
case HICTINT_BLEND_SCREEN:
|
||||||
|
wpptr->b = 255 - (((255 - wpptr->b) * (255 - b)) >> 8);
|
||||||
|
wpptr->g = 255 - (((255 - wpptr->g) * (255 - g)) >> 8);
|
||||||
|
wpptr->r = 255 - (((255 - wpptr->r) * (255 - r)) >> 8);
|
||||||
|
break;
|
||||||
|
case HICTINT_BLEND_OVERLAY:
|
||||||
|
wpptr->b = wpptr->b < 128 ? (wpptr->b * b) >> 7 : 255 - (((255 - wpptr->b) * (255 - b)) >> 7);
|
||||||
|
wpptr->g = wpptr->g < 128 ? (wpptr->g * g) >> 7 : 255 - (((255 - wpptr->g) * (255 - g)) >> 7);
|
||||||
|
wpptr->r = wpptr->r < 128 ? (wpptr->r * r) >> 7 : 255 - (((255 - wpptr->r) * (255 - r)) >> 7);
|
||||||
|
break;
|
||||||
|
case HICTINT_BLEND_HARDLIGHT:
|
||||||
|
wpptr->b = b < 128 ? (wpptr->b * b) >> 7 : 255 - (((255 - wpptr->b) * (255 - b)) >> 7);
|
||||||
|
wpptr->g = g < 128 ? (wpptr->g * g) >> 7 : 255 - (((255 - wpptr->g) * (255 - g)) >> 7);
|
||||||
|
wpptr->r = r < 128 ? (wpptr->r * r) >> 7 : 255 - (((255 - wpptr->r) * (255 - r)) >> 7);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (doalloc) bglGenTextures(1,(GLuint *)&pth->glpic); //# of textures (make OpenGL allocate structure)
|
||||||
|
bglBindTexture(GL_TEXTURE_2D,pth->glpic);
|
||||||
|
|
||||||
|
fixtransparency(pic,tsiz,siz,dameth);
|
||||||
|
|
||||||
|
if (polymost_want_npotytex(dameth, siz.y) && tsiz.x == siz.x && tsiz.y == siz.y) // XXX
|
||||||
|
{
|
||||||
|
const int32_t nextpoty = 1 << ((picsiz[dapic] >> 4) + 1);
|
||||||
|
const int32_t ydif = nextpoty - siz.y;
|
||||||
|
coltype *paddedpic;
|
||||||
|
|
||||||
|
Bassert(ydif < siz.y);
|
||||||
|
|
||||||
|
paddedpic = (coltype *)Xrealloc(pic, siz.x * nextpoty * sizeof(coltype));
|
||||||
|
|
||||||
|
pic = paddedpic;
|
||||||
|
Bmemcpy(&pic[siz.x * siz.y], pic, siz.x * ydif * sizeof(coltype));
|
||||||
|
siz.y = tsiz.y = nextpoty;
|
||||||
|
|
||||||
|
npoty = PTH_NPOTWALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadtexture(doalloc, siz, GL_RGBA, pic, tsiz,
|
||||||
|
dameth | DAMETH_ARTIMMUNITY |
|
||||||
|
(dapic >= MAXUSERTILES ? (DAMETH_NOTEXCOMPRESS|DAMETH_NODOWNSIZE) : 0) | /* never process these short-lived tiles */
|
||||||
|
(hasalpha ? (DAMETH_HASALPHA|DAMETH_ONEBITALPHA) : 0));
|
||||||
|
|
||||||
|
Bfree(pic);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doalloc) bglGenTextures(1,(GLuint *)&pth->glpic); //# of textures (make OpenGL allocate structure)
|
|
||||||
bglBindTexture(GL_TEXTURE_2D,pth->glpic);
|
|
||||||
|
|
||||||
fixtransparency(pic,tsiz,siz,dameth);
|
|
||||||
|
|
||||||
int32_t npoty = 0;
|
|
||||||
|
|
||||||
if (polymost_want_npotytex(dameth, siz.y) && tsiz.x == siz.x && tsiz.y == siz.y) // XXX
|
|
||||||
{
|
|
||||||
const int32_t nextpoty = 1 << ((picsiz[dapic] >> 4) + 1);
|
|
||||||
const int32_t ydif = nextpoty - siz.y;
|
|
||||||
coltype *paddedpic;
|
|
||||||
|
|
||||||
Bassert(ydif < siz.y);
|
|
||||||
|
|
||||||
paddedpic = (coltype *)Xrealloc(pic, siz.x * nextpoty * sizeof(coltype));
|
|
||||||
|
|
||||||
pic = paddedpic;
|
|
||||||
Bmemcpy(&pic[siz.x * siz.y], pic, siz.x * ydif * sizeof(coltype));
|
|
||||||
siz.y = tsiz.y = nextpoty;
|
|
||||||
|
|
||||||
npoty = PTH_NPOTWALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
uploadtexture(doalloc, siz, GL_RGBA, pic, tsiz,
|
|
||||||
dameth | DAMETH_ARTIMMUNITY |
|
|
||||||
(dapic >= MAXUSERTILES ? (DAMETH_NOTEXCOMPRESS|DAMETH_NODOWNSIZE) : 0) | /* never process these short-lived tiles */
|
|
||||||
(hasalpha ? (DAMETH_HASALPHA|DAMETH_ONEBITALPHA) : 0));
|
|
||||||
|
|
||||||
Bfree(pic);
|
|
||||||
|
|
||||||
polymost_setuptexture(dameth, -1);
|
polymost_setuptexture(dameth, -1);
|
||||||
|
|
||||||
pth->picnum = dapic;
|
pth->picnum = dapic;
|
||||||
|
|
Loading…
Reference in a new issue