mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 04:21:47 +00:00
use enum for bpp
This commit is contained in:
parent
c7eed47340
commit
f39368dfb0
3 changed files with 46 additions and 36 deletions
|
|
@ -118,6 +118,10 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
|
||||||
count--;
|
count--;
|
||||||
|
|
||||||
texel = source[yfrac>>FRACBITS];
|
texel = source[yfrac>>FRACBITS];
|
||||||
|
alpha = 0xFF;
|
||||||
|
// Make pixel transparent if chroma keyed
|
||||||
|
if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
|
||||||
|
alpha = 0x00;
|
||||||
|
|
||||||
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
||||||
if (mipmap->colormap)
|
if (mipmap->colormap)
|
||||||
|
|
@ -230,17 +234,15 @@ static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block,
|
||||||
count--;
|
count--;
|
||||||
|
|
||||||
texel = source[yfrac>>FRACBITS];
|
texel = source[yfrac>>FRACBITS];
|
||||||
|
alpha = 0xFF;
|
||||||
|
// Make pixel transparent if chroma keyed
|
||||||
|
if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
|
||||||
|
alpha = 0x00;
|
||||||
|
|
||||||
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
||||||
if (mipmap->colormap)
|
if (mipmap->colormap)
|
||||||
texel = mipmap->colormap[texel];
|
texel = mipmap->colormap[texel];
|
||||||
|
|
||||||
// transparent pixel
|
|
||||||
if (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX)
|
|
||||||
alpha = 0x00;
|
|
||||||
else
|
|
||||||
alpha = 0xff;
|
|
||||||
|
|
||||||
// hope compiler will get this switch out of the loops (dreams...)
|
// hope compiler will get this switch out of the loops (dreams...)
|
||||||
// gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?)
|
// gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?)
|
||||||
// Alam: SRB2 uses Mingw, HUGS
|
// Alam: SRB2 uses Mingw, HUGS
|
||||||
|
|
|
||||||
|
|
@ -128,9 +128,9 @@ void *Picture_PatchConvert(
|
||||||
else if (informat == outformat)
|
else if (informat == outformat)
|
||||||
I_Error("Picture_PatchConvert: input and output formats were the same!");
|
I_Error("Picture_PatchConvert: input and output formats were the same!");
|
||||||
|
|
||||||
if (!inbpp)
|
if (inbpp == PICDEPTH_NONE)
|
||||||
I_Error("Picture_PatchConvert: unknown input bits per pixel?!");
|
I_Error("Picture_PatchConvert: unknown input bits per pixel?!");
|
||||||
if (!Picture_FormatBPP(outformat))
|
if (Picture_FormatBPP(outformat) == PICDEPTH_NONE)
|
||||||
I_Error("Picture_PatchConvert: unknown output bits per pixel?!");
|
I_Error("Picture_PatchConvert: unknown output bits per pixel?!");
|
||||||
|
|
||||||
// If it's a patch, you can just figure out
|
// If it's a patch, you can just figure out
|
||||||
|
|
@ -199,17 +199,17 @@ void *Picture_PatchConvert(
|
||||||
if (input != NULL)
|
if (input != NULL)
|
||||||
{
|
{
|
||||||
UINT8 alpha = 0xFF;
|
UINT8 alpha = 0xFF;
|
||||||
if (inbpp == 32)
|
if (inbpp == PICDEPTH_32BPP)
|
||||||
{
|
{
|
||||||
RGBA_t px = *(RGBA_t *)input;
|
RGBA_t px = *(RGBA_t *)input;
|
||||||
alpha = px.s.alpha;
|
alpha = px.s.alpha;
|
||||||
}
|
}
|
||||||
else if (inbpp == 16)
|
else if (inbpp == PICDEPTH_16BPP)
|
||||||
{
|
{
|
||||||
UINT16 px = *(UINT16 *)input;
|
UINT16 px = *(UINT16 *)input;
|
||||||
alpha = (px & 0xFF00) >> 8;
|
alpha = (px & 0xFF00) >> 8;
|
||||||
}
|
}
|
||||||
else if (inbpp == 8)
|
else if (inbpp == PICDEPTH_8BPP)
|
||||||
{
|
{
|
||||||
UINT8 px = *(UINT8 *)input;
|
UINT8 px = *(UINT8 *)input;
|
||||||
if (px == TRANSPARENTPIXEL)
|
if (px == TRANSPARENTPIXEL)
|
||||||
|
|
@ -272,12 +272,12 @@ void *Picture_PatchConvert(
|
||||||
{
|
{
|
||||||
case PICFMT_PATCH32:
|
case PICFMT_PATCH32:
|
||||||
{
|
{
|
||||||
if (inbpp == 32)
|
if (inbpp == PICDEPTH_32BPP)
|
||||||
{
|
{
|
||||||
RGBA_t out = *(RGBA_t *)input;
|
RGBA_t out = *(RGBA_t *)input;
|
||||||
WRITEUINT32(imgptr, out.rgba);
|
WRITEUINT32(imgptr, out.rgba);
|
||||||
}
|
}
|
||||||
else if (inbpp == 16)
|
else if (inbpp == PICDEPTH_16BPP)
|
||||||
{
|
{
|
||||||
RGBA_t out = pMasterPalette[*((UINT16 *)input) & 0xFF];
|
RGBA_t out = pMasterPalette[*((UINT16 *)input) & 0xFF];
|
||||||
WRITEUINT32(imgptr, out.rgba);
|
WRITEUINT32(imgptr, out.rgba);
|
||||||
|
|
@ -290,26 +290,26 @@ void *Picture_PatchConvert(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PICFMT_PATCH16:
|
case PICFMT_PATCH16:
|
||||||
if (inbpp == 32)
|
if (inbpp == PICDEPTH_32BPP)
|
||||||
{
|
{
|
||||||
RGBA_t in = *(RGBA_t *)input;
|
RGBA_t in = *(RGBA_t *)input;
|
||||||
UINT8 out = NearestColor(in.s.red, in.s.green, in.s.blue);
|
UINT8 out = NearestColor(in.s.red, in.s.green, in.s.blue);
|
||||||
WRITEUINT16(imgptr, (0xFF00 | out));
|
WRITEUINT16(imgptr, (0xFF00 | out));
|
||||||
}
|
}
|
||||||
else if (inbpp == 16)
|
else if (inbpp == PICDEPTH_16BPP)
|
||||||
WRITEUINT16(imgptr, *(UINT16 *)input);
|
WRITEUINT16(imgptr, *(UINT16 *)input);
|
||||||
else // PICFMT_PATCH
|
else // PICFMT_PATCH
|
||||||
WRITEUINT16(imgptr, (0xFF00 | (*(UINT8 *)input)));
|
WRITEUINT16(imgptr, (0xFF00 | (*(UINT8 *)input)));
|
||||||
break;
|
break;
|
||||||
default: // PICFMT_PATCH
|
default: // PICFMT_PATCH
|
||||||
{
|
{
|
||||||
if (inbpp == 32)
|
if (inbpp == PICDEPTH_32BPP)
|
||||||
{
|
{
|
||||||
RGBA_t in = *(RGBA_t *)input;
|
RGBA_t in = *(RGBA_t *)input;
|
||||||
UINT8 out = NearestColor(in.s.red, in.s.green, in.s.blue);
|
UINT8 out = NearestColor(in.s.red, in.s.green, in.s.blue);
|
||||||
WRITEUINT8(imgptr, out);
|
WRITEUINT8(imgptr, out);
|
||||||
}
|
}
|
||||||
else if (inbpp == 16)
|
else if (inbpp == PICDEPTH_16BPP)
|
||||||
{
|
{
|
||||||
UINT16 out = *(UINT16 *)input;
|
UINT16 out = *(UINT16 *)input;
|
||||||
WRITEUINT8(imgptr, (out & 0xFF));
|
WRITEUINT8(imgptr, (out & 0xFF));
|
||||||
|
|
@ -377,9 +377,9 @@ void *Picture_FlatConvert(
|
||||||
else if (informat == outformat)
|
else if (informat == outformat)
|
||||||
I_Error("Picture_FlatConvert: input and output formats were the same!");
|
I_Error("Picture_FlatConvert: input and output formats were the same!");
|
||||||
|
|
||||||
if (!inbpp)
|
if (inbpp == PICDEPTH_NONE)
|
||||||
I_Error("Picture_FlatConvert: unknown input bits per pixel?!");
|
I_Error("Picture_FlatConvert: unknown input bits per pixel?!");
|
||||||
if (!outbpp)
|
if (outbpp == PICDEPTH_NONE)
|
||||||
I_Error("Picture_FlatConvert: unknown output bits per pixel?!");
|
I_Error("Picture_FlatConvert: unknown output bits per pixel?!");
|
||||||
|
|
||||||
// If it's a patch, you can just figure out
|
// If it's a patch, you can just figure out
|
||||||
|
|
@ -397,7 +397,7 @@ void *Picture_FlatConvert(
|
||||||
*outsize = size;
|
*outsize = size;
|
||||||
|
|
||||||
// Set transparency
|
// Set transparency
|
||||||
if (outbpp == 8)
|
if (outbpp == PICDEPTH_8BPP)
|
||||||
memset(outflat, TRANSPARENTPIXEL, size);
|
memset(outflat, TRANSPARENTPIXEL, size);
|
||||||
|
|
||||||
for (y = 0; y < inheight; y++)
|
for (y = 0; y < inheight; y++)
|
||||||
|
|
@ -422,12 +422,12 @@ void *Picture_FlatConvert(
|
||||||
case PICFMT_FLAT32:
|
case PICFMT_FLAT32:
|
||||||
{
|
{
|
||||||
UINT32 *f32 = (UINT32 *)outflat;
|
UINT32 *f32 = (UINT32 *)outflat;
|
||||||
if (inbpp == 32)
|
if (inbpp == PICDEPTH_32BPP)
|
||||||
{
|
{
|
||||||
RGBA_t out = *(RGBA_t *)input;
|
RGBA_t out = *(RGBA_t *)input;
|
||||||
f32[offs] = out.rgba;
|
f32[offs] = out.rgba;
|
||||||
}
|
}
|
||||||
else if (inbpp == 16)
|
else if (inbpp == PICDEPTH_16BPP)
|
||||||
{
|
{
|
||||||
RGBA_t out = pMasterPalette[*((UINT16 *)input) & 0xFF];
|
RGBA_t out = pMasterPalette[*((UINT16 *)input) & 0xFF];
|
||||||
f32[offs] = out.rgba;
|
f32[offs] = out.rgba;
|
||||||
|
|
@ -442,13 +442,13 @@ void *Picture_FlatConvert(
|
||||||
case PICFMT_FLAT16:
|
case PICFMT_FLAT16:
|
||||||
{
|
{
|
||||||
UINT16 *f16 = (UINT16 *)outflat;
|
UINT16 *f16 = (UINT16 *)outflat;
|
||||||
if (inbpp == 32)
|
if (inbpp == PICDEPTH_32BPP)
|
||||||
{
|
{
|
||||||
RGBA_t in = *(RGBA_t *)input;
|
RGBA_t in = *(RGBA_t *)input;
|
||||||
UINT8 out = NearestColor(in.s.red, in.s.green, in.s.blue);
|
UINT8 out = NearestColor(in.s.red, in.s.green, in.s.blue);
|
||||||
f16[offs] = (0xFF00 | out);
|
f16[offs] = (0xFF00 | out);
|
||||||
}
|
}
|
||||||
else if (inbpp == 16)
|
else if (inbpp == PICDEPTH_16BPP)
|
||||||
f16[offs] = *(UINT16 *)input;
|
f16[offs] = *(UINT16 *)input;
|
||||||
else // PICFMT_PATCH
|
else // PICFMT_PATCH
|
||||||
f16[offs] = (0xFF00 | *((UINT8 *)input));
|
f16[offs] = (0xFF00 | *((UINT8 *)input));
|
||||||
|
|
@ -457,13 +457,13 @@ void *Picture_FlatConvert(
|
||||||
case PICFMT_FLAT:
|
case PICFMT_FLAT:
|
||||||
{
|
{
|
||||||
UINT8 *f8 = (UINT8 *)outflat;
|
UINT8 *f8 = (UINT8 *)outflat;
|
||||||
if (inbpp == 32)
|
if (inbpp == PICDEPTH_32BPP)
|
||||||
{
|
{
|
||||||
RGBA_t in = *(RGBA_t *)input;
|
RGBA_t in = *(RGBA_t *)input;
|
||||||
UINT8 out = NearestColor(in.s.red, in.s.green, in.s.blue);
|
UINT8 out = NearestColor(in.s.red, in.s.green, in.s.blue);
|
||||||
f8[offs] = out;
|
f8[offs] = out;
|
||||||
}
|
}
|
||||||
else if (inbpp == 16)
|
else if (inbpp == PICDEPTH_16BPP)
|
||||||
{
|
{
|
||||||
UINT16 out = *(UINT16 *)input;
|
UINT16 out = *(UINT16 *)input;
|
||||||
f8[offs] = (out & 0xFF);
|
f8[offs] = (out & 0xFF);
|
||||||
|
|
@ -553,21 +553,21 @@ void *Picture_GetPatchPixel(
|
||||||
*/
|
*/
|
||||||
INT32 Picture_FormatBPP(pictureformat_t format)
|
INT32 Picture_FormatBPP(pictureformat_t format)
|
||||||
{
|
{
|
||||||
INT32 bpp = 0;
|
INT32 bpp = PICDEPTH_NONE;
|
||||||
switch (format)
|
switch (format)
|
||||||
{
|
{
|
||||||
case PICFMT_PATCH32:
|
case PICFMT_PATCH32:
|
||||||
case PICFMT_FLAT32:
|
case PICFMT_FLAT32:
|
||||||
case PICFMT_PNG:
|
case PICFMT_PNG:
|
||||||
bpp = 32;
|
bpp = PICDEPTH_32BPP;
|
||||||
break;
|
break;
|
||||||
case PICFMT_PATCH16:
|
case PICFMT_PATCH16:
|
||||||
case PICFMT_FLAT16:
|
case PICFMT_FLAT16:
|
||||||
bpp = 16;
|
bpp = PICDEPTH_16BPP;
|
||||||
break;
|
break;
|
||||||
case PICFMT_PATCH:
|
case PICFMT_PATCH:
|
||||||
case PICFMT_FLAT:
|
case PICFMT_FLAT:
|
||||||
bpp = 8;
|
bpp = PICDEPTH_8BPP;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
@ -938,12 +938,12 @@ void *Picture_PNGConvert(
|
||||||
if (Picture_IsPatchFormat(outformat))
|
if (Picture_IsPatchFormat(outformat))
|
||||||
{
|
{
|
||||||
// Force a higher bit depth
|
// Force a higher bit depth
|
||||||
if (outbpp == 8)
|
if (outbpp == PICDEPTH_8BPP)
|
||||||
outbpp = 16;
|
outbpp = PICDEPTH_16BPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shouldn't happen.
|
// Shouldn't happen.
|
||||||
if (!outbpp)
|
if (outbpp == PICDEPTH_NONE)
|
||||||
I_Error("Picture_PNGConvert: unknown output bits per pixel?!");
|
I_Error("Picture_PNGConvert: unknown output bits per pixel?!");
|
||||||
|
|
||||||
// Figure out the size
|
// Figure out the size
|
||||||
|
|
@ -955,7 +955,7 @@ void *Picture_PNGConvert(
|
||||||
flat = Z_Calloc(flatsize, PU_STATIC, NULL);
|
flat = Z_Calloc(flatsize, PU_STATIC, NULL);
|
||||||
|
|
||||||
// Set transparency
|
// Set transparency
|
||||||
if (outbpp == 8)
|
if (outbpp == PICDEPTH_8BPP)
|
||||||
memset(flat, TRANSPARENTPIXEL, (width * height));
|
memset(flat, TRANSPARENTPIXEL, (width * height));
|
||||||
|
|
||||||
for (y = 0; y < height; y++)
|
for (y = 0; y < height; y++)
|
||||||
|
|
@ -970,7 +970,7 @@ void *Picture_PNGConvert(
|
||||||
UINT8 green = (UINT8)px[1];
|
UINT8 green = (UINT8)px[1];
|
||||||
UINT8 blue = (UINT8)px[2];
|
UINT8 blue = (UINT8)px[2];
|
||||||
UINT8 alpha = (UINT8)px[3];
|
UINT8 alpha = (UINT8)px[3];
|
||||||
if (outbpp == 32)
|
if (outbpp == PICDEPTH_32BPP)
|
||||||
{
|
{
|
||||||
UINT32 *outflat = (UINT32 *)flat;
|
UINT32 *outflat = (UINT32 *)flat;
|
||||||
RGBA_t out;
|
RGBA_t out;
|
||||||
|
|
@ -983,7 +983,7 @@ void *Picture_PNGConvert(
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UINT8 palidx = NearestColor(red, green, blue);
|
UINT8 palidx = NearestColor(red, green, blue);
|
||||||
if (outbpp == 16)
|
if (outbpp == PICDEPTH_16BPP)
|
||||||
{
|
{
|
||||||
UINT16 *outflat = (UINT16 *)flat;
|
UINT16 *outflat = (UINT16 *)flat;
|
||||||
outflat[((y * width) + x)] = (alpha << 8) | palidx;
|
outflat[((y * width) + x)] = (alpha << 8) | palidx;
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,14 @@ typedef enum
|
||||||
PICFLAGS_YFLIP = 1<<1
|
PICFLAGS_YFLIP = 1<<1
|
||||||
} pictureflags_t;
|
} pictureflags_t;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PICDEPTH_NONE = 0,
|
||||||
|
PICDEPTH_8BPP = 8,
|
||||||
|
PICDEPTH_16BPP = 16,
|
||||||
|
PICDEPTH_32BPP = 32
|
||||||
|
};
|
||||||
|
|
||||||
void *Picture_Convert(
|
void *Picture_Convert(
|
||||||
pictureformat_t informat, void *picture, pictureformat_t outformat,
|
pictureformat_t informat, void *picture, pictureformat_t outformat,
|
||||||
size_t insize, size_t *outsize,
|
size_t insize, size_t *outsize,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue