mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 07:22:28 +00:00
Fix OpenGL
This commit is contained in:
parent
5b5f371b0c
commit
1358507785
5 changed files with 98 additions and 35 deletions
|
@ -1024,7 +1024,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
|
||||||
INT32 texturenum = levelflat->u.texture.num;
|
INT32 texturenum = levelflat->u.texture.num;
|
||||||
#ifdef PARANOIA
|
#ifdef PARANOIA
|
||||||
if ((unsigned)texturenum >= gr_numtextures)
|
if ((unsigned)texturenum >= gr_numtextures)
|
||||||
I_Error("HWR_GetLevelFlat: texturenum >= numtextures\n");
|
I_Error("HWR_GetLevelFlat: texturenum >= numtextures");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Who knows?
|
// Who knows?
|
||||||
|
@ -1044,6 +1044,58 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
|
||||||
// The system-memory data can be purged now.
|
// The system-memory data can be purged now.
|
||||||
Z_ChangeTag(grtex->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED);
|
Z_ChangeTag(grtex->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED);
|
||||||
}
|
}
|
||||||
|
else if (levelflat->type == LEVELFLAT_PATCH)
|
||||||
|
{
|
||||||
|
GLPatch_t *patch = W_CachePatchNum(levelflat->u.flat.lumpnum, PU_CACHE);
|
||||||
|
levelflat->width = (UINT16)SHORT(patch->width);
|
||||||
|
levelflat->height = (UINT16)SHORT(patch->height);
|
||||||
|
HWR_GetPatch(patch);
|
||||||
|
}
|
||||||
|
#ifndef NO_PNG_LUMPS
|
||||||
|
else if (levelflat->type == LEVELFLAT_PNG)
|
||||||
|
{
|
||||||
|
INT32 pngwidth, pngheight;
|
||||||
|
GLMipmap_t *mipmap = levelflat->mipmap;
|
||||||
|
UINT8 *flat;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
// Cache the picture.
|
||||||
|
if (!levelflat->picture)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
levelflat->width = (UINT16)pngwidth;
|
||||||
|
levelflat->height = (UINT16)pngheight;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make the mipmap.
|
||||||
|
if (mipmap == NULL)
|
||||||
|
{
|
||||||
|
mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_LEVEL, NULL);
|
||||||
|
mipmap->grInfo.format = GR_TEXFMT_P_8;
|
||||||
|
mipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
|
||||||
|
#ifdef GLIDE_API_COMPATIBILITY
|
||||||
|
mipmap->grInfo.smallLodLog2 = GR_LOD_LOG2_64;
|
||||||
|
mipmap->grInfo.largeLodLog2 = GR_LOD_LOG2_64;
|
||||||
|
mipmap->grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1;
|
||||||
|
#endif
|
||||||
|
levelflat->mipmap = mipmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mipmap->grInfo.data && !mipmap->downloaded)
|
||||||
|
{
|
||||||
|
mipmap->width = levelflat->width;
|
||||||
|
mipmap->height = levelflat->height;
|
||||||
|
size = (mipmap->width * mipmap->height);
|
||||||
|
flat = Z_Malloc(size, PU_LEVEL, &mipmap->grInfo.data);
|
||||||
|
if (levelflat->picture == NULL)
|
||||||
|
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
|
||||||
|
HWD.pfnSetTexture(mipmap);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else // set no texture
|
else // set no texture
|
||||||
HWD.pfnSetTexture(NULL);
|
HWD.pfnSetTexture(NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -480,7 +480,6 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
||||||
float fflatwidth = 64.0f, fflatheight = 64.0f;
|
float fflatwidth = 64.0f, fflatheight = 64.0f;
|
||||||
INT32 flatflag = 63;
|
INT32 flatflag = 63;
|
||||||
boolean texflat = false;
|
boolean texflat = false;
|
||||||
size_t len;
|
|
||||||
float scrollx = 0.0f, scrolly = 0.0f;
|
float scrollx = 0.0f, scrolly = 0.0f;
|
||||||
angle_t angle = 0;
|
angle_t angle = 0;
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf;
|
||||||
|
@ -546,16 +545,9 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
||||||
// set texture for polygon
|
// set texture for polygon
|
||||||
if (levelflat != NULL)
|
if (levelflat != NULL)
|
||||||
{
|
{
|
||||||
if (levelflat->type == LEVELFLAT_TEXTURE)
|
if (levelflat->type == LEVELFLAT_FLAT)
|
||||||
{
|
{
|
||||||
fflatwidth = textures[levelflat->u.texture.num]->width;
|
size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
|
||||||
fflatheight = textures[levelflat->u.texture.num]->height;
|
|
||||||
texflat = true;
|
|
||||||
}
|
|
||||||
else if (levelflat->type == LEVELFLAT_FLAT)
|
|
||||||
{
|
|
||||||
len = W_LumpLength(levelflat->u.flat.lumpnum);
|
|
||||||
|
|
||||||
switch (len)
|
switch (len)
|
||||||
{
|
{
|
||||||
case 4194304: // 2048x2048 lump
|
case 4194304: // 2048x2048 lump
|
||||||
|
@ -580,9 +572,22 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is
|
||||||
fflatwidth = fflatheight = 64.0f;
|
fflatwidth = fflatheight = 64.0f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
flatflag = ((INT32)fflatwidth)-1;
|
flatflag = ((INT32)fflatwidth)-1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (levelflat->type == LEVELFLAT_TEXTURE)
|
||||||
|
{
|
||||||
|
fflatwidth = textures[levelflat->u.texture.num]->width;
|
||||||
|
fflatheight = textures[levelflat->u.texture.num]->height;
|
||||||
|
}
|
||||||
|
else if (levelflat->type == LEVELFLAT_PATCH || levelflat->type == LEVELFLAT_PNG)
|
||||||
|
{
|
||||||
|
fflatwidth = levelflat->width;
|
||||||
|
fflatheight = levelflat->height;
|
||||||
|
}
|
||||||
|
texflat = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else // set no texture
|
else // set no texture
|
||||||
HWD.pfnSetTexture(NULL);
|
HWD.pfnSetTexture(NULL);
|
||||||
|
@ -3142,7 +3147,6 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
||||||
float fflatwidth = 64.0f, fflatheight = 64.0f;
|
float fflatwidth = 64.0f, fflatheight = 64.0f;
|
||||||
INT32 flatflag = 63;
|
INT32 flatflag = 63;
|
||||||
boolean texflat = false;
|
boolean texflat = false;
|
||||||
size_t len;
|
|
||||||
float scrollx = 0.0f, scrolly = 0.0f;
|
float scrollx = 0.0f, scrolly = 0.0f;
|
||||||
angle_t angle = 0;
|
angle_t angle = 0;
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf;
|
||||||
|
@ -3176,16 +3180,9 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
||||||
// set texture for polygon
|
// set texture for polygon
|
||||||
if (levelflat != NULL)
|
if (levelflat != NULL)
|
||||||
{
|
{
|
||||||
if (levelflat->type == LEVELFLAT_TEXTURE)
|
if (levelflat->type == LEVELFLAT_FLAT)
|
||||||
{
|
{
|
||||||
fflatwidth = textures[levelflat->u.texture.num]->width;
|
size_t len = W_LumpLength(levelflat->u.flat.lumpnum);
|
||||||
fflatheight = textures[levelflat->u.texture.num]->height;
|
|
||||||
texflat = true;
|
|
||||||
}
|
|
||||||
else if (levelflat->type == LEVELFLAT_FLAT)
|
|
||||||
{
|
|
||||||
len = W_LumpLength(levelflat->u.flat.lumpnum);
|
|
||||||
|
|
||||||
switch (len)
|
switch (len)
|
||||||
{
|
{
|
||||||
case 4194304: // 2048x2048 lump
|
case 4194304: // 2048x2048 lump
|
||||||
|
@ -3210,9 +3207,22 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
||||||
fflatwidth = fflatheight = 64.0f;
|
fflatwidth = fflatheight = 64.0f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
flatflag = ((INT32)fflatwidth)-1;
|
flatflag = ((INT32)fflatwidth)-1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (levelflat->type == LEVELFLAT_TEXTURE)
|
||||||
|
{
|
||||||
|
fflatwidth = textures[levelflat->u.texture.num]->width;
|
||||||
|
fflatheight = textures[levelflat->u.texture.num]->height;
|
||||||
|
}
|
||||||
|
else if (levelflat->type == LEVELFLAT_PATCH || levelflat->type == LEVELFLAT_PNG)
|
||||||
|
{
|
||||||
|
fflatwidth = levelflat->width;
|
||||||
|
fflatheight = levelflat->height;
|
||||||
|
}
|
||||||
|
texflat = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else // set no texture
|
else // set no texture
|
||||||
HWD.pfnSetTexture(NULL);
|
HWD.pfnSetTexture(NULL);
|
||||||
|
|
|
@ -649,8 +649,6 @@ flatfound:
|
||||||
Only need eight bytes for PNG headers.
|
Only need eight bytes for PNG headers.
|
||||||
FIXME: Put this elsewhere.
|
FIXME: Put this elsewhere.
|
||||||
*/
|
*/
|
||||||
if (flatpatch)
|
|
||||||
Z_Free(flatpatch);
|
|
||||||
W_ReadLumpHeader(flatnum, buffer, 8, 0);
|
W_ReadLumpHeader(flatnum, buffer, 8, 0);
|
||||||
if (Picture_IsLumpPNG(buffer, lumplength))
|
if (Picture_IsLumpPNG(buffer, lumplength))
|
||||||
levelflat->type = LEVELFLAT_PNG;
|
levelflat->type = LEVELFLAT_PNG;
|
||||||
|
@ -658,6 +656,8 @@ flatfound:
|
||||||
#endif/*NO_PNG_LUMPS*/
|
#endif/*NO_PNG_LUMPS*/
|
||||||
levelflat->type = LEVELFLAT_FLAT;/* phew */
|
levelflat->type = LEVELFLAT_FLAT;/* phew */
|
||||||
}
|
}
|
||||||
|
if (flatpatch)
|
||||||
|
Z_Free(flatpatch);
|
||||||
|
|
||||||
levelflat->u.flat. lumpnum = flatnum;
|
levelflat->u.flat. lumpnum = flatnum;
|
||||||
levelflat->u.flat.baselumpnum = LUMPERROR;
|
levelflat->u.flat.baselumpnum = LUMPERROR;
|
||||||
|
|
|
@ -37,9 +37,7 @@ enum
|
||||||
LEVELFLAT_NONE,/* HOM time my friend */
|
LEVELFLAT_NONE,/* HOM time my friend */
|
||||||
LEVELFLAT_FLAT,
|
LEVELFLAT_FLAT,
|
||||||
LEVELFLAT_PATCH,
|
LEVELFLAT_PATCH,
|
||||||
#ifndef NO_PNG_LUMPS
|
|
||||||
LEVELFLAT_PNG,
|
LEVELFLAT_PNG,
|
||||||
#endif
|
|
||||||
LEVELFLAT_TEXTURE,
|
LEVELFLAT_TEXTURE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -78,8 +76,11 @@ typedef struct
|
||||||
INT32 numpics;
|
INT32 numpics;
|
||||||
INT32 speed;
|
INT32 speed;
|
||||||
|
|
||||||
// for patchflats
|
// for textures
|
||||||
UINT8 *flatpatch;
|
UINT8 *picture;
|
||||||
|
#ifdef HWRENDER
|
||||||
|
void *mipmap;
|
||||||
|
#endif
|
||||||
} levelflat_t;
|
} levelflat_t;
|
||||||
|
|
||||||
extern size_t numlevelflats;
|
extern size_t numlevelflats;
|
||||||
|
|
|
@ -529,7 +529,7 @@ void *R_GetLevelFlat(levelflat_t *levelflat)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the texture changed, or the patch doesn't exist, convert either of them to a flat.
|
// If the texture changed, or the patch doesn't exist, convert either of them to a flat.
|
||||||
if (levelflat->flatpatch == NULL || texturechanged)
|
if (levelflat->picture == NULL || texturechanged)
|
||||||
{
|
{
|
||||||
// Level texture
|
// Level texture
|
||||||
if (leveltexture)
|
if (leveltexture)
|
||||||
|
@ -546,7 +546,7 @@ void *R_GetLevelFlat(levelflat_t *levelflat)
|
||||||
M_Memcpy(texflat->flat, converted, size);
|
M_Memcpy(texflat->flat, converted, size);
|
||||||
Z_Free(converted);
|
Z_Free(converted);
|
||||||
|
|
||||||
levelflat->flatpatch = texflat->flat;
|
levelflat->picture = texflat->flat;
|
||||||
levelflat->width = ds_flatwidth;
|
levelflat->width = ds_flatwidth;
|
||||||
levelflat->height = ds_flatheight;
|
levelflat->height = ds_flatheight;
|
||||||
}
|
}
|
||||||
|
@ -557,7 +557,7 @@ void *R_GetLevelFlat(levelflat_t *levelflat)
|
||||||
{
|
{
|
||||||
INT32 pngwidth, pngheight;
|
INT32 pngwidth, pngheight;
|
||||||
|
|
||||||
levelflat->flatpatch = Picture_PNGConvert(W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_CACHE), PICFMT_FLAT, &pngwidth, &pngheight, NULL, NULL, W_LumpLength(levelflat->u.flat.lumpnum), NULL, 0);
|
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);
|
||||||
levelflat->width = (UINT16)pngwidth;
|
levelflat->width = (UINT16)pngwidth;
|
||||||
levelflat->height = (UINT16)pngheight;
|
levelflat->height = (UINT16)pngheight;
|
||||||
|
|
||||||
|
@ -575,9 +575,9 @@ void *R_GetLevelFlat(levelflat_t *levelflat)
|
||||||
levelflat->width = ds_flatwidth = SHORT(patch->width);
|
levelflat->width = ds_flatwidth = SHORT(patch->width);
|
||||||
levelflat->height = ds_flatheight = SHORT(patch->height);
|
levelflat->height = ds_flatheight = SHORT(patch->height);
|
||||||
|
|
||||||
levelflat->flatpatch = Z_Malloc(levelflat->width * levelflat->height, PU_LEVEL, NULL);
|
levelflat->picture = Z_Malloc(levelflat->width * levelflat->height, PU_LEVEL, NULL);
|
||||||
converted = Picture_FlatConvert(PICFMT_PATCH, patch, PICFMT_FLAT, 0, &size, levelflat->width, levelflat->height, patch->topoffset, patch->leftoffset, 0);
|
converted = Picture_FlatConvert(PICFMT_PATCH, patch, PICFMT_FLAT, 0, &size, levelflat->width, levelflat->height, patch->topoffset, patch->leftoffset, 0);
|
||||||
M_Memcpy(levelflat->flatpatch, converted, size);
|
M_Memcpy(levelflat->picture, converted, size);
|
||||||
Z_Free(converted);
|
Z_Free(converted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -591,7 +591,7 @@ void *R_GetLevelFlat(levelflat_t *levelflat)
|
||||||
levelflat->u.texture.lastnum = levelflat->u.texture.num;
|
levelflat->u.texture.lastnum = levelflat->u.texture.num;
|
||||||
|
|
||||||
if (flatdata == NULL)
|
if (flatdata == NULL)
|
||||||
flatdata = levelflat->flatpatch;
|
flatdata = levelflat->picture;
|
||||||
return flatdata;
|
return flatdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue