Merge branch 'gl-levelflat-fix' into 'next'
Fix a misuse of levelflat_t.picture in OpenGL See merge request STJr/SRB2!1327
This commit is contained in:
commit
14ee92ef67
|
@ -866,7 +866,7 @@ static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download a Doom 'flat' to the hardware cache and make it ready for use
|
// Download a Doom 'flat' to the hardware cache and make it ready for use
|
||||||
void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum)
|
void HWR_GetRawFlat(lumpnum_t flatlumpnum)
|
||||||
{
|
{
|
||||||
GLMipmap_t *grmip;
|
GLMipmap_t *grmip;
|
||||||
patch_t *patch;
|
patch_t *patch;
|
||||||
|
@ -895,7 +895,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (levelflat->type == LEVELFLAT_FLAT)
|
if (levelflat->type == LEVELFLAT_FLAT)
|
||||||
HWR_LiterallyGetFlat(levelflat->u.flat.lumpnum);
|
HWR_GetRawFlat(levelflat->u.flat.lumpnum);
|
||||||
else if (levelflat->type == LEVELFLAT_TEXTURE)
|
else if (levelflat->type == LEVELFLAT_TEXTURE)
|
||||||
{
|
{
|
||||||
GLMapTexture_t *grtex;
|
GLMapTexture_t *grtex;
|
||||||
|
@ -934,15 +934,17 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
|
||||||
#ifndef NO_PNG_LUMPS
|
#ifndef NO_PNG_LUMPS
|
||||||
else if (levelflat->type == LEVELFLAT_PNG)
|
else if (levelflat->type == LEVELFLAT_PNG)
|
||||||
{
|
{
|
||||||
INT32 pngwidth = 0, pngheight = 0;
|
|
||||||
GLMipmap_t *mipmap = levelflat->mipmap;
|
GLMipmap_t *mipmap = levelflat->mipmap;
|
||||||
UINT8 *flat;
|
|
||||||
size_t size;
|
|
||||||
|
|
||||||
// Cache the picture.
|
// Cache the picture.
|
||||||
if (!levelflat->picture)
|
if (!levelflat->mippic)
|
||||||
{
|
{
|
||||||
levelflat->picture = Picture_PNGConvert(W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_CACHE), PICFMT_FLAT, &pngwidth, &pngheight, NULL, NULL, W_LumpLength(levelflat->u.flat.lumpnum), NULL, 0);
|
INT32 pngwidth = 0, pngheight = 0;
|
||||||
|
void *pic = Picture_PNGConvert(W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_CACHE), PICFMT_FLAT, &pngwidth, &pngheight, NULL, NULL, W_LumpLength(levelflat->u.flat.lumpnum), NULL, 0);
|
||||||
|
|
||||||
|
Z_ChangeTag(pic, PU_LEVEL);
|
||||||
|
Z_SetUser(pic, &levelflat->mippic);
|
||||||
|
|
||||||
levelflat->width = (UINT16)pngwidth;
|
levelflat->width = (UINT16)pngwidth;
|
||||||
levelflat->height = (UINT16)pngheight;
|
levelflat->height = (UINT16)pngheight;
|
||||||
}
|
}
|
||||||
|
@ -950,7 +952,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
|
||||||
// Make the mipmap.
|
// Make the mipmap.
|
||||||
if (mipmap == NULL)
|
if (mipmap == NULL)
|
||||||
{
|
{
|
||||||
mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_LEVEL, NULL);
|
mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_STATIC, NULL);
|
||||||
mipmap->format = GL_TEXFMT_P_8;
|
mipmap->format = GL_TEXFMT_P_8;
|
||||||
mipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
|
mipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
|
||||||
levelflat->mipmap = mipmap;
|
levelflat->mipmap = mipmap;
|
||||||
|
@ -958,17 +960,22 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
|
||||||
|
|
||||||
if (!mipmap->data && !mipmap->downloaded)
|
if (!mipmap->data && !mipmap->downloaded)
|
||||||
{
|
{
|
||||||
|
UINT8 *flat;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
if (levelflat->mippic == NULL)
|
||||||
|
I_Error("HWR_GetLevelFlat: levelflat->mippic == NULL");
|
||||||
|
|
||||||
mipmap->width = levelflat->width;
|
mipmap->width = levelflat->width;
|
||||||
mipmap->height = levelflat->height;
|
mipmap->height = levelflat->height;
|
||||||
|
|
||||||
size = (mipmap->width * mipmap->height);
|
size = (mipmap->width * mipmap->height);
|
||||||
flat = Z_Malloc(size, PU_LEVEL, &mipmap->data);
|
flat = Z_Malloc(size, PU_LEVEL, &mipmap->data);
|
||||||
if (levelflat->picture == NULL)
|
M_Memcpy(flat, levelflat->mippic, size);
|
||||||
I_Error("HWR_GetLevelFlat: levelflat->picture == NULL");
|
|
||||||
M_Memcpy(flat, levelflat->picture, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell the hardware driver to bind the current texture to the flat's mipmap
|
// Tell the hardware driver to bind the current texture to the flat's mipmap
|
||||||
HWD.pfnSetTexture(mipmap);
|
HWR_SetCurrentTexture(mipmap);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else // set no texture
|
else // set no texture
|
||||||
|
|
|
@ -639,7 +639,7 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum
|
||||||
v[0].t = v[1].t = (float)((y & flatflag)/dflatsize);
|
v[0].t = v[1].t = (float)((y & flatflag)/dflatsize);
|
||||||
v[2].t = v[3].t = (float)(v[0].t + h/dflatsize);
|
v[2].t = v[3].t = (float)(v[0].t + h/dflatsize);
|
||||||
|
|
||||||
HWR_LiterallyGetFlat(flatlumpnum);
|
HWR_GetRawFlat(flatlumpnum);
|
||||||
|
|
||||||
//Hurdler: Boris, the same comment as above... but maybe for pics
|
//Hurdler: Boris, the same comment as above... but maybe for pics
|
||||||
// it not a problem since they don't have any transparent pixel
|
// it not a problem since they don't have any transparent pixel
|
||||||
|
|
|
@ -118,7 +118,7 @@ patch_t *HWR_GetPic(lumpnum_t lumpnum);
|
||||||
|
|
||||||
GLMapTexture_t *HWR_GetTexture(INT32 tex);
|
GLMapTexture_t *HWR_GetTexture(INT32 tex);
|
||||||
void HWR_GetLevelFlat(levelflat_t *levelflat);
|
void HWR_GetLevelFlat(levelflat_t *levelflat);
|
||||||
void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum);
|
void HWR_GetRawFlat(lumpnum_t flatlumpnum);
|
||||||
|
|
||||||
void HWR_FreeTexture(patch_t *patch);
|
void HWR_FreeTexture(patch_t *patch);
|
||||||
void HWR_FreeTextureData(patch_t *patch);
|
void HWR_FreeTextureData(patch_t *patch);
|
||||||
|
|
|
@ -80,6 +80,7 @@ typedef struct
|
||||||
UINT8 *picture;
|
UINT8 *picture;
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
void *mipmap;
|
void *mipmap;
|
||||||
|
void *mippic;
|
||||||
#endif
|
#endif
|
||||||
} levelflat_t;
|
} levelflat_t;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue