give those better names
This commit is contained in:
1 parent
3790782ec7
commit
ba059ec1a6
3 files changed
+87
-86
No files matched your search
+61
-61
@@ -644,117 +644,117 @@ static void HWR_CacheFlat(GLMipmap_t *glMipmap, lumpnum_t flatlumpnum)
|
||||
// Download a Doom 'flat' to the hardware cache and make it ready for use
|
||||
void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
|
||||
{
|
||||
GLMipmap_t *glmip;
|
||||
GLMipmap_t *glMipmap;
|
||||
|
||||
if (flatlumpnum == LUMPERROR)
|
||||
return;
|
||||
|
||||
glmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
|
||||
glMipmap = HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
|
||||
|
||||
glmip->colormap = colormaps;
|
||||
glMipmap->colormap = colormaps;
|
||||
|
||||
#ifdef GLENCORE
|
||||
if (!noencoremap && encoremap)
|
||||
glmip->colormap += COLORMAP_REMAPOFFSET;
|
||||
glMipmap->colormap += COLORMAP_REMAPOFFSET;
|
||||
#endif
|
||||
|
||||
if (!glmip->downloaded && !glmip->data)
|
||||
HWR_CacheFlat(glmip, flatlumpnum);
|
||||
if (!glMipmap->downloaded && !glMipmap->data)
|
||||
HWR_CacheFlat(glMipmap, flatlumpnum);
|
||||
|
||||
// If hardware does not have the texture, then call pfnSetTexture to upload it
|
||||
if (!glmip->downloaded)
|
||||
GL_SetTexture(glmip);
|
||||
HWR_SetCurrentTexture(glmip);
|
||||
if (!glMipmap->downloaded)
|
||||
GL_SetTexture(glMipmap);
|
||||
HWR_SetCurrentTexture(glMipmap);
|
||||
|
||||
// The system-memory data can be purged now.
|
||||
Z_ChangeTag(glmip->data, PU_HWRCACHE_UNLOCKED);
|
||||
Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED);
|
||||
}
|
||||
|
||||
//
|
||||
// HWR_LoadMappedPatch(): replace the skin color of the sprite in cache
|
||||
// : load it first in doom cache if not already
|
||||
//
|
||||
static void HWR_LoadMappedPatch(GLMipmap_t *glmip, GLPatch_t *gpatch)
|
||||
static void HWR_LoadMappedPatch(GLMipmap_t *glMipmap, GLPatch_t *glPatch)
|
||||
{
|
||||
if (!glmip->downloaded && !glmip->data)
|
||||
if (!glMipmap->downloaded && !glMipmap->data)
|
||||
{
|
||||
patch_t *patch = gpatch->rawpatch;
|
||||
patch_t *patch = glPatch->rawpatch;
|
||||
if (!patch)
|
||||
patch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC);
|
||||
HWR_MakePatch(patch, gpatch, glmip, true);
|
||||
patch = W_CacheLumpNumPwad(glPatch->wadnum, glPatch->lumpnum, PU_STATIC);
|
||||
HWR_MakePatch(patch, glPatch, glMipmap, true);
|
||||
|
||||
// You can't free rawpatch for some reason?
|
||||
// (Obviously I can't, sprite rotation needs that...)
|
||||
|
||||
if (!gpatch->rawpatch)
|
||||
if (!glPatch->rawpatch)
|
||||
Z_Free(patch);
|
||||
}
|
||||
|
||||
// If hardware does not have the texture, then call pfnSetTexture to upload it
|
||||
if (!glmip->downloaded)
|
||||
GL_SetTexture(glmip);
|
||||
HWR_SetCurrentTexture(glmip);
|
||||
if (!glMipmap->downloaded)
|
||||
GL_SetTexture(glMipmap);
|
||||
HWR_SetCurrentTexture(glMipmap);
|
||||
|
||||
// The system-memory data can be purged now.
|
||||
Z_ChangeTag(glmip->data, PU_HWRCACHE_UNLOCKED);
|
||||
Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED);
|
||||
}
|
||||
|
||||
// -----------------+
|
||||
// HWR_GetPatch : Download a patch to the hardware cache and make it ready for use
|
||||
// HWR_GetPatch : Downloads a patch to the hardware cache and make it ready for use
|
||||
// -----------------+
|
||||
void HWR_GetPatch(GLPatch_t *gpatch)
|
||||
void HWR_GetPatch(GLPatch_t *glPatch)
|
||||
{
|
||||
// is it in hardware cache
|
||||
if (!gpatch->mipmap->downloaded && !gpatch->mipmap->data)
|
||||
if (!glPatch->mipmap->downloaded && !glPatch->mipmap->data)
|
||||
{
|
||||
// load the software patch, PU_STATIC or the Z_Malloc for hardware patch will
|
||||
// flush the software patch before the conversion! oh yeah I suffered
|
||||
patch_t *ptr = gpatch->rawpatch;
|
||||
patch_t *ptr = glPatch->rawpatch;
|
||||
if (!ptr)
|
||||
ptr = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC);
|
||||
HWR_MakePatch(ptr, gpatch, gpatch->mipmap, true);
|
||||
ptr = W_CacheLumpNumPwad(glPatch->wadnum, glPatch->lumpnum, PU_STATIC);
|
||||
HWR_MakePatch(ptr, glPatch, glPatch->mipmap, true);
|
||||
|
||||
// this is inefficient.. but the hardware patch in heap is purgeable so it should
|
||||
// not fragment memory, and besides the REAL cache here is the hardware memory
|
||||
if (!gpatch->rawpatch)
|
||||
if (!glPatch->rawpatch)
|
||||
Z_Free(ptr);
|
||||
}
|
||||
|
||||
// If hardware does not have the texture, then call pfnSetTexture to upload it
|
||||
if (!gpatch->mipmap->downloaded)
|
||||
GL_SetTexture(gpatch->mipmap);
|
||||
HWR_SetCurrentTexture(gpatch->mipmap);
|
||||
if (!glPatch->mipmap->downloaded)
|
||||
GL_SetTexture(glPatch->mipmap);
|
||||
HWR_SetCurrentTexture(glPatch->mipmap);
|
||||
|
||||
// The system-memory patch data can be purged now.
|
||||
Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
|
||||
Z_ChangeTag(glPatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
|
||||
}
|
||||
|
||||
|
||||
// -------------------+
|
||||
// HWR_GetMappedPatch : Same as HWR_GetPatch for sprite color
|
||||
// -------------------+
|
||||
void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap)
|
||||
void HWR_GetMappedPatch(GLPatch_t *glPatch, const UINT8 *colormap)
|
||||
{
|
||||
GLMipmap_t *glmip, *newmip;
|
||||
GLMipmap_t *glMipmap, *newMipmap;
|
||||
|
||||
// Blatant hack for encore colormapping aside...
|
||||
if (colormap == colormaps || colormap == NULL || colormap == (const UINT8*)(COLORMAP_REMAPOFFSET))
|
||||
{
|
||||
// Load the default (green) color in doom cache (temporary?) AND hardware cache
|
||||
HWR_GetPatch(gpatch);
|
||||
HWR_GetPatch(glPatch);
|
||||
return;
|
||||
}
|
||||
|
||||
// search for the mimmap
|
||||
// search for the mipmap
|
||||
// skip the first (no colormap translated)
|
||||
for (glmip = gpatch->mipmap; glmip->nextcolormap; )
|
||||
for (glMipmap = glPatch->mipmap; glMipmap->nextcolormap; )
|
||||
{
|
||||
glmip = glmip->nextcolormap;
|
||||
glMipmap = glMipmap->nextcolormap;
|
||||
|
||||
if (glmip->colormap != colormap)
|
||||
if (!glMipmap->colormap)
|
||||
continue;
|
||||
|
||||
HWR_LoadMappedPatch(glmip, gpatch);
|
||||
HWR_LoadMappedPatch(glMipmap, glPatch);
|
||||
return;
|
||||
}
|
||||
// not found, create it!
|
||||
@@ -764,38 +764,38 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap)
|
||||
// (it have a liste of mipmap)
|
||||
// this malloc is cleared in HWR_FreeTextureCache
|
||||
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
|
||||
newmip = calloc(1, sizeof (*newmip));
|
||||
if (newmip == NULL)
|
||||
newMipmap = calloc(1, sizeof (*newMipmap));
|
||||
if (newMipmap == NULL)
|
||||
I_Error("%s: Out of memory", "HWR_GetMappedPatch");
|
||||
glmip->nextcolormap = newmip;
|
||||
glMipmap->nextcolormap = newMipmap;
|
||||
|
||||
newmip->colormap = colormap;
|
||||
HWR_LoadMappedPatch(newmip, gpatch);
|
||||
newMipmap->colormap = colormap;
|
||||
HWR_LoadMappedPatch(newMipmap, glPatch);
|
||||
}
|
||||
|
||||
void HWR_UnlockCachedPatch(GLPatch_t *gpatch)
|
||||
void HWR_UnlockCachedPatch(GLPatch_t *glPatch)
|
||||
{
|
||||
if (!gpatch)
|
||||
if (!glPatch)
|
||||
return;
|
||||
|
||||
Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
|
||||
Z_ChangeTag(glPatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
|
||||
}
|
||||
|
||||
GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum)
|
||||
{
|
||||
aatree_t *hwrcache = wadfiles[wadnum]->hwrcache;
|
||||
GLPatch_t *glpatch;
|
||||
GLPatch_t *glPatch;
|
||||
|
||||
if (!(glpatch = M_AATreeGet(hwrcache, lumpnum)))
|
||||
if (!(glPatch = M_AATreeGet(hwrcache, lumpnum)))
|
||||
{
|
||||
glpatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
|
||||
glpatch->wadnum = wadnum;
|
||||
glpatch->lumpnum = lumpnum;
|
||||
glpatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
|
||||
M_AATreeSet(hwrcache, lumpnum, glpatch);
|
||||
glPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL);
|
||||
glPatch->wadnum = wadnum;
|
||||
glPatch->lumpnum = lumpnum;
|
||||
glPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL);
|
||||
M_AATreeSet(hwrcache, lumpnum, glPatch);
|
||||
}
|
||||
|
||||
return glpatch;
|
||||
return glPatch;
|
||||
}
|
||||
|
||||
GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum)
|
||||
@@ -890,17 +890,17 @@ static void HWR_CacheFadeMask(GLMipmap_t *glMipmap, lumpnum_t fademasklumpnum)
|
||||
|
||||
void HWR_GetFadeMask(lumpnum_t fademasklumpnum)
|
||||
{
|
||||
GLMipmap_t *glmip;
|
||||
GLMipmap_t *glMipmap;
|
||||
|
||||
glmip = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap;
|
||||
glMipmap = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap;
|
||||
|
||||
if (!glmip->downloaded && !glmip->data)
|
||||
HWR_CacheFadeMask(glmip, fademasklumpnum);
|
||||
if (!glMipmap->downloaded && !glMipmap->data)
|
||||
HWR_CacheFadeMask(glMipmap, fademasklumpnum);
|
||||
|
||||
GL_SetTexture(glmip);
|
||||
GL_SetTexture(glMipmap);
|
||||
|
||||
// The system-memory data can be purged now.
|
||||
Z_ChangeTag(glmip->data, PU_HWRCACHE_UNLOCKED);
|
||||
Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED);
|
||||
}
|
||||
|
||||
// =================================================
|
||||
|
||||
@@ -4947,7 +4947,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
|
||||
return;
|
||||
#endif
|
||||
|
||||
sprframe = &sprdef->spriteframes[ thing->frame & FF_FRAMEMASK];
|
||||
sprframe = &sprdef->spriteframes[thing->frame & FF_FRAMEMASK];
|
||||
|
||||
// use single rotation for all views
|
||||
lumpoff = sprframe->lumpid[0];
|
||||
|
||||
+25
-24
@@ -681,7 +681,7 @@ spritemd2found:
|
||||
#define SETBRIGHTNESS(brightness,r,g,b) \
|
||||
brightness = (UINT8)(((1063*(UINT32)(r))/5000) + ((3576*(UINT32)(g))/5000) + ((361*(UINT32)(b))/5000))
|
||||
|
||||
static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *glmip, INT32 skinnum, skincolors_t color)
|
||||
static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *glMipmap, INT32 skinnum, skincolors_t color)
|
||||
{
|
||||
UINT16 w = gpatch->width, h = gpatch->height;
|
||||
UINT32 size = w*h;
|
||||
@@ -697,24 +697,24 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch,
|
||||
memset(translation, 0, sizeof(translation));
|
||||
memset(cutoff, 0, sizeof(cutoff));
|
||||
|
||||
if (glmip->width == 0)
|
||||
if (glMipmap->width == 0)
|
||||
{
|
||||
glmip->width = gpatch->width;
|
||||
glmip->height = gpatch->height;
|
||||
glMipmap->width = gpatch->width;
|
||||
glMipmap->height = gpatch->height;
|
||||
|
||||
// no wrap around, no chroma key
|
||||
glmip->flags = 0;
|
||||
glMipmap->flags = 0;
|
||||
// setup the texture info
|
||||
glmip->format = GL_TEXFMT_RGBA;
|
||||
glMipmap->format = GL_TEXFMT_RGBA;
|
||||
}
|
||||
|
||||
if (glmip->data)
|
||||
if (glMipmap->data)
|
||||
{
|
||||
Z_Free(glmip->data);
|
||||
glmip->data = NULL;
|
||||
Z_Free(glMipmap->data);
|
||||
glMipmap->data = NULL;
|
||||
}
|
||||
|
||||
cur = Z_Malloc(size*4, PU_HWRCACHE, &glmip->data);
|
||||
cur = Z_Malloc(size*4, PU_HWRCACHE, &glMipmap->data);
|
||||
memset(cur, 0x00, size*4);
|
||||
|
||||
image = gpatch->mipmap->data;
|
||||
@@ -1044,7 +1044,7 @@ skippixel:
|
||||
static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT32 skinnum, const UINT8 *colormap, skincolors_t color)
|
||||
{
|
||||
// mostly copied from HWR_GetMappedPatch, hence the similarities and comment
|
||||
GLMipmap_t *glmip, *newmip;
|
||||
GLMipmap_t *glMipmap, *newMipmap;
|
||||
|
||||
if (colormap == colormaps || colormap == NULL)
|
||||
{
|
||||
@@ -1055,15 +1055,16 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
|
||||
|
||||
// search for the mimmap
|
||||
// skip the first (no colormap translated)
|
||||
for (glmip = gpatch->mipmap; glmip->nextcolormap; )
|
||||
for (glMipmap = gpatch->mipmap; glMipmap->nextcolormap; )
|
||||
{
|
||||
glmip = glmip->nextcolormap;
|
||||
if (glmip->colormap == colormap)
|
||||
glMipmap = glMipmap->nextcolormap;
|
||||
|
||||
if (glMipmap->colormap)
|
||||
{
|
||||
if (glmip->downloaded && glmip->data)
|
||||
if (glMipmap->downloaded && glMipmap->data)
|
||||
{
|
||||
GL_SetTexture(glmip); // found the colormap, set it to the correct texture
|
||||
Z_ChangeTag(glmip->data, PU_HWRCACHE_UNLOCKED);
|
||||
GL_SetTexture(glMipmap); // found the colormap, set it to the correct texture
|
||||
Z_ChangeTag(glMipmap->data, PU_HWRCACHE_UNLOCKED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1076,16 +1077,16 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT
|
||||
// (it have a liste of mipmap)
|
||||
// this malloc is cleared in HWR_FreeTextureCache
|
||||
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
|
||||
newmip = calloc(1, sizeof (*newmip));
|
||||
if (newmip == NULL)
|
||||
newMipmap = calloc(1, sizeof (*newMipmap));
|
||||
if (newMipmap == NULL)
|
||||
I_Error("%s: Out of memory", "HWR_GetMappedPatch");
|
||||
glmip->nextcolormap = newmip;
|
||||
newmip->colormap = colormap;
|
||||
glMipmap->nextcolormap = newMipmap;
|
||||
newMipmap->colormap = colormap;
|
||||
|
||||
HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, skinnum, color);
|
||||
HWR_CreateBlendedTexture(gpatch, blendgpatch, newMipmap, skinnum, color);
|
||||
|
||||
GL_SetTexture(newmip);
|
||||
Z_ChangeTag(newmip->data, PU_HWRCACHE_UNLOCKED);
|
||||
GL_SetTexture(newMipmap);
|
||||
Z_ChangeTag(newMipmap->data, PU_HWRCACHE_UNLOCKED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user