Commit 91ed56ef by Jaime Ita Passos

Refactor patch loading

parent cc677d2d
......@@ -1555,7 +1555,7 @@ static void CON_DrawBackpic(void)
// then fill the sides with a solid color.
if (x > 0)
{
column_t *column = (column_t *)((UINT8 *)(con_backpic) + LONG(con_backpic->columnofs[0]));
column_t *column = (column_t *)((UINT8 *)(con_backpic->columns) + (con_backpic->columnofs[0]));
if (!column->topdelta)
{
UINT8 *source = (UINT8 *)(column) + 3;
......@@ -1648,9 +1648,6 @@ void CON_Drawer(void)
if (!con_started || !graphics_started)
return;
if (needpatchrecache)
HU_LoadGraphics();
if (con_recalc)
{
CON_RecalcSize();
......
......@@ -110,8 +110,6 @@ boolean devparm = false; // started game with -devparm
boolean singletics = false; // timedemo
boolean lastdraw = false;
static void D_CheckRendererState(void);
postimg_t postimgtype = postimg_none;
INT32 postimgparam;
postimg_t postimgtype2 = postimg_none;
......@@ -245,9 +243,7 @@ static void D_Display(void)
// create plane polygons, if necessary.
// 3. Functions related to switching video
// modes (resolution) are called.
// 4. Patch data is freed from memory,
// and recached if necessary.
// 5. The frame is ready to be drawn!
// 4. The frame is ready to be drawn!
// stop movie if needs to change renderer
if (setrenderneeded && (moviemode == MM_APNG))
......@@ -284,9 +280,6 @@ static void D_Display(void)
forcerefresh = true; // force background redraw
}
// Lactozilla: Renderer switching
D_CheckRendererState();
// draw buffered stuff to screen
// Used only by linux GGI version
I_UpdateNoBlit();
......@@ -679,26 +672,6 @@ static void D_Display(void)
I_FinishUpdate(); // page flip or blit buffer
rs_swaptime = I_GetTimeMicros() - rs_swaptime;
}
needpatchflush = false;
needpatchrecache = false;
}
// Check the renderer's state
// after a possible renderer switch.
void D_CheckRendererState(void)
{
// flush all patches from memory
if (needpatchflush)
{
Z_FlushCachedPatches();
needpatchflush = false;
}
// some patches have been freed,
// so cache them again
if (needpatchrecache)
R_ReloadHUDGraphics();
}
// =========================================================================
......@@ -1433,18 +1406,10 @@ void D_SRB2Main(void)
if ((setrenderneeded != 0) && (setrenderneeded != rendermode))
{
CONS_Printf(M_GetText("Switching the renderer...\n"));
Z_PreparePatchFlush();
// set needpatchflush / needpatchrecache true for D_CheckRendererState
needpatchflush = true;
needpatchrecache = true;
// Set cv_renderer to the new render mode
VID_CheckRenderer();
SCR_ChangeRendererCVars(rendermode);
// check the renderer's state
D_CheckRendererState();
}
wipegamestate = gamestate;
......
......@@ -1046,7 +1046,7 @@ static void readspriteinfo(MYFILE *f, INT32 num, boolean sprite2)
#ifdef ROTSPRITE
if ((sprites != NULL) && (!sprite2))
R_FreeSingleRotSprite(&sprites[num]);
R_FreeRotSprite(&sprites[num]);
#endif
do
......
......@@ -1901,13 +1901,6 @@ void F_EndingDrawer(void)
INT32 x, y, i, j, parallaxticker;
patch_t *rockpat;
if (needpatchrecache)
{
F_CacheEnding();
if (goodending && finalecount >= INFLECTIONPOINT) // time to swap some assets
F_CacheGoodEnding();
}
if (!goodending || finalecount < INFLECTIONPOINT)
rockpat = W_CachePatchName("ROID0000", PU_PATCH);
else
......@@ -2706,17 +2699,12 @@ static void F_FigureActiveTtScale(void)
SINT8 newttscale = max(1, min(6, vid.dupx));
SINT8 oldttscale = activettscale;
if (needpatchrecache)
ttloaded[0] = ttloaded[1] = ttloaded[2] = ttloaded[3] = ttloaded[4] = ttloaded[5] = 0;
else
{
if (newttscale == testttscale)
return;
if (newttscale == testttscale)
return;
// We have a new ttscale, so load gfx
if(oldttscale > 0)
F_UnloadAlacroixGraphics(oldttscale);
}
// We have a new ttscale, so load gfx
if(oldttscale > 0)
F_UnloadAlacroixGraphics(oldttscale);
testttscale = newttscale;
......@@ -2750,9 +2738,6 @@ void F_TitleScreenDrawer(void)
if (modeattacking)
return; // We likely came here from retrying. Don't do a damn thing.
if (needpatchrecache && (curttmode != TTMODE_ALACROIX))
F_CacheTitleScreen();
// Draw that sky!
if (curbgcolor >= 0)
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, curbgcolor);
......
......@@ -73,23 +73,10 @@ struct GLMapTexture_s
typedef struct GLMapTexture_s GLMapTexture_t;
// a cached patch as converted to hardware format, holding the original patch_t
// header so that the existing code can retrieve ->width, ->height as usual
// This is returned by W_CachePatchNum()/W_CachePatchName(), when rendermode
// is 'render_opengl'. Else it returns the normal patch_t data.
// a cached patch as converted to hardware format
struct GLPatch_s
{
// the 4 first fields come right away from the original patch_t
INT16 width;
INT16 height;
INT16 leftoffset; // pixels to the left of origin
INT16 topoffset; // pixels below the origin
//
float max_s,max_t;
UINT16 wadnum; // the software patch lump num for when the hardware patch
UINT16 lumpnum; // was flushed, and we need to re-create it
void *rawpatch; // :^)
GLMipmap_t *mipmap;
} ATTRPACK;
typedef struct GLPatch_s GLPatch_t;
......
......@@ -42,6 +42,7 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags);
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor);
EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo);
EXPORT void HWRAPI(UpdateTexture) (FTextureInfo *TexInfo);
EXPORT void HWRAPI(DeleteTexture) (FTextureInfo *TexInfo);
EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data);
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip);
EXPORT void HWRAPI(ClearMipMapCache) (void);
......@@ -96,6 +97,7 @@ struct hwdriver_s
ClearBuffer pfnClearBuffer;
SetTexture pfnSetTexture;
UpdateTexture pfnUpdateTexture;
DeleteTexture pfnDeleteTexture;
ReadRect pfnReadRect;
GClipRect pfnGClipRect;
ClearMipMapCache pfnClearMipMapCache;
......
......@@ -64,8 +64,7 @@ typedef struct gl_vissprite_s
float x1, x2;
float tz, ty;
float tracertz; // for MF2_LINKDRAW sprites, this contains tracer's tz for use in sorting
//lumpnum_t patchlumpnum;
GLPatch_t *gpatch;
patch_t *gpatch;
boolean flip;
UINT8 translucency; //alpha level 0-255
mobj_t *mobj; // NOTE: This is a precipmobj_t if precip is true !!! Watch out.
......@@ -86,25 +85,33 @@ extern size_t addsubsector;
void HWR_InitPolyPool(void);
void HWR_FreePolyPool(void);
void HWR_FreeExtraSubsectors(void);
// --------
// hw_cache.c
// --------
void HWR_InitTextureCache(void);
void HWR_FreeTextureCache(void);
void HWR_FreeMipmapCache(void);
void HWR_FreeExtraSubsectors(void);
patch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump);
patch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum);
void HWR_GetPatch(patch_t *patch);
void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap);
void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
patch_t *HWR_GetPic(lumpnum_t lumpnum);
GLMapTexture_t *HWR_GetTexture(INT32 tex);
void HWR_GetLevelFlat(levelflat_t *levelflat);
void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum);
GLMapTexture_t *HWR_GetTexture(INT32 tex);
void HWR_GetPatch(GLPatch_t *gpatch);
void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap);
void HWR_FreeTexture(patch_t *patch);
void HWR_FreeTextureColormaps(patch_t *patch);
void HWR_UnlockCachedPatch(GLPatch_t *gpatch);
GLPatch_t *HWR_GetPic(lumpnum_t lumpnum);
void HWR_SetPalette(RGBA_t *palette);
GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump);
GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum);
void HWR_GetFadeMask(lumpnum_t fademasklumpnum);
// --------
// hw_draw.c
......
......@@ -706,7 +706,7 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf)
{
FOutVector wallVerts[4];
wallsplat_t *splat;
GLPatch_t *gpatch;
patch_t *gpatch;
fixed_t i;
// seg bbox
fixed_t segbbox[4];
......@@ -3549,7 +3549,7 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v
static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
{
GLPatch_t *gpatch;
patch_t *gpatch;
FOutVector shadowVerts[4];
FSurfaceInfo sSurf;
float fscale; float fx; float fy; float offset;
......@@ -3575,12 +3575,12 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
if (alpha >= 255) return;
alpha = 255 - alpha;
gpatch = (GLPatch_t *)W_CachePatchName("DSHADOW", PU_CACHE);
if (!(gpatch && gpatch->mipmap->format)) return;
gpatch = (patch_t *)W_CachePatchName("DSHADOW", PU_CACHE);
if (!(gpatch && ((GLPatch_t *)gpatch->hardware)->mipmap->format)) return;
HWR_GetPatch(gpatch);
scalemul = FixedMul(FRACUNIT - floordiff/640, scale);
scalemul = FixedMul(scalemul, (thing->radius*2) / SHORT(gpatch->height));
scalemul = FixedMul(scalemul, (thing->radius*2) / gpatch->height);
fscale = FIXED_TO_FLOAT(scalemul);
fx = FIXED_TO_FLOAT(thing->x);
......@@ -3592,9 +3592,9 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
// 0--1
if (thing && fabsf(fscale - 1.0f) > 1.0E-36f)
offset = (SHORT(gpatch->height)/2) * fscale;
offset = ((gpatch->height)/2) * fscale;
else
offset = (float)(SHORT(gpatch->height)/2);
offset = (float)((gpatch->height)/2);
shadowVerts[2].x = shadowVerts[3].x = fx + offset;
shadowVerts[1].x = shadowVerts[0].x = fx - offset;
......@@ -3624,10 +3624,10 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
}
shadowVerts[0].s = shadowVerts[3].s = 0;
shadowVerts[2].s = shadowVerts[1].s = gpatch->max_s;
shadowVerts[2].s = shadowVerts[1].s = ((GLPatch_t *)gpatch->hardware)->max_s;
shadowVerts[3].t = shadowVerts[2].t = 0;
shadowVerts[0].t = shadowVerts[1].t = gpatch->max_t;
shadowVerts[0].t = shadowVerts[1].t = ((GLPatch_t *)gpatch->hardware)->max_t;
if (thing->subsector->sector->numlights)
{
......@@ -3687,7 +3687,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
float this_scale = 1.0f;
FOutVector wallVerts[4];
FOutVector baseWallVerts[4]; // This is what the verts should end up as
GLPatch_t *gpatch;
patch_t *gpatch;
FSurfaceInfo Surf;
const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES);
extracolormap_t *colormap;
......@@ -3715,7 +3715,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
if (hires)
this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)spr->mobj->skin)->highresscale);
gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE);
gpatch = spr->gpatch;
// cache the patch in the graphics card memory
//12/12/99: Hurdler: same comment as above (for md2)
......@@ -3740,25 +3740,25 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
if (spr->flip)
{
baseWallVerts[0].s = baseWallVerts[3].s = gpatch->max_s;
baseWallVerts[0].s = baseWallVerts[3].s = ((GLPatch_t *)gpatch->hardware)->max_s;
baseWallVerts[2].s = baseWallVerts[1].s = 0;
}
else
{
baseWallVerts[0].s = baseWallVerts[3].s = 0;
baseWallVerts[2].s = baseWallVerts[1].s = gpatch->max_s;
baseWallVerts[2].s = baseWallVerts[1].s = ((GLPatch_t *)gpatch->hardware)->max_s;
}
// flip the texture coords (look familiar?)
if (spr->vflip)
{
baseWallVerts[3].t = baseWallVerts[2].t = gpatch->max_t;
baseWallVerts[3].t = baseWallVerts[2].t = ((GLPatch_t *)gpatch->hardware)->max_t;
baseWallVerts[0].t = baseWallVerts[1].t = 0;
}
else
{
baseWallVerts[3].t = baseWallVerts[2].t = 0;
baseWallVerts[0].t = baseWallVerts[1].t = gpatch->max_t;
baseWallVerts[0].t = baseWallVerts[1].t = ((GLPatch_t *)gpatch->hardware)->max_t;
}
// if it has a dispoffset, push it a little towards the camera
......@@ -3963,7 +3963,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
{
float this_scale = 1.0f;
FOutVector wallVerts[4];
GLPatch_t *gpatch; // sprite patch converted to hardware
patch_t *gpatch; // sprite patch converted to hardware
FSurfaceInfo Surf;
const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES);
//const boolean papersprite = (spr->mobj && (spr->mobj->frame & FF_PAPERSPRITE));
......@@ -3990,7 +3990,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
// sure to do it the right way. So actually, we keep normal sprite
// in memory and we add the md2 model if it exists for that sprite
gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE);
gpatch = spr->gpatch;
#ifdef ALAM_LIGHTING
if (!(spr->mobj->flags2 & MF2_DEBRIS) && (spr->mobj->sprite != SPR_PLAY ||
......@@ -4021,21 +4021,21 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
if (spr->flip)
{
wallVerts[0].s = wallVerts[3].s = gpatch->max_s;
wallVerts[0].s = wallVerts[3].s = ((GLPatch_t *)gpatch->hardware)->max_s;
wallVerts[2].s = wallVerts[1].s = 0;
}else{
wallVerts[0].s = wallVerts[3].s = 0;
wallVerts[2].s = wallVerts[1].s = gpatch->max_s;
wallVerts[2].s = wallVerts[1].s = ((GLPatch_t *)gpatch->hardware)->max_s;
}
// flip the texture coords (look familiar?)
if (spr->vflip)
{
wallVerts[3].t = wallVerts[2].t = gpatch->max_t;
wallVerts[3].t = wallVerts[2].t = ((GLPatch_t *)gpatch->hardware)->max_t;
wallVerts[0].t = wallVerts[1].t = 0;
}else{
wallVerts[3].t = wallVerts[2].t = 0;
wallVerts[0].t = wallVerts[1].t = gpatch->max_t;
wallVerts[0].t = wallVerts[1].t = ((GLPatch_t *)gpatch->hardware)->max_t;
}
// cache the patch in the graphics card memory
......@@ -4121,7 +4121,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
{
FBITFIELD blend = 0;
FOutVector wallVerts[4];
GLPatch_t *gpatch; // sprite patch converted to hardware
patch_t *gpatch; // sprite patch converted to hardware
FSurfaceInfo Surf;
if (!spr->mobj)
......@@ -4131,7 +4131,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
return;
// cache sprite graphics
gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE);
gpatch = spr->gpatch;
// create the sprite billboard
//
......@@ -4153,10 +4153,10 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
HWR_RotateSpritePolyToAim(spr, wallVerts, true);
wallVerts[0].s = wallVerts[3].s = 0;
wallVerts[2].s = wallVerts[1].s = gpatch->max_s;
wallVerts[2].s = wallVerts[1].s = ((GLPatch_t *)gpatch->hardware)->max_s;
wallVerts[3].t = wallVerts[2].t = 0;
wallVerts[0].t = wallVerts[1].t = gpatch->max_t;
wallVerts[0].t = wallVerts[1].t = ((GLPatch_t *)gpatch->hardware)->max_t;
// cache the patch in the graphics card memory
//12/12/99: Hurdler: same comment as above (for md2)
......@@ -5014,13 +5014,12 @@ static void HWR_ProjectSprite(mobj_t *thing)
vis->tz = tz; // Keep tz for the simple sprite sorting that happens
vis->tracertz = tracertz;
vis->dispoffset = dispoffset; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST
//vis->patchlumpnum = sprframe->lumppat[rot];
#ifdef ROTSPRITE
if (rotsprite)
vis->gpatch = (GLPatch_t *)rotsprite;
vis->gpatch = (patch_t *)rotsprite;
else
#endif
vis->gpatch = (GLPatch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE);
vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE);
vis->flip = flip;
vis->mobj = thing;
vis->z1 = z1;
......@@ -5155,8 +5154,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
vis->z2 = z2;
vis->tz = tz;
vis->dispoffset = 0; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST
//vis->patchlumpnum = sprframe->lumppat[rot];
vis->gpatch = (GLPatch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE);
vis->gpatch = (patch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE);
vis->flip = flip;
vis->mobj = (mobj_t *)thing;
......
......@@ -35,9 +35,9 @@ void HWR_DrawViewBorder(INT32 clearlines);
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum);
void HWR_InitTextureMapping(void);
void HWR_SetViewSize(void);
void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option);
void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap);
void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t scale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h);
void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option);
void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap);
void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t scale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h);
void HWR_MakePatch(const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap);
void HWR_CreatePlanePolygons(INT32 bspnum);
void HWR_CreateStaticLightmaps(INT32 bspnum);
......
......@@ -1318,6 +1318,17 @@ void SetStates(void)
// -----------------+
// DeleteTexture : Deletes a texture from the GPU and frees its data
// -----------------+
EXPORT void HWRAPI(DeleteTexture) (FTextureInfo *pTexInfo)
{
if (pTexInfo->downloaded)
pglDeleteTextures(1, (GLuint *)&pTexInfo->downloaded);
pTexInfo->downloaded = 0;
}
// -----------------+
// Flush : flush OpenGL textures
// : Clear list of downloaded mipmaps
// -----------------+
......@@ -1327,9 +1338,7 @@ void Flush(void)
while (gl_cachehead)
{
if (gl_cachehead->downloaded)
pglDeleteTextures(1, (GLuint *)&gl_cachehead->downloaded);
gl_cachehead->downloaded = 0;
DeleteTexture(gl_cachehead);
gl_cachehead = gl_cachehead->nextmipmap;
}
gl_cachetail = gl_cachehead = NULL; //Hurdler: well, gl_cachehead is already NULL
......
......@@ -2038,9 +2038,6 @@ static void HU_DrawDemoInfo(void)
//
void HU_Drawer(void)
{
if (needpatchrecache)
R_ReloadHUDGraphics();
#ifndef NONET
// draw chat string plus cursor
if (chat_on)
......
......@@ -379,7 +379,7 @@ static int lib_setSpriteInfo(lua_State *L)
return luaL_error(L, "spriteinfo[] index %d out of range (1 - %d)", i, NUMSPRITES-1);
#ifdef ROTSPRITE
if (sprites != NULL)
R_FreeSingleRotSprite(&sprites[i]);
R_FreeRotSprite(&sprites[i]);
#endif
info = &spriteinfo[i]; // get the spriteinfo to assign to.
}
......@@ -464,7 +464,7 @@ static int spriteinfo_set(lua_State *L)
#ifdef ROTSPRITE
if (sprites != NULL)
R_FreeSingleRotSprite(&sprites[sprinfo-spriteinfo]);
R_FreeRotSprite(&sprites[sprinfo-spriteinfo]);
#endif
if (fastcmp(field, "pivot"))
......
......@@ -1490,7 +1490,7 @@ static menuitem_t OP_SoundOptionsMenu[] =
{IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 36},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "MIDI Music Volume", &cv_midimusicvolume, 41},
{IT_STRING | IT_CVAR, NULL, "Music Preference", &cv_musicpref, 51},
{IT_HEADER, NULL, "Miscellaneous", NULL, 61},
......@@ -5593,9 +5593,6 @@ static void M_DrawLevelPlatterWideMap(UINT8 row, UINT8 col, INT32 x, INT32 y, bo
if (map <= 0)
return;
if (needpatchrecache)
M_CacheLevelPlatter();
// A 564x100 image of the level as entry MAPxxW
if (!(levelselect.rows[row].mapavailable[col]))
{
......@@ -5627,9 +5624,6 @@ static void M_DrawLevelPlatterMap(UINT8 row, UINT8 col, INT32 x, INT32 y, boolea
if (map <= 0)
return;
if (needpatchrecache)
M_CacheLevelPlatter();
// A 160x100 image of the level as entry MAPxxP
if (!(levelselect.rows[row].mapavailable[col]))
{
......@@ -6452,10 +6446,6 @@ static void M_DrawAddons(void)
return;
}
// Lactozilla: Load addons menu patches.
if (needpatchrecache)
M_LoadAddonsPatches();
if (Playing())
V_DrawCenteredString(BASEVIDWIDTH/2, 5, warningflags, "Adding files mid-game may cause problems.");
else
......@@ -7610,9 +7600,6 @@ static void M_DrawSoundTest(void)
fixed_t hscale = FRACUNIT/2, vscale = FRACUNIT/2, bounce = 0;
UINT8 frame[4] = {0, 0, -1, SKINCOLOR_RUBY};
if (needpatchrecache)
M_CacheSoundTest();
// let's handle the ticker first. ideally we'd tick this somewhere else, BUT...
if (curplaying)
{
......@@ -8260,9 +8247,6 @@ static void M_DrawLoadGameData(void)
if (vid.width != BASEVIDWIDTH*vid.dupx)
hsep = (hsep*vid.width)/(BASEVIDWIDTH*vid.dupx);
if (needpatchrecache)
M_CacheLoadGameData();
for (i = -2; i <= 2; i++)
{
savetodraw = (saveSlotSelected + i + numsaves)%numsaves;
......@@ -8966,7 +8950,6 @@ void M_ForceSaveSlotSelected(INT32 sslot)
// CHARACTER SELECT
// ================
// lactozilla: sometimes the renderer changes and these patches don't exist anymore
static void M_CacheCharacterSelectEntry(INT32 i, INT32 skinnum)
{
if (!(description[i].picname[0]))
......@@ -8987,22 +8970,6 @@ static void M_CacheCharacterSelectEntry(INT32 i, INT32 skinnum)
description[i].namepic = W_CachePatchName(description[i].nametag, PU_PATCH);
}
static void M_CacheCharacterSelect(void)
{
INT32 i, skinnum;
for (i = 0; i < MAXSKINS; i++)
{
if (!description[i].used)
continue;
// Already set in M_SetupChoosePlayer
skinnum = description[i].skinnum[0];
if ((skinnum != -1) && (R_SkinUsable(-1, skinnum)))
M_CacheCharacterSelectEntry(i, skinnum);
}
}
static UINT8 M_SetupChoosePlayerDirect(INT32 choice)
{
INT32 skinnum;
......@@ -9209,10 +9176,6 @@ static void M_DrawSetupChoosePlayerMenu(void)
INT32 x, y;
INT32 w = (vid.width/vid.dupx);
// lactozilla: the renderer changed so recache patches
if (needpatchrecache)
M_CacheCharacterSelect();
if (abs(char_scroll) > FRACUNIT)
char_scroll -= (char_scroll>>2);
else // close enough.
......@@ -10584,10 +10547,6 @@ void M_DrawMarathon(void)
angle_t fa;
INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy), xspan = (vid.width/dupz), yspan = (vid.height/dupz), diffx = (xspan - BASEVIDWIDTH)/2, diffy = (yspan - BASEVIDHEIGHT)/2, maxy = BASEVIDHEIGHT + diffy;
// lactozilla: the renderer changed so recache patches
if (needpatchrecache)
M_CacheCharacterSelect();
curbgxspeed = 0;
curbgyspeed = 18;
......
......@@ -482,7 +482,7 @@ static UINT8 *R_GenerateTexture(size_t texnum)
UINT8 *blocktex;
texture_t *texture;
texpatch_t *patch;
patch_t *realpatch;
softwarepatch_t *realpatch;
UINT8 *pdata;
int x, x1, x2, i, width, height;
size_t blocksize;
......@@ -512,7 +512,7 @@ static UINT8 *R_GenerateTexture(size_t texnum)
lumpnum = patch->lump;
lumplength = W_LumpLengthPwad(wadnum, lumpnum);
pdata = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
realpatch = (patch_t *)pdata;
realpatch = (softwarepatch_t *)pdata;
#ifndef NO_PNG_LUMPS
if (R_IsLumpPNG((UINT8 *)realpatch, lumplength))
......@@ -608,7 +608,7 @@ static UINT8 *R_GenerateTexture(size_t texnum)
lumpnum = patch->lump;
pdata = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE);
lumplength = W_LumpLengthPwad(wadnum, lumpnum);
realpatch = (patch_t *)pdata;
realpatch = (softwarepatch_t *)pdata;
dealloc = true;
#ifndef NO_PNG_LUMPS
......
......@@ -652,16 +652,26 @@ typedef enum
RGBA32 = 4, // 32 bit rgba
} pic_mode_t;
#if defined(_MSC_VER)
#pragma pack(1)
#endif
// Patches.
// A patch holds one or more columns.
// Patches are used for sprites and all masked pictures, and we compose
// textures from the TEXTURES list of patches.
//
// WARNING: this structure is cloned in GLPatch_t
typedef struct
{
INT16 width, height;
INT16 leftoffset, topoffset;
INT32 *columnofs; // Column offsets. This is relative to patch->columns
UINT8 *columns; // Software column data
void *hardware; // OpenGL patch, allocated whenever necessary
} patch_t;
#if defined(_MSC_VER)
#pragma pack(1)
#endif
typedef struct
{
INT16 width; // bounding box size
......@@ -670,7 +680,7 @@ typedef struct
INT16 topoffset; // pixels below the origin
INT32 columnofs[8]; // only [width] used
// the [0] is &columnofs[width]
} ATTRPACK patch_t;
} ATTRPACK softwarepatch_t;
#ifdef _MSC_VER
#pragma warning(disable : 4200)
......
......@@ -1572,14 +1572,6 @@ void R_InitHardwareMode(void)
}
#endif
void R_ReloadHUDGraphics(void)
{
CONS_Debug(DBG_RENDER, "R_ReloadHUDGraphics()...\n");
ST_LoadGraphics();
HU_LoadGraphics();
ST_ReloadSkinFaceGraphics();
}
// =========================================================================
// ENGINE COMMANDS & VARS
// =========================================================================
......