Merge branch 'more-opengl-fixes' into 'master'
More OpenGL fixes plus masked PNG conversion See merge request STJr/SRB2!619
This commit is contained in:
commit
6870492cf2
|
@ -122,11 +122,11 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
|
||||||
if (mipmap->colormap)
|
if (mipmap->colormap)
|
||||||
texel = mipmap->colormap[texel];
|
texel = mipmap->colormap[texel];
|
||||||
|
|
||||||
// transparent pixel
|
// If the mipmap is chromakeyed, check if the texel's color
|
||||||
if (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX)
|
// is equivalent to the chroma key's color index.
|
||||||
|
alpha = 0xff;
|
||||||
|
if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
|
||||||
alpha = 0x00;
|
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 ?)
|
||||||
|
@ -654,7 +654,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex)
|
||||||
|
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
if (R_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
if (R_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
||||||
realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL, false);
|
realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef WALLFLATS
|
#ifdef WALLFLATS
|
||||||
|
@ -698,7 +698,7 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm
|
||||||
// lump is a png so convert it
|
// lump is a png so convert it
|
||||||
size_t len = W_LumpLengthPwad(grPatch->wadnum, grPatch->lumpnum);
|
size_t len = W_LumpLengthPwad(grPatch->wadnum, grPatch->lumpnum);
|
||||||
if ((patch != NULL) && R_IsLumpPNG((const UINT8 *)patch, len))
|
if ((patch != NULL) && R_IsLumpPNG((const UINT8 *)patch, len))
|
||||||
patch = R_PNGToPatch((const UINT8 *)patch, len, NULL, true);
|
patch = R_PNGToPatch((const UINT8 *)patch, len, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// don't do it twice (like a cache)
|
// don't do it twice (like a cache)
|
||||||
|
@ -1324,23 +1324,6 @@ GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum)
|
||||||
return HWR_GetCachedGLPatchPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum));
|
return HWR_GetCachedGLPatchPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ROTSPRITE
|
|
||||||
GLPatch_t *HWR_GetCachedGLRotSprite(aatree_t *hwrcache, UINT16 rollangle, patch_t *rawpatch)
|
|
||||||
{
|
|
||||||
GLPatch_t *grpatch;
|
|
||||||
|
|
||||||
if (!(grpatch = M_AATreeGet(hwrcache, rollangle)))
|
|
||||||
{
|
|
||||||
grpatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
|
|
||||||
grpatch->rawpatch = rawpatch;
|
|
||||||
grpatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
|
|
||||||
M_AATreeSet(hwrcache, rollangle, grpatch);
|
|
||||||
}
|
|
||||||
|
|
||||||
return grpatch;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Need to do this because they aren't powers of 2
|
// Need to do this because they aren't powers of 2
|
||||||
static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 pblockheight,
|
static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 pblockheight,
|
||||||
lumpnum_t fademasklumpnum, UINT16 fmwidth, UINT16 fmheight)
|
lumpnum_t fademasklumpnum, UINT16 fmwidth, UINT16 fmheight)
|
||||||
|
|
|
@ -113,9 +113,6 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum);
|
||||||
void HWR_SetPalette(RGBA_t *palette);
|
void HWR_SetPalette(RGBA_t *palette);
|
||||||
GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump);
|
GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump);
|
||||||
GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum);
|
GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum);
|
||||||
#ifdef ROTSPRITE
|
|
||||||
GLPatch_t *HWR_GetCachedGLRotSprite(aatree_t *hwrcache, UINT16 rollangle, patch_t *rawpatch);
|
|
||||||
#endif
|
|
||||||
void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
|
void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
|
||||||
|
|
||||||
// --------
|
// --------
|
||||||
|
|
|
@ -1108,7 +1108,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr)
|
||||||
{
|
{
|
||||||
sector_t *sector = spr->mobj->subsector->sector;
|
sector_t *sector = spr->mobj->subsector->sector;
|
||||||
UINT8 lightlevel = 255;
|
UINT8 lightlevel = 255;
|
||||||
extracolormap_t *colormap = sector->extra_colormap;
|
extracolormap_t *colormap = NULL;
|
||||||
|
|
||||||
if (sector->numlights)
|
if (sector->numlights)
|
||||||
{
|
{
|
||||||
|
@ -1145,6 +1145,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr)
|
||||||
INT32 durs = spr->mobj->state->tics;
|
INT32 durs = spr->mobj->state->tics;
|
||||||
INT32 tics = spr->mobj->tics;
|
INT32 tics = spr->mobj->tics;
|
||||||
//mdlframe_t *next = NULL;
|
//mdlframe_t *next = NULL;
|
||||||
|
const boolean papersprite = (spr->mobj->frame & FF_PAPERSPRITE);
|
||||||
const UINT8 flip = (UINT8)(!(spr->mobj->eflags & MFE_VERTICALFLIP) != !(spr->mobj->frame & FF_VERTICALFLIP));
|
const UINT8 flip = (UINT8)(!(spr->mobj->eflags & MFE_VERTICALFLIP) != !(spr->mobj->frame & FF_VERTICALFLIP));
|
||||||
spritedef_t *sprdef;
|
spritedef_t *sprdef;
|
||||||
spriteframe_t *sprframe;
|
spriteframe_t *sprframe;
|
||||||
|
@ -1367,14 +1368,12 @@ boolean HWR_DrawModel(gr_vissprite_t *spr)
|
||||||
|
|
||||||
sprframe = &sprdef->spriteframes[spr->mobj->frame & FF_FRAMEMASK];
|
sprframe = &sprdef->spriteframes[spr->mobj->frame & FF_FRAMEMASK];
|
||||||
|
|
||||||
if (sprframe->rotate)
|
if (sprframe->rotate || papersprite)
|
||||||
{
|
{
|
||||||
fixed_t anglef = AngleFixed(spr->mobj->angle);
|
fixed_t anglef = AngleFixed(spr->mobj->angle);
|
||||||
|
|
||||||
if (spr->mobj->player)
|
if (spr->mobj->player)
|
||||||
anglef = AngleFixed(spr->mobj->player->drawangle);
|
anglef = AngleFixed(spr->mobj->player->drawangle);
|
||||||
else
|
|
||||||
anglef = AngleFixed(spr->mobj->angle);
|
|
||||||
|
|
||||||
p.angley = FIXED_TO_FLOAT(anglef);
|
p.angley = FIXED_TO_FLOAT(anglef);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2275,14 +2275,30 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform)
|
||||||
|
|
||||||
EXPORT INT32 HWRAPI(GetTextureUsed) (void)
|
EXPORT INT32 HWRAPI(GetTextureUsed) (void)
|
||||||
{
|
{
|
||||||
FTextureInfo* tmp = gr_cachehead;
|
FTextureInfo *tmp = gr_cachehead;
|
||||||
INT32 res = 0;
|
INT32 res = 0;
|
||||||
|
|
||||||
while (tmp)
|
while (tmp)
|
||||||
{
|
{
|
||||||
res += tmp->height*tmp->width*(screen_depth/8);
|
// Figure out the correct bytes-per-pixel for this texture
|
||||||
|
// I don't know which one the game actually _uses_ but this
|
||||||
|
// follows format2bpp in hw_cache.c
|
||||||
|
int bpp = 1;
|
||||||
|
int format = tmp->grInfo.format;
|
||||||
|
if (format == GR_RGBA)
|
||||||
|
bpp = 4;
|
||||||
|
else if (format == GR_TEXFMT_RGB_565
|
||||||
|
|| format == GR_TEXFMT_ARGB_1555
|
||||||
|
|| format == GR_TEXFMT_ARGB_4444
|
||||||
|
|| format == GR_TEXFMT_ALPHA_INTENSITY_88
|
||||||
|
|| format == GR_TEXFMT_AP_88)
|
||||||
|
bpp = 2;
|
||||||
|
|
||||||
|
// Add it up!
|
||||||
|
res += tmp->height*tmp->width*bpp;
|
||||||
tmp = tmp->nextmipmap;
|
tmp = tmp->nextmipmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -571,7 +571,7 @@ static UINT8 *R_GenerateTexture(size_t texnum)
|
||||||
|
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
if (R_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
if (R_IsLumpPNG((UINT8 *)realpatch, lumplength))
|
||||||
realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL, false);
|
realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef WALLFLATS
|
#ifdef WALLFLATS
|
||||||
|
|
|
@ -740,9 +740,6 @@ typedef struct
|
||||||
{
|
{
|
||||||
patch_t *patch[8][ROTANGLES];
|
patch_t *patch[8][ROTANGLES];
|
||||||
boolean cached[8];
|
boolean cached[8];
|
||||||
#ifdef HWRENDER
|
|
||||||
aatree_t *hardware_patch[8];
|
|
||||||
#endif/*HWRENDER*/
|
|
||||||
} rotsprite_t;
|
} rotsprite_t;
|
||||||
#endif/*ROTSPRITE*/
|
#endif/*ROTSPRITE*/
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||||
// Copyright (C) 2005-2009 by Andrey "entryway" Budko.
|
// Copyright (C) 2005-2009 by Andrey "entryway" Budko.
|
||||||
// Copyright (C) 2018-2019 by Jaime "Lactozilla" Passos.
|
// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos.
|
||||||
// Copyright (C) 2019 by Sonic Team Junior.
|
// Copyright (C) 2019-2020 by Sonic Team Junior.
|
||||||
//
|
//
|
||||||
// This program is free software distributed under the
|
// This program is free software distributed under the
|
||||||
// terms of the GNU General Public License, version 2.
|
// terms of the GNU General Public License, version 2.
|
||||||
|
@ -201,11 +201,15 @@ void R_PatchToFlat(patch_t *patch, UINT8 *flat)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_PatchToFlat_16bpp
|
// R_PatchToMaskedFlat
|
||||||
//
|
//
|
||||||
// Convert a patch to a 16-bit flat.
|
// Convert a patch to a masked flat.
|
||||||
|
// Now, what is a "masked" flat anyway?
|
||||||
|
// It means the flat uses two bytes to store image data.
|
||||||
|
// The upper byte is used to store the transparent pixel,
|
||||||
|
// and the lower byte stores a palette index.
|
||||||
//
|
//
|
||||||
void R_PatchToFlat_16bpp(patch_t *patch, UINT16 *raw, boolean flip)
|
void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip)
|
||||||
{
|
{
|
||||||
fixed_t col, ofs;
|
fixed_t col, ofs;
|
||||||
column_t *column;
|
column_t *column;
|
||||||
|
@ -250,6 +254,9 @@ patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffse
|
||||||
UINT8 *colpointers, *startofspan;
|
UINT8 *colpointers, *startofspan;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
|
||||||
|
if (!raw)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// Write image size and offset
|
// Write image size and offset
|
||||||
WRITEINT16(imgptr, width);
|
WRITEINT16(imgptr, width);
|
||||||
WRITEINT16(imgptr, height);
|
WRITEINT16(imgptr, height);
|
||||||
|
@ -349,16 +356,18 @@ patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffse
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_FlatToPatch_16bpp
|
// R_MaskedFlatToPatch
|
||||||
//
|
//
|
||||||
// Convert a 16-bit flat to a patch.
|
// Convert a masked flat to a patch.
|
||||||
|
// Explanation of "masked" flats in R_PatchToMaskedFlat.
|
||||||
//
|
//
|
||||||
patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, size_t *size)
|
patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize)
|
||||||
{
|
{
|
||||||
UINT32 x, y;
|
UINT32 x, y;
|
||||||
UINT8 *img;
|
UINT8 *img;
|
||||||
UINT8 *imgptr = imgbuf;
|
UINT8 *imgptr = imgbuf;
|
||||||
UINT8 *colpointers, *startofspan;
|
UINT8 *colpointers, *startofspan;
|
||||||
|
size_t size = 0;
|
||||||
|
|
||||||
if (!raw)
|
if (!raw)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -366,9 +375,8 @@ patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, size_t *s
|
||||||
// Write image size and offset
|
// Write image size and offset
|
||||||
WRITEINT16(imgptr, width);
|
WRITEINT16(imgptr, width);
|
||||||
WRITEINT16(imgptr, height);
|
WRITEINT16(imgptr, height);
|
||||||
// no offsets
|
WRITEINT16(imgptr, leftoffset);
|
||||||
WRITEINT16(imgptr, 0);
|
WRITEINT16(imgptr, topoffset);
|
||||||
WRITEINT16(imgptr, 0);
|
|
||||||
|
|
||||||
// Leave placeholder to column pointers
|
// Leave placeholder to column pointers
|
||||||
colpointers = imgptr;
|
colpointers = imgptr;
|
||||||
|
@ -452,9 +460,12 @@ patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, size_t *s
|
||||||
WRITEUINT8(imgptr, 0xFF);
|
WRITEUINT8(imgptr, 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
*size = imgptr-imgbuf;
|
size = imgptr-imgbuf;
|
||||||
img = Z_Malloc(*size, PU_STATIC, NULL);
|
img = Z_Malloc(size, PU_STATIC, NULL);
|
||||||
memcpy(img, imgbuf, *size);
|
memcpy(img, imgbuf, size);
|
||||||
|
|
||||||
|
if (destsize != NULL)
|
||||||
|
*destsize = size;
|
||||||
return (patch_t *)img;
|
return (patch_t *)img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,6 +688,41 @@ static UINT8 *PNG_RawConvert(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topo
|
||||||
return flat;
|
return flat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert a PNG with transparency to a raw image.
|
||||||
|
static UINT16 *PNG_MaskedRawConvert(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size)
|
||||||
|
{
|
||||||
|
UINT16 *flat;
|
||||||
|
png_uint_32 x, y;
|
||||||
|
png_bytep *row_pointers = PNG_Read(png, w, h, topoffset, leftoffset, size);
|
||||||
|
png_uint_32 width = *w, height = *h;
|
||||||
|
size_t flatsize, i;
|
||||||
|
|
||||||
|
if (!row_pointers)
|
||||||
|
I_Error("PNG_MaskedRawConvert: conversion failed");
|
||||||
|
|
||||||
|
// Convert the image to 16bpp
|
||||||
|
flatsize = (width * height);
|
||||||
|
flat = Z_Malloc(flatsize * sizeof(UINT16), PU_LEVEL, NULL);
|
||||||
|
|
||||||
|
// can't memset here
|
||||||
|
for (i = 0; i < flatsize; i++)
|
||||||
|
flat[i] = 0xFF00;
|
||||||
|
|
||||||
|
for (y = 0; y < height; y++)
|
||||||
|
{
|
||||||
|
png_bytep row = row_pointers[y];
|
||||||
|
for (x = 0; x < width; x++)
|
||||||
|
{
|
||||||
|
png_bytep px = &(row[x * 4]);
|
||||||
|
if ((UINT8)px[3])
|
||||||
|
flat[((y * width) + x)] = NearestColor((UINT8)px[0], (UINT8)px[1], (UINT8)px[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(row_pointers);
|
||||||
|
|
||||||
|
return flat;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_PNGToFlat
|
// R_PNGToFlat
|
||||||
//
|
//
|
||||||
|
@ -692,16 +738,16 @@ UINT8 *R_PNGToFlat(UINT16 *width, UINT16 *height, UINT8 *png, size_t size)
|
||||||
//
|
//
|
||||||
// Convert a PNG to a patch.
|
// Convert a PNG to a patch.
|
||||||
//
|
//
|
||||||
patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize, boolean transparency)
|
patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize)
|
||||||
{
|
{
|
||||||
UINT16 width, height;
|
UINT16 width, height;
|
||||||
INT16 topoffset = 0, leftoffset = 0;
|
INT16 topoffset = 0, leftoffset = 0;
|
||||||
UINT8 *raw = PNG_RawConvert(png, &width, &height, &topoffset, &leftoffset, size);
|
UINT16 *raw = PNG_MaskedRawConvert(png, &width, &height, &topoffset, &leftoffset, size);
|
||||||
|
|
||||||
if (!raw)
|
if (!raw)
|
||||||
I_Error("R_PNGToPatch: conversion failed");
|
I_Error("R_PNGToPatch: conversion failed");
|
||||||
|
|
||||||
return R_FlatToPatch(raw, width, height, leftoffset, topoffset, destsize, transparency);
|
return R_MaskedFlatToPatch(raw, width, height, leftoffset, topoffset, destsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1168,7 +1214,7 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
rawsrc[i] = 0xFF00;
|
rawsrc[i] = 0xFF00;
|
||||||
|
|
||||||
R_PatchToFlat_16bpp(patch, rawsrc, bflip);
|
R_PatchToMaskedFlat(patch, rawsrc, bflip);
|
||||||
|
|
||||||
// Don't cache angle = 0
|
// Don't cache angle = 0
|
||||||
for (angle = 1; angle < ROTANGLES; angle++)
|
for (angle = 1; angle < ROTANGLES; angle++)
|
||||||
|
@ -1264,7 +1310,7 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp
|
||||||
}
|
}
|
||||||
|
|
||||||
// make patch
|
// make patch
|
||||||
newpatch = R_FlatToPatch_16bpp(rawdst, newwidth, newheight, &size);
|
newpatch = R_MaskedFlatToPatch(rawdst, newwidth, newheight, 0, 0, &size);
|
||||||
{
|
{
|
||||||
newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px);
|
newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px);
|
||||||
newpatch->topoffset = (newpatch->height / 2) + (patch->topoffset - py);
|
newpatch->topoffset = (newpatch->height / 2) + (patch->topoffset - py);
|
||||||
|
@ -1280,9 +1326,11 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
if (rendermode == render_opengl)
|
if (rendermode == render_opengl)
|
||||||
{
|
{
|
||||||
GLPatch_t *grPatch = HWR_GetCachedGLRotSprite(sprframe->rotsprite.hardware_patch[rot], angle, newpatch);
|
GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
|
||||||
HWR_MakePatch(newpatch, grPatch, grPatch->mipmap, false);
|
grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
|
||||||
|
grPatch->rawpatch = newpatch;
|
||||||
sprframe->rotsprite.patch[rot][angle] = (patch_t *)grPatch;
|
sprframe->rotsprite.patch[rot][angle] = (patch_t *)grPatch;
|
||||||
|
HWR_MakePatch(newpatch, grPatch, grPatch->mipmap, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif // HWRENDER
|
#endif // HWRENDER
|
||||||
|
|
|
@ -45,9 +45,9 @@ typedef struct
|
||||||
boolean R_CheckIfPatch(lumpnum_t lump);
|
boolean R_CheckIfPatch(lumpnum_t lump);
|
||||||
void R_TextureToFlat(size_t tex, UINT8 *flat);
|
void R_TextureToFlat(size_t tex, UINT8 *flat);
|
||||||
void R_PatchToFlat(patch_t *patch, UINT8 *flat);
|
void R_PatchToFlat(patch_t *patch, UINT8 *flat);
|
||||||
void R_PatchToFlat_16bpp(patch_t *patch, UINT16 *raw, boolean flip);
|
void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip);
|
||||||
patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency);
|
patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency);
|
||||||
patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, size_t *size);
|
patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize);
|
||||||
|
|
||||||
// Portable Network Graphics
|
// Portable Network Graphics
|
||||||
boolean R_IsLumpPNG(const UINT8 *d, size_t s);
|
boolean R_IsLumpPNG(const UINT8 *d, size_t s);
|
||||||
|
@ -55,7 +55,7 @@ boolean R_IsLumpPNG(const UINT8 *d, size_t s);
|
||||||
|
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
UINT8 *R_PNGToFlat(UINT16 *width, UINT16 *height, UINT8 *png, size_t size);
|
UINT8 *R_PNGToFlat(UINT16 *width, UINT16 *height, UINT8 *png, size_t size);
|
||||||
patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize, boolean transparency);
|
patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize);
|
||||||
boolean R_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size);
|
boolean R_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -125,9 +125,6 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch
|
||||||
sprtemp[frame].rotsprite.cached[r] = false;
|
sprtemp[frame].rotsprite.cached[r] = false;
|
||||||
for (ang = 0; ang < ROTANGLES; ang++)
|
for (ang = 0; ang < ROTANGLES; ang++)
|
||||||
sprtemp[frame].rotsprite.patch[r][ang] = NULL;
|
sprtemp[frame].rotsprite.patch[r][ang] = NULL;
|
||||||
#ifdef HWRENDER
|
|
||||||
sprtemp[frame].rotsprite.hardware_patch[r] = M_AATreeAlloc(AATREE_ZUSER);
|
|
||||||
#endif/*HWRENDER*/
|
|
||||||
}
|
}
|
||||||
#endif/*ROTSPRITE*/
|
#endif/*ROTSPRITE*/
|
||||||
|
|
||||||
|
@ -284,7 +281,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef,
|
||||||
// lump is a png so convert it
|
// lump is a png so convert it
|
||||||
if (R_IsLumpPNG((UINT8 *)png, len))
|
if (R_IsLumpPNG((UINT8 *)png, len))
|
||||||
{
|
{
|
||||||
png = R_PNGToPatch((UINT8 *)png, len, NULL, true);
|
png = R_PNGToPatch((UINT8 *)png, len, NULL);
|
||||||
M_Memcpy(&patch, png, sizeof(INT16)*4);
|
M_Memcpy(&patch, png, sizeof(INT16)*4);
|
||||||
}
|
}
|
||||||
Z_Free(png);
|
Z_Free(png);
|
||||||
|
|
33
src/w_wad.c
33
src/w_wad.c
|
@ -1465,6 +1465,21 @@ boolean W_IsPatchCached(lumpnum_t lumpnum, void *ptr)
|
||||||
return W_IsPatchCachedPWAD(WADFILENUM(lumpnum),LUMPNUM(lumpnum), ptr);
|
return W_IsPatchCachedPWAD(WADFILENUM(lumpnum),LUMPNUM(lumpnum), ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void W_FlushCachedPatches(void)
|
||||||
|
{
|
||||||
|
if (needpatchflush)
|
||||||
|
{
|
||||||
|
Z_FreeTag(PU_CACHE);
|
||||||
|
Z_FreeTag(PU_PATCH);
|
||||||
|
Z_FreeTag(PU_HUDGFX);
|
||||||
|
Z_FreeTag(PU_HWRPATCHINFO);
|
||||||
|
Z_FreeTag(PU_HWRMODELTEXTURE);
|
||||||
|
Z_FreeTag(PU_HWRCACHE);
|
||||||
|
Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRPATCHINFO_UNLOCKED);
|
||||||
|
}
|
||||||
|
needpatchflush = false;
|
||||||
|
}
|
||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
// W_CacheLumpName
|
// W_CacheLumpName
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
@ -1488,22 +1503,6 @@ void *W_CacheLumpName(const char *name, INT32 tag)
|
||||||
// Cache a patch into heap memory, convert the patch format as necessary
|
// Cache a patch into heap memory, convert the patch format as necessary
|
||||||
//
|
//
|
||||||
|
|
||||||
void W_FlushCachedPatches(void)
|
|
||||||
{
|
|
||||||
if (needpatchflush)
|
|
||||||
{
|
|
||||||
Z_FreeTag(PU_CACHE);
|
|
||||||
Z_FreeTag(PU_PATCH);
|
|
||||||
Z_FreeTag(PU_HUDGFX);
|
|
||||||
Z_FreeTag(PU_HWRPATCHINFO);
|
|
||||||
Z_FreeTag(PU_HWRMODELTEXTURE);
|
|
||||||
Z_FreeTag(PU_HWRCACHE);
|
|
||||||
Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRPATCHINFO_UNLOCKED);
|
|
||||||
}
|
|
||||||
needpatchflush = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Software-only compile cache the data without conversion
|
|
||||||
void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
|
void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
|
||||||
{
|
{
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
|
@ -1541,7 +1540,7 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
|
||||||
if (R_IsLumpPNG((UINT8 *)lumpdata, len))
|
if (R_IsLumpPNG((UINT8 *)lumpdata, len))
|
||||||
{
|
{
|
||||||
size_t newlen;
|
size_t newlen;
|
||||||
srcdata = R_PNGToPatch((UINT8 *)lumpdata, len, &newlen, true);
|
srcdata = R_PNGToPatch((UINT8 *)lumpdata, len, &newlen);
|
||||||
ptr = Z_Realloc(ptr, newlen, tag, &lumpcache[lump]);
|
ptr = Z_Realloc(ptr, newlen, tag, &lumpcache[lump]);
|
||||||
M_Memcpy(ptr, srcdata, newlen);
|
M_Memcpy(ptr, srcdata, newlen);
|
||||||
Z_Free(srcdata);
|
Z_Free(srcdata);
|
||||||
|
|
Loading…
Reference in New Issue