mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Fix OpenGL
This commit is contained in:
parent
c2cd9a71fa
commit
1904e3b5e9
4 changed files with 110 additions and 65 deletions
|
@ -97,6 +97,7 @@ static void CON_InputInit(void);
|
|||
static void CON_RecalcSize(void);
|
||||
static void CON_ChangeHeight(void);
|
||||
|
||||
static void CON_DrawBackpic(void);
|
||||
static void CONS_hudlines_Change(void);
|
||||
static void CONS_backcolor_Change(void);
|
||||
|
||||
|
@ -1530,6 +1531,51 @@ static void CON_DrawHudlines(void)
|
|||
con_clearlines = y; // this is handled by HU_Erase();
|
||||
}
|
||||
|
||||
// Lactozilla: Draws the console's background picture.
|
||||
static void CON_DrawBackpic(void)
|
||||
{
|
||||
patch_t *con_backpic;
|
||||
lumpnum_t piclump;
|
||||
int x, w, h;
|
||||
|
||||
// Get the lumpnum for CONSBACK, or fallback into MISSING.
|
||||
piclump = W_CheckNumForName("CONSBACK");
|
||||
if (piclump == LUMPERROR)
|
||||
piclump = W_GetNumForName("MISSING");
|
||||
|
||||
// Cache the Software patch.
|
||||
con_backpic = W_CacheSoftwarePatchNum(piclump, PU_PATCH);
|
||||
|
||||
// Center the backpic, and draw a vertically cropped patch.
|
||||
w = (con_backpic->width * vid.dupx);
|
||||
x = (vid.width / 2) - (w / 2);
|
||||
h = con_curlines/vid.dupy;
|
||||
|
||||
// If the patch doesn't fill the entire screen,
|
||||
// then fill the sides with a solid color.
|
||||
if (x > 0)
|
||||
{
|
||||
column_t *column = (column_t *)((UINT8 *)(con_backpic) + LONG(con_backpic->columnofs[0]));
|
||||
if (!column->topdelta)
|
||||
{
|
||||
UINT8 *source = (UINT8 *)(column) + 3;
|
||||
INT32 color = (source[0] | V_NOSCALESTART);
|
||||
// left side
|
||||
V_DrawFill(0, 0, x, con_curlines, color);
|
||||
// right side
|
||||
V_DrawFill((x + w), 0, (vid.width - w), con_curlines, color);
|
||||
}
|
||||
}
|
||||
|
||||
// Cache the patch normally.
|
||||
con_backpic = W_CachePatchNum(piclump, PU_PATCH);
|
||||
V_DrawCroppedPatch(x << FRACBITS, 0, FRACUNIT, V_NOSCALESTART, con_backpic,
|
||||
0, ( BASEVIDHEIGHT - h ), BASEVIDWIDTH, h);
|
||||
|
||||
// Unlock the cached patch.
|
||||
W_UnlockCachedPatch(con_backpic);
|
||||
}
|
||||
|
||||
// draw the console background, text, and prompt if enough place
|
||||
//
|
||||
static void CON_DrawConsole(void)
|
||||
|
@ -1551,34 +1597,7 @@ static void CON_DrawConsole(void)
|
|||
|
||||
// draw console background
|
||||
if (cons_backpic.value || con_forcepic)
|
||||
{
|
||||
patch_t *con_backpic = W_CachePatchName("CONSBACK", PU_PATCH);
|
||||
int x, w, h;
|
||||
|
||||
w = (con_backpic->width * vid.dupx);
|
||||
x = (vid.width / 2) - (w / 2);
|
||||
h = con_curlines/vid.dupy;
|
||||
|
||||
// Lactozilla: If the patch doesn't fill the entire screen,
|
||||
// then fill the sides with a solid color.
|
||||
if (x > 0)
|
||||
{
|
||||
column_t *column = (column_t *)((UINT8 *)(con_backpic) + LONG(con_backpic->columnofs[0]));
|
||||
if (!column->topdelta)
|
||||
{
|
||||
UINT8 *source = (UINT8 *)(column) + 3;
|
||||
INT32 color = (source[0] | V_NOSCALESTART);
|
||||
// left side
|
||||
V_DrawFill(0, 0, x, con_curlines, color);
|
||||
// right side
|
||||
V_DrawFill((x + w), 0, (vid.width - w), con_curlines, color);
|
||||
}
|
||||
}
|
||||
V_DrawCroppedPatch(x << FRACBITS, 0, FRACUNIT, V_NOSCALESTART, con_backpic,
|
||||
0, ( BASEVIDHEIGHT - h ), BASEVIDWIDTH, h);
|
||||
|
||||
W_UnlockCachedPatch(con_backpic);
|
||||
}
|
||||
CON_DrawBackpic();
|
||||
else
|
||||
{
|
||||
// inu: no more width (was always 0 and vid.width)
|
||||
|
|
|
@ -291,7 +291,7 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t
|
|||
if (cx >= -0.1f && cx <= 0.1f && SHORT(gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT)
|
||||
{
|
||||
// Need to temporarily cache the real patch to get the colour of the top left pixel
|
||||
patch_t *realpatch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC);
|
||||
patch_t *realpatch = W_CacheSoftwarePatchNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC);
|
||||
const column_t *column = (const column_t *)((const UINT8 *)(realpatch) + LONG((realpatch)->columnofs[0]));
|
||||
if (!column->topdelta)
|
||||
{
|
||||
|
@ -450,7 +450,7 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal
|
|||
if (cx >= -0.1f && cx <= 0.1f && SHORT(gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT)
|
||||
{
|
||||
// Need to temporarily cache the real patch to get the colour of the top left pixel
|
||||
patch_t *realpatch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC);
|
||||
patch_t *realpatch = W_CacheSoftwarePatchNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC);
|
||||
const column_t *column = (const column_t *)((const UINT8 *)(realpatch) + LONG((realpatch)->columnofs[0]));
|
||||
if (!column->topdelta)
|
||||
{
|
||||
|
|
85
src/w_wad.c
85
src/w_wad.c
|
@ -1511,6 +1511,57 @@ void *W_CacheLumpName(const char *name, INT32 tag)
|
|||
// Cache a patch into heap memory, convert the patch format as necessary
|
||||
//
|
||||
|
||||
void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
|
||||
{
|
||||
lumpcache_t *lumpcache = NULL;
|
||||
|
||||
if (needpatchflush)
|
||||
W_FlushCachedPatches();
|
||||
|
||||
if (!TestValidLump(wad, lump))
|
||||
return NULL;
|
||||
|
||||
lumpcache = wadfiles[wad]->patchcache;
|
||||
|
||||
if (!lumpcache[lump])
|
||||
{
|
||||
size_t len = W_LumpLengthPwad(wad, lump);
|
||||
void *ptr, *lumpdata;
|
||||
#ifndef NO_PNG_LUMPS
|
||||
void *srcdata = NULL;
|
||||
#endif
|
||||
|
||||
ptr = Z_Malloc(len, tag, &lumpcache[lump]);
|
||||
lumpdata = Z_Malloc(len, tag, NULL);
|
||||
|
||||
// read the lump in full
|
||||
W_ReadLumpHeaderPwad(wad, lump, lumpdata, 0, 0);
|
||||
|
||||
#ifndef NO_PNG_LUMPS
|
||||
// lump is a png so convert it
|
||||
if (R_IsLumpPNG((UINT8 *)lumpdata, len))
|
||||
{
|
||||
size_t newlen;
|
||||
srcdata = R_PNGToPatch((UINT8 *)lumpdata, len, &newlen);
|
||||
ptr = Z_Realloc(ptr, newlen, tag, &lumpcache[lump]);
|
||||
M_Memcpy(ptr, srcdata, newlen);
|
||||
Z_Free(srcdata);
|
||||
}
|
||||
else // just copy it into the patch cache
|
||||
#endif
|
||||
M_Memcpy(ptr, lumpdata, len);
|
||||
}
|
||||
else
|
||||
Z_ChangeTag(lumpcache[lump], tag);
|
||||
|
||||
return lumpcache[lump];
|
||||
}
|
||||
|
||||
void *W_CacheSoftwarePatchNum(lumpnum_t lumpnum, INT32 tag)
|
||||
{
|
||||
return W_CacheSoftwarePatchNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum),tag);
|
||||
}
|
||||
|
||||
void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
|
||||
{
|
||||
#ifdef HWRENDER
|
||||
|
@ -1528,39 +1579,7 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
|
|||
if (rendermode == render_soft || rendermode == render_none)
|
||||
#endif
|
||||
{
|
||||
lumpcache_t *lumpcache = wadfiles[wad]->patchcache;
|
||||
if (!lumpcache[lump])
|
||||
{
|
||||
size_t len = W_LumpLengthPwad(wad, lump);
|
||||
void *ptr, *lumpdata;
|
||||
#ifndef NO_PNG_LUMPS
|
||||
void *srcdata = NULL;
|
||||
#endif
|
||||
|
||||
ptr = Z_Malloc(len, tag, &lumpcache[lump]);
|
||||
lumpdata = Z_Malloc(len, tag, NULL);
|
||||
|
||||
// read the lump in full
|
||||
W_ReadLumpHeaderPwad(wad, lump, lumpdata, 0, 0);
|
||||
|
||||
#ifndef NO_PNG_LUMPS
|
||||
// lump is a png so convert it
|
||||
if (R_IsLumpPNG((UINT8 *)lumpdata, len))
|
||||
{
|
||||
size_t newlen;
|
||||
srcdata = R_PNGToPatch((UINT8 *)lumpdata, len, &newlen);
|
||||
ptr = Z_Realloc(ptr, newlen, tag, &lumpcache[lump]);
|
||||
M_Memcpy(ptr, srcdata, newlen);
|
||||
Z_Free(srcdata);
|
||||
}
|
||||
else // just copy it into the patch cache
|
||||
#endif
|
||||
M_Memcpy(ptr, lumpdata, len);
|
||||
}
|
||||
else
|
||||
Z_ChangeTag(lumpcache[lump], tag);
|
||||
|
||||
return lumpcache[lump];
|
||||
return W_CacheSoftwarePatchNumPwad(wad, lump, tag);
|
||||
}
|
||||
#ifdef HWRENDER
|
||||
|
||||
|
|
11
src/w_wad.h
11
src/w_wad.h
|
@ -191,8 +191,15 @@ boolean W_IsPatchCached(lumpnum_t lump, void *ptr);
|
|||
void *W_CacheLumpName(const char *name, INT32 tag);
|
||||
void *W_CachePatchName(const char *name, INT32 tag);
|
||||
|
||||
void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag); // return a patch_t
|
||||
void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag); // return a patch_t
|
||||
// Returns either a Software patch, or an OpenGL patch.
|
||||
// Performs any necessary conversions from PNG images.
|
||||
void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag);
|
||||
void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag);
|
||||
|
||||
// Returns a Software patch.
|
||||
// Performs any necessary conversions from PNG images.
|
||||
void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag);
|
||||
void *W_CacheSoftwarePatchNum(lumpnum_t lumpnum, INT32 tag);
|
||||
|
||||
void W_UnlockCachedPatch(void *patch);
|
||||
void W_FlushCachedPatches(void);
|
||||
|
|
Loading…
Reference in a new issue