Refactoring

This commit is contained in:
Jaime Ita Passos 2020-12-11 01:06:45 -03:00
parent 29745f80dc
commit b259368b37
24 changed files with 1069 additions and 1261 deletions

View file

@ -16,7 +16,7 @@
// The texture for the next polygon given to HWR_ProcessPolygon.
// Set with HWR_SetCurrentTexture.
GLMipmap_t *current_texture = NULL;
HWRTexture_t *current_texture = NULL;
boolean currently_batching = false;
@ -61,7 +61,7 @@ void HWR_StartBatching(void)
// This replaces the direct calls to pfnSetTexture in cases where batching is available.
// The texture selection is saved for the next HWR_ProcessPolygon call.
// Doing this was easier than getting a texture pointer to HWR_ProcessPolygon.
void HWR_SetCurrentTexture(GLMipmap_t *texture)
void HWR_SetCurrentTexture(HWRTexture_t *texture)
{
if (currently_batching)
{
@ -76,7 +76,7 @@ void HWR_SetCurrentTexture(GLMipmap_t *texture)
// If batching is enabled, this function collects the polygon data and the chosen texture
// for later use in HWR_RenderBatches. Otherwise the rendering backend is used to
// render the polygon immediately.
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial)
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, UINT32 iNumPts, UINT32 PolyFlags, int shader, boolean horizonSpecial)
{
if (currently_batching)
{
@ -165,11 +165,11 @@ static int comparePolygons(const void *p1, const void *p2)
diff64 = poly1->surf.FadeColor.rgba - poly2->surf.FadeColor.rgba;
if (diff64 < 0) return -1; else if (diff64 > 0) return 1;
diff = poly1->surf.LightInfo.light_level - poly2->surf.LightInfo.light_level;
diff = poly1->surf.LightInfo.LightLevel - poly2->surf.LightInfo.LightLevel;
if (diff != 0) return diff;
diff = poly1->surf.LightInfo.fade_start - poly2->surf.LightInfo.fade_start;
diff = poly1->surf.LightInfo.FadeStart - poly2->surf.LightInfo.FadeStart;
if (diff != 0) return diff;
diff = poly1->surf.LightInfo.fade_end - poly2->surf.LightInfo.fade_end;
diff = poly1->surf.LightInfo.FadeEnd - poly2->surf.LightInfo.FadeEnd;
return diff;
}
@ -182,8 +182,8 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2)
int diff;
INT64 diff64;
GLMipmap_t *texture1 = poly1->texture;
GLMipmap_t *texture2 = poly2->texture;
HWRTexture_t *texture1 = poly1->texture;
HWRTexture_t *texture2 = poly2->texture;
if (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial)
texture1 = NULL;
if (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial)
@ -215,10 +215,10 @@ void HWR_RenderBatches(void)
int currentShader;
int nextShader = 0;
GLMipmap_t *currentTexture;
GLMipmap_t *nextTexture = NULL;
FBITFIELD currentPolyFlags = 0;
FBITFIELD nextPolyFlags = 0;
HWRTexture_t *currentTexture;
HWRTexture_t *nextTexture = NULL;
UINT32 currentPolyFlags = 0;
UINT32 nextPolyFlags = 0;
FSurfaceInfo currentSurfaceInfo;
FSurfaceInfo nextSurfaceInfo;
@ -227,9 +227,9 @@ void HWR_RenderBatches(void)
if (!currently_batching)
I_Error("HWR_RenderBatches called without starting batching");
nextSurfaceInfo.LightInfo.fade_end = 0;
nextSurfaceInfo.LightInfo.fade_start = 0;
nextSurfaceInfo.LightInfo.light_level = 0;
nextSurfaceInfo.LightInfo.FadeEnd = 0;
nextSurfaceInfo.LightInfo.FadeStart = 0;
nextSurfaceInfo.LightInfo.LightLevel = 0;
currently_batching = false;// no longer collecting batches
if (!polygonArraySize)
@ -374,9 +374,9 @@ void HWR_RenderBatches(void)
if (currentSurfaceInfo.PolyColor.rgba != nextSurfaceInfo.PolyColor.rgba ||
currentSurfaceInfo.TintColor.rgba != nextSurfaceInfo.TintColor.rgba ||
currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba ||
currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level ||
currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start ||
currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end)
currentSurfaceInfo.LightInfo.LightLevel != nextSurfaceInfo.LightInfo.LightLevel ||
currentSurfaceInfo.LightInfo.FadeStart != nextSurfaceInfo.LightInfo.FadeStart ||
currentSurfaceInfo.LightInfo.FadeEnd != nextSurfaceInfo.LightInfo.FadeEnd)
{
changeState = true;
changeSurfaceInfo = true;

View file

@ -16,21 +16,21 @@
#include "hw_data.h"
#include "hw_drv.h"
typedef struct
typedef struct
{
FSurfaceInfo surf;// surf also has its own polyflags for some reason, but it seems unused
unsigned int vertsIndex;// location of verts in unsortedVertexArray
FUINT numVerts;
FBITFIELD polyFlags;
GLMipmap_t *texture;
UINT32 numVerts;
UINT32 polyFlags;
HWRTexture_t *texture;
int shader;
// this tells batching that the plane belongs to a horizon line and must be drawn in correct order with the skywalls
boolean horizonSpecial;
} PolygonArrayEntry;
void HWR_StartBatching(void);
void HWR_SetCurrentTexture(GLMipmap_t *texture);
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, int shader, boolean horizonSpecial);
void HWR_SetCurrentTexture(HWRTexture_t *texture);
void HWR_ProcessPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, UINT32 iNumPts, UINT32 PolyFlags, int shader, boolean horizonSpecial);
void HWR_RenderBatches(void);
#endif

View file

@ -29,14 +29,14 @@
#include "../r_picformats.h"
#include "../p_setup.h"
INT32 patchformat = GL_TEXFMT_AP_88; // use alpha for holes
INT32 textureformat = GL_TEXFMT_P_8; // use chromakey for hole
INT32 gl_patchformat = GPU_TEXFMT_AP_88; // use alpha for holes
INT32 gl_textureformat = GPU_TEXFMT_P_8; // use chromakey for hole
static INT32 format2bpp(GLTextureFormat_t format)
{
if (format == GL_TEXFMT_RGBA)
if (format == GPU_TEXFMT_RGBA)
return 4;
else if (format == GL_TEXFMT_ALPHA_INTENSITY_88 || format == GL_TEXFMT_AP_88)
else if (format == GPU_TEXFMT_ALPHA_INTENSITY_88 || format == GPU_TEXFMT_AP_88)
return 2;
else
return 1;
@ -45,7 +45,7 @@ static INT32 format2bpp(GLTextureFormat_t format)
// This code was originally placed directly in HWR_DrawPatchInCache.
// It is now split from it for my sanity! (and the sanity of others)
// -- Monster Iestyn (13/02/19)
static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipmap_t *mipmap,
static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, HWRTexture_t *texture,
INT32 pblockheight, INT32 blockmodulo,
fixed_t yfracstep, fixed_t scale_y,
texpatch_t *originPatch, INT32 patchheight,
@ -103,12 +103,12 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
texel = source[yfrac>>FRACBITS];
alpha = 0xFF;
// Make pixel transparent if chroma keyed
if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
if ((texture->flags & TF_CHROMAKEYED) && (texel == GPU_PATCHES_CHROMAKEY_COLORINDEX))
alpha = 0x00;
//Hurdler: 25/04/2000: now support colormap in hardware mode
if (mipmap->colormap)
texel = mipmap->colormap[texel];
if (texture->colormap)
texel = texture->colormap[texel];
// hope compiler will get this switch out of the loops (dreams...)
// gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?)
@ -156,7 +156,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm
}
}
static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block, GLMipmap_t *mipmap,
static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block, HWRTexture_t *texture,
INT32 pblockheight, INT32 blockmodulo,
fixed_t yfracstep, fixed_t scale_y,
texpatch_t *originPatch, INT32 patchheight,
@ -213,12 +213,12 @@ static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block,
texel = source[yfrac>>FRACBITS];
alpha = 0xFF;
// Make pixel transparent if chroma keyed
if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
if ((texture->flags & TF_CHROMAKEYED) && (texel == GPU_PATCHES_CHROMAKEY_COLORINDEX))
alpha = 0x00;
//Hurdler: 25/04/2000: now support colormap in hardware mode
if (mipmap->colormap)
texel = mipmap->colormap[texel];
if (texture->colormap)
texel = texture->colormap[texel];
// hope compiler will get this switch out of the loops (dreams...)
// gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?)
@ -272,7 +272,7 @@ static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block,
// no alpha or flipping should be present since we do not want non-texture graphics to have them
// no offsets are used either
// -- Monster Iestyn (13/02/19)
static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
static void HWR_DrawPatchInCache(HWRTexture_t *texture,
INT32 pblockwidth, INT32 pblockheight,
INT32 pwidth, INT32 pheight,
const patch_t *realpatch)
@ -281,7 +281,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
fixed_t xfrac, xfracstep;
fixed_t yfracstep, scale_y;
const column_t *patchcol;
UINT8 *block = mipmap->data;
UINT8 *block = texture->data;
INT32 bpp;
INT32 blockmodulo;
@ -296,7 +296,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
yfracstep = FRACUNIT;
scale_y = FRACUNIT;
bpp = format2bpp(mipmap->format);
bpp = format2bpp(texture->format);
if (bpp < 1 || bpp > 4)
I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp);
@ -309,7 +309,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
{
patchcol = (const column_t *)((const UINT8 *)realpatch->columns + (realpatch->columnofs[xfrac>>FRACBITS]));
HWR_DrawColumnInCache(patchcol, block, mipmap,
HWR_DrawColumnInCache(patchcol, block, texture,
pblockheight, blockmodulo,
yfracstep, scale_y,
NULL, pheight, // not that pheight is going to get used anyway...
@ -318,7 +318,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap,
}
// This function we use for caching patches that belong to textures
static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
static void HWR_DrawTexturePatchInCache(HWRTexture_t *hwrTexture,
INT32 pblockwidth, INT32 pblockheight,
texture_t *texture, texpatch_t *patch,
const softwarepatch_t *realpatch)
@ -328,12 +328,12 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
fixed_t xfrac, xfracstep;
fixed_t yfracstep, scale_y;
const column_t *patchcol;
UINT8 *block = mipmap->data;
UINT8 *block = hwrTexture->data;
INT32 bpp;
INT32 blockmodulo;
INT32 width, height;
// Column drawing function pointer.
static void (*ColumnDrawerPointer)(const column_t *patchcol, UINT8 *block, GLMipmap_t *mipmap,
static void (*ColumnDrawerPointer)(const column_t *patchcol, UINT8 *block, HWRTexture_t *texture,
INT32 pblockheight, INT32 blockmodulo,
fixed_t yfracstep, fixed_t scale_y,
texpatch_t *originPatch, INT32 patchheight,
@ -389,7 +389,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
yfracstep = (texture->height<< FRACBITS) / pblockheight;
scale_y = (pblockheight << FRACBITS) / texture->height;
bpp = format2bpp(mipmap->format);
bpp = format2bpp(hwrTexture->format);
if (bpp < 1 || bpp > 4)
I_Error("HWR_DrawTexturePatchInCache: no drawer defined for this bpp (%d)\n",bpp);
@ -405,7 +405,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
else
patchcol = (const column_t *)((const UINT8 *)realpatch + LONG(realpatch->columnofs[xfrac>>FRACBITS]));
ColumnDrawerPointer(patchcol, block, mipmap,
ColumnDrawerPointer(patchcol, block, hwrTexture,
pblockheight, blockmodulo,
yfracstep, scale_y,
patch, height,
@ -413,19 +413,19 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap,
}
}
static UINT8 *MakeBlock(GLMipmap_t *grMipmap)
static UINT8 *MakeBlock(HWRTexture_t *hwrTexture)
{
UINT8 *block;
INT32 bpp, i;
UINT16 bu16 = ((0x00 <<8) | HWR_PATCHES_CHROMAKEY_COLORINDEX);
INT32 blocksize = (grMipmap->width * grMipmap->height);
UINT16 bu16 = ((0x00 <<8) | GPU_PATCHES_CHROMAKEY_COLORINDEX);
INT32 blocksize = (hwrTexture->width * hwrTexture->height);
bpp = format2bpp(grMipmap->format);
block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->data));
bpp = format2bpp(hwrTexture->format);
block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(hwrTexture->data));
switch (bpp)
{
case 1: memset(block, HWR_PATCHES_CHROMAKEY_COLORINDEX, blocksize); break;
case 1: memset(block, GPU_PATCHES_CHROMAKEY_COLORINDEX, blocksize); break;
case 2:
// fill background with chromakey, alpha = 0
for (i = 0; i < blocksize; i++)
@ -465,26 +465,26 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex)
)
{
skyspecial = true;
grtex->mipmap.flags = TF_WRAPXY; // don't use the chromakey for sky
grtex->texture.flags = TF_WRAPXY; // don't use the chromakey for sky
}
else
grtex->mipmap.flags = TF_CHROMAKEYED | TF_WRAPXY;
grtex->texture.flags = TF_CHROMAKEYED | TF_WRAPXY;
grtex->mipmap.width = (UINT16)texture->width;
grtex->mipmap.height = (UINT16)texture->height;
grtex->mipmap.format = textureformat;
grtex->texture.width = (UINT16)texture->width;
grtex->texture.height = (UINT16)texture->height;
grtex->texture.format = gl_textureformat;
blockwidth = texture->width;
blockheight = texture->height;
blocksize = (blockwidth * blockheight);
block = MakeBlock(&grtex->mipmap);
block = MakeBlock(&grtex->texture);
if (skyspecial) //Hurdler: not efficient, but better than holes in the sky (and it's done only at level loading)
{
INT32 j;
RGBA_t col;
col = V_GetColor(HWR_PATCHES_CHROMAKEY_COLORINDEX);
col = V_GetColor(GPU_PATCHES_CHROMAKEY_COLORINDEX);
for (j = 0; j < blockheight; j++)
{
for (i = 0; i < blockwidth; i++)
@ -520,19 +520,19 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex)
dealloc = false;
}
HWR_DrawTexturePatchInCache(&grtex->mipmap, blockwidth, blockheight, texture, patch, realpatch);
HWR_DrawTexturePatchInCache(&grtex->texture, blockwidth, blockheight, texture, patch, realpatch);
if (dealloc)
Z_Unlock(realpatch);
}
//Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :(
if (format2bpp(grtex->mipmap.format)==4)
if (format2bpp(grtex->texture.format)==4)
{
for (i = 3; i < blocksize*4; i += 4) // blocksize*4 because blocksize doesn't include the bpp
{
if (block[i] == 0)
{
grtex->mipmap.flags |= TF_TRANSPARENT;
grtex->texture.flags |= TF_TRANSPARENT;
break;
}
}
@ -542,34 +542,34 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *grtex)
grtex->scaleY = 1.0f/(texture->height*FRACUNIT);
}
// patch may be NULL if grMipmap has been initialised already and makebitmap is false
void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap)
// patch may be NULL if hwrTexture has been initialised already and makebitmap is false
void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, HWRTexture_t *hwrTexture, boolean makebitmap)
{
if (grMipmap->width == 0)
if (hwrTexture->width == 0)
{
grMipmap->width = grMipmap->height = 1;
while (grMipmap->width < patch->width) grMipmap->width <<= 1;
while (grMipmap->height < patch->height) grMipmap->height <<= 1;
hwrTexture->width = hwrTexture->height = 1;
while (hwrTexture->width < patch->width) hwrTexture->width <<= 1;
while (hwrTexture->height < patch->height) hwrTexture->height <<= 1;
// no wrap around, no chroma key
grMipmap->flags = 0;
hwrTexture->flags = 0;
// setup the texture info
grMipmap->format = patchformat;
hwrTexture->format = gl_patchformat;
grPatch->max_s = (float)patch->width / (float)grMipmap->width;
grPatch->max_t = (float)patch->height / (float)grMipmap->height;
grPatch->max_s = (float)patch->width / (float)hwrTexture->width;
grPatch->max_t = (float)patch->height / (float)hwrTexture->height;
}
Z_Free(grMipmap->data);
grMipmap->data = NULL;
Z_Free(hwrTexture->data);
hwrTexture->data = NULL;
if (makebitmap)
{
MakeBlock(grMipmap);
MakeBlock(hwrTexture);
HWR_DrawPatchInCache(grMipmap,
grMipmap->width, grMipmap->height,
HWR_DrawPatchInCache(hwrTexture,
hwrTexture->width, hwrTexture->height,
patch->width, patch->height,
patch);
}
@ -585,21 +585,6 @@ static GLMapTexture_t *gl_textures; // For all textures
static GLMapTexture_t *gl_flats; // For all (texture) flats, as normal flats don't need to be cached
boolean gl_maptexturesloaded = false;
void HWR_FreeTextureData(patch_t *patch)
{
GLPatch_t *grPatch;
if (!patch || !patch->hardware)
return;
grPatch = patch->hardware;
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWD.pfnDeleteTexture(grPatch->mipmap);
if (grPatch->mipmap->data)
Z_Free(grPatch->mipmap->data);
}
void HWR_FreeTexture(patch_t *patch)
{
if (!patch)
@ -611,10 +596,13 @@ void HWR_FreeTexture(patch_t *patch)
HWR_FreeTextureColormaps(patch);
if (grPatch->mipmap)
if (grPatch->texture)
{
HWR_FreeTextureData(patch);
Z_Free(grPatch->mipmap);
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWD.pfnDeleteTexture(grPatch->texture);
if (grPatch->texture->data)
Z_Free(grPatch->texture->data);
Z_Free(grPatch->texture);
}
Z_Free(patch->hardware);
@ -623,7 +611,7 @@ void HWR_FreeTexture(patch_t *patch)
patch->hardware = NULL;
}
// Called by HWR_FreePatchCache.
// Called by FreeTextureCache.
void HWR_FreeTextureColormaps(patch_t *patch)
{
GLPatch_t *pat;
@ -636,59 +624,74 @@ void HWR_FreeTextureColormaps(patch_t *patch)
if (!pat)
return;
// The mipmap must be valid, obviously
while (pat->mipmap)
// The texture must be valid, obviously
while (pat->texture)
{
// Confusing at first, but pat->mipmap->nextcolormap
// Confusing at first, but pat->texture->nextcolormap
// at the beginning of the loop is the first colormap
// from the linked list of colormaps.
GLMipmap_t *next = NULL;
HWRTexture_t *next = NULL;
// No mipmap in this patch, break out of the loop.
if (!pat->mipmap)
// No texture in this patch, break out of the loop.
if (!pat->texture)
break;
// No colormap mipmaps either.
if (!pat->mipmap->nextcolormap)
// No colormap textures either.
if (!pat->texture->nextcolormap)
break;
// Set the first colormap to the one that comes after it.
next = pat->mipmap->nextcolormap;
pat->mipmap->nextcolormap = next->nextcolormap;
next = pat->texture->nextcolormap;
pat->texture->nextcolormap = next->nextcolormap;
// Free image data from memory.
if (next->data)
Z_Free(next->data);
next->data = NULL;
HWD.pfnDeleteTexture(next);
// Free the old colormap mipmap from memory.
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWD.pfnDeleteTexture(next);
// Free the old colormap texture from memory.
free(next);
}
}
static void HWR_FreePatchCache(boolean freeall)
static boolean FreeTextureCallback(void *mem)
{
INT32 i;
for (i = 0; i < numwadfiles; i++)
{
INT32 j = 0;
for (; j < wadfiles[i]->numlumps; j++)
(freeall ? HWR_FreeTexture : HWR_FreeTextureColormaps)(wadfiles[i]->patchcache[j]);
}
patch_t *patch = (patch_t *)mem;
HWR_FreeTexture(patch);
return false;
}
static boolean FreeColormapsCallback(void *mem)
{
patch_t *patch = (patch_t *)mem;
HWR_FreeTextureColormaps(patch);
return false;
}
static void FreeTextureCache(boolean freeall)
{
boolean (*callback)(void *mem) = FreeTextureCallback;
if (!freeall)
callback = FreeColormapsCallback;
Z_IterateTags(PU_PATCH, PU_PATCH_ROTATED, callback);
Z_IterateTags(PU_SPRITE, PU_HUDGFX, callback);
}
// free all textures after each level
void HWR_ClearAllTextures(void)
{
HWD.pfnClearMipMapCache(); // free references to the textures
HWR_FreePatchCache(true);
HWD.pfnClearTextureCache(); // free references to the textures
FreeTextureCache(true);
}
void HWR_FreeColormapCache(void)
// free all texture colormaps after each level
void HWR_ClearColormapCache(void)
{
HWR_FreePatchCache(false);
FreeTextureCache(false);
}
void HWR_InitMapTextures(void)
@ -700,10 +703,10 @@ void HWR_InitMapTextures(void)
static void FreeMapTexture(GLMapTexture_t *tex)
{
HWD.pfnDeleteTexture(&tex->mipmap);
if (tex->mipmap.data)
Z_Free(tex->mipmap.data);
tex->mipmap.data = NULL;
HWD.pfnDeleteTexture(&tex->texture);
if (tex->texture.data)
Z_Free(tex->texture.data);
tex->texture.data = NULL;
}
void HWR_FreeMapTextures(void)
@ -749,7 +752,7 @@ void HWR_SetPalette(RGBA_t *palette)
// hardware driver will flush there own cache if cache is non paletized
// now flush data texture cache so 32 bit texture are recomputed
if (patchformat == GL_TEXFMT_RGBA || textureformat == GL_TEXFMT_RGBA)
if (gl_patchformat == GPU_TEXFMT_RGBA || gl_textureformat == GPU_TEXFMT_RGBA)
{
Z_FreeTag(PU_HWRCACHE);
Z_FreeTag(PU_HWRCACHE_UNLOCKED);
@ -772,27 +775,27 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex)
grtex = &gl_textures[tex];
// Generate texture if missing from the cache
if (!grtex->mipmap.data && !grtex->mipmap.downloaded)
if (!grtex->texture.data && !grtex->texture.downloaded)
HWR_GenerateTexture(tex, grtex);
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grtex->mipmap.downloaded)
HWD.pfnSetTexture(&grtex->mipmap);
HWR_SetCurrentTexture(&grtex->mipmap);
if (!grtex->texture.downloaded)
HWD.pfnSetTexture(&grtex->texture);
HWR_SetCurrentTexture(&grtex->texture);
// The system-memory data can be purged now.
Z_ChangeTag(grtex->mipmap.data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(grtex->texture.data, PU_HWRCACHE_UNLOCKED);
return grtex;
}
static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
static void HWR_CacheFlat(HWRTexture_t *hwrTexture, lumpnum_t flatlumpnum)
{
size_t size, pflatsize;
// setup the texture info
grMipmap->format = GL_TEXFMT_P_8;
grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
hwrTexture->format = GPU_TEXFMT_P_8;
hwrTexture->flags = TF_WRAPXY|TF_CHROMAKEYED;
size = W_LumpLength(flatlumpnum);
@ -821,29 +824,29 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum)
break;
}
grMipmap->width = (UINT16)pflatsize;
grMipmap->height = (UINT16)pflatsize;
hwrTexture->width = (UINT16)pflatsize;
hwrTexture->height = (UINT16)pflatsize;
// the flat raw data needn't be converted with palettized textures
W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum),
PU_HWRCACHE, &grMipmap->data));
PU_HWRCACHE, &hwrTexture->data));
}
static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
static void HWR_CacheTextureAsFlat(HWRTexture_t *hwrTexture, INT32 texturenum)
{
UINT8 *flat;
UINT8 *converted;
size_t size;
// setup the texture info
grMipmap->format = GL_TEXFMT_P_8;
grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
hwrTexture->format = GPU_TEXFMT_P_8;
hwrTexture->flags = TF_WRAPXY|TF_CHROMAKEYED;
grMipmap->width = (UINT16)textures[texturenum]->width;
grMipmap->height = (UINT16)textures[texturenum]->height;
size = (grMipmap->width * grMipmap->height);
hwrTexture->width = (UINT16)textures[texturenum]->width;
hwrTexture->height = (UINT16)textures[texturenum]->height;
size = (hwrTexture->width * hwrTexture->height);
flat = Z_Malloc(size, PU_HWRCACHE, &grMipmap->data);
flat = Z_Malloc(size, PU_HWRCACHE, &hwrTexture->data);
converted = (UINT8 *)Picture_TextureToFlat(texturenum);
M_Memcpy(flat, converted, size);
Z_Free(converted);
@ -852,24 +855,24 @@ static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum)
// Download a Doom 'flat' to the hardware cache and make it ready for use
void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum)
{
GLMipmap_t *grmip;
HWRTexture_t *hwrtex;
patch_t *patch;
if (flatlumpnum == LUMPERROR)
return;
patch = HWR_GetCachedGLPatch(flatlumpnum);
grmip = ((GLPatch_t *)Patch_AllocateHardwarePatch(patch))->mipmap;
if (!grmip->downloaded && !grmip->data)
HWR_CacheFlat(grmip, flatlumpnum);
hwrtex = ((GLPatch_t *)Patch_AllocateHardwarePatch(patch))->texture;
if (!hwrtex->downloaded && !hwrtex->data)
HWR_CacheFlat(hwrtex, flatlumpnum);
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grmip->downloaded)
HWD.pfnSetTexture(grmip);
HWR_SetCurrentTexture(grmip);
if (!hwrtex->downloaded)
HWD.pfnSetTexture(hwrtex);
HWR_SetCurrentTexture(hwrtex);
// The system-memory data can be purged now.
Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(hwrtex->data, PU_HWRCACHE_UNLOCKED);
}
void HWR_GetLevelFlat(levelflat_t *levelflat)
@ -897,16 +900,16 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
grtex = &gl_flats[texturenum];
// Generate flat if missing from the cache
if (!grtex->mipmap.data && !grtex->mipmap.downloaded)
HWR_CacheTextureAsFlat(&grtex->mipmap, texturenum);
if (!grtex->texture.data && !grtex->texture.downloaded)
HWR_CacheTextureAsFlat(&grtex->texture, texturenum);
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grtex->mipmap.downloaded)
HWD.pfnSetTexture(&grtex->mipmap);
HWR_SetCurrentTexture(&grtex->mipmap);
if (!grtex->texture.downloaded)
HWD.pfnSetTexture(&grtex->texture);
HWR_SetCurrentTexture(&grtex->texture);
// The system-memory data can be purged now.
Z_ChangeTag(grtex->mipmap.data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(grtex->texture.data, PU_HWRCACHE_UNLOCKED);
}
else if (levelflat->type == LEVELFLAT_PATCH)
{
@ -919,7 +922,7 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
else if (levelflat->type == LEVELFLAT_PNG)
{
INT32 pngwidth = 0, pngheight = 0;
GLMipmap_t *mipmap = levelflat->mipmap;
HWRTexture_t *texture = levelflat->texture;
UINT8 *flat;
size_t size;
@ -931,28 +934,28 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
levelflat->height = (UINT16)pngheight;
}
// Make the mipmap.
if (mipmap == NULL)
// Make the texture.
if (texture == NULL)
{
mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_LEVEL, NULL);
mipmap->format = GL_TEXFMT_P_8;
mipmap->flags = TF_WRAPXY|TF_CHROMAKEYED;
levelflat->mipmap = mipmap;
texture = Z_Calloc(sizeof(HWRTexture_t), PU_LEVEL, NULL);
texture->format = GPU_TEXFMT_P_8;
texture->flags = TF_WRAPXY|TF_CHROMAKEYED;
levelflat->texture = texture;
}
if (!mipmap->data && !mipmap->downloaded)
if (!texture->data && !texture->downloaded)
{
mipmap->width = levelflat->width;
mipmap->height = levelflat->height;
size = (mipmap->width * mipmap->height);
flat = Z_Malloc(size, PU_LEVEL, &mipmap->data);
texture->width = levelflat->width;
texture->height = levelflat->height;
size = (texture->width * texture->height);
flat = Z_Malloc(size, PU_LEVEL, &texture->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);
// Tell the hardware driver to bind the current texture to the flat's texture
HWD.pfnSetTexture(texture);
}
#endif
else // set no texture
@ -960,21 +963,21 @@ void HWR_GetLevelFlat(levelflat_t *levelflat)
}
// --------------------+
// HWR_LoadPatchMipmap : Generates a patch into a mipmap, usually the mipmap inside the patch itself
// HWR_LoadPatchTexture : Generates a patch into a texture, usually the texture inside the patch itself
// --------------------+
static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *grMipmap)
static void HWR_LoadPatchTexture(patch_t *patch, HWRTexture_t *hwrTexture)
{
GLPatch_t *grPatch = patch->hardware;
if (!grMipmap->downloaded && !grMipmap->data)
HWR_MakePatch(patch, grPatch, grMipmap, true);
if (!hwrTexture->downloaded && !hwrTexture->data)
HWR_MakePatch(patch, grPatch, hwrTexture, true);
// If hardware does not have the texture, then call pfnSetTexture to upload it
if (!grMipmap->downloaded)
HWD.pfnSetTexture(grMipmap);
HWR_SetCurrentTexture(grMipmap);
if (!hwrTexture->downloaded)
HWD.pfnSetTexture(hwrTexture);
HWR_SetCurrentTexture(hwrTexture);
// The system-memory data can be purged now.
Z_ChangeTag(grMipmap->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(hwrTexture->data, PU_HWRCACHE_UNLOCKED);
}
// -----------------+
@ -984,7 +987,7 @@ void HWR_GetPatch(patch_t *patch)
{
if (!patch->hardware)
Patch_CreateGL(patch);
HWR_LoadPatchMipmap(patch, ((GLPatch_t *)patch->hardware)->mipmap);
HWR_LoadPatchTexture(patch, ((GLPatch_t *)patch->hardware)->texture);
}
// -------------------+
@ -993,7 +996,7 @@ void HWR_GetPatch(patch_t *patch)
void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap)
{
GLPatch_t *grPatch;
GLMipmap_t *grMipmap, *newMipmap;
HWRTexture_t *hwrTexture, *newTexture;
if (!patch->hardware)
Patch_CreateGL(patch);
@ -1008,29 +1011,25 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap)
// search for the mimmap
// skip the first (no colormap translated)
for (grMipmap = grPatch->mipmap; grMipmap->nextcolormap; )
for (hwrTexture = grPatch->texture; hwrTexture->nextcolormap; )
{
grMipmap = grMipmap->nextcolormap;
if (grMipmap->colormap == colormap)
hwrTexture = hwrTexture->nextcolormap;
if (hwrTexture->colormap == colormap)
{
HWR_LoadPatchMipmap(patch, grMipmap);
HWR_LoadPatchTexture(patch, hwrTexture);
return;
}
}
// not found, create it!
// If we are here, the sprite with the current colormap is not already in hardware memory
//BP: WARNING: don't free it manually without clearing the cache of harware renderer
// (it have a liste of mipmap)
// this malloc is cleared in HWR_FreeColormapCache
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
newMipmap = calloc(1, sizeof (*newMipmap));
if (newMipmap == NULL)
newTexture = calloc(1, sizeof (*newTexture));
if (newTexture == NULL)
I_Error("%s: Out of memory", "HWR_GetMappedPatch");
grMipmap->nextcolormap = newMipmap;
hwrTexture->nextcolormap = newTexture;
newMipmap->colormap = colormap;
HWR_LoadPatchMipmap(patch, newMipmap);
newTexture->colormap = colormap;
HWR_LoadPatchTexture(patch, newTexture);
}
void HWR_UnlockCachedPatch(GLPatch_t *gpatch)
@ -1038,17 +1037,17 @@ void HWR_UnlockCachedPatch(GLPatch_t *gpatch)
if (!gpatch)
return;
Z_ChangeTag(gpatch->mipmap->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(gpatch->texture->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(gpatch, PU_HWRPATCHINFO_UNLOCKED);
}
static const INT32 picmode2GR[] =
{
GL_TEXFMT_P_8, // PALETTE
0, // INTENSITY (unsupported yet)
GL_TEXFMT_ALPHA_INTENSITY_88, // INTENSITY_ALPHA (corona use this)
0, // RGB24 (unsupported yet)
GL_TEXFMT_RGBA, // RGBA32 (opengl only)
GPU_TEXFMT_P_8, // PALETTE
0, // INTENSITY (unsupported yet)
GPU_TEXFMT_ALPHA_INTENSITY_88, // INTENSITY_ALPHA (corona use this)
0, // RGB24 (unsupported yet)
GPU_TEXFMT_RGBA, // RGBA32
};
static void HWR_DrawPicInCache(UINT8 *block, INT32 pblockwidth, INT32 pblockheight,
@ -1125,7 +1124,7 @@ patch_t *HWR_GetPic(lumpnum_t lumpnum)
patch_t *patch = HWR_GetCachedGLPatch(lumpnum);
GLPatch_t *grPatch = (GLPatch_t *)(patch->hardware);
if (!grPatch->mipmap->downloaded && !grPatch->mipmap->data)
if (!grPatch->texture->downloaded && !grPatch->texture->data)
{
pic_t *pic;
UINT8 *block;
@ -1136,40 +1135,40 @@ patch_t *HWR_GetPic(lumpnum_t lumpnum)
patch->height = SHORT(pic->height);
len = W_LumpLength(lumpnum) - sizeof (pic_t);
grPatch->mipmap->width = (UINT16)patch->width;
grPatch->mipmap->height = (UINT16)patch->height;
grPatch->texture->width = (UINT16)patch->width;
grPatch->texture->height = (UINT16)patch->height;
if (pic->mode == PALETTE)
grPatch->mipmap->format = textureformat; // can be set by driver
grPatch->texture->format = gl_textureformat; // can be set by driver
else
grPatch->mipmap->format = picmode2GR[pic->mode];
grPatch->texture->format = picmode2GR[pic->mode];
Z_Free(grPatch->mipmap->data);
Z_Free(grPatch->texture->data);
// allocate block
block = MakeBlock(grPatch->mipmap);
block = MakeBlock(grPatch->texture);
if (patch->width == SHORT(pic->width) &&
patch->height == SHORT(pic->height) &&
format2bpp(grPatch->mipmap->format) == format2bpp(picmode2GR[pic->mode]))
format2bpp(grPatch->texture->format) == format2bpp(picmode2GR[pic->mode]))
{
// no conversion needed
M_Memcpy(grPatch->mipmap->data, pic->data,len);
M_Memcpy(grPatch->texture->data, pic->data,len);
}
else
HWR_DrawPicInCache(block, SHORT(pic->width), SHORT(pic->height),
SHORT(pic->width)*format2bpp(grPatch->mipmap->format),
SHORT(pic->width)*format2bpp(grPatch->texture->format),
pic,
format2bpp(grPatch->mipmap->format));
format2bpp(grPatch->texture->format));
Z_Unlock(pic);
Z_ChangeTag(block, PU_HWRCACHE_UNLOCKED);
grPatch->mipmap->flags = 0;
grPatch->texture->flags = 0;
grPatch->max_s = grPatch->max_t = 1.0f;
}
HWD.pfnSetTexture(grPatch->mipmap);
//CONS_Debug(DBG_RENDER, "picloaded at %x as texture %d\n",grPatch->mipmap->data, grPatch->mipmap->downloaded);
HWD.pfnSetTexture(grPatch->texture);
//CONS_Debug(DBG_RENDER, "picloaded at %x as texture %d\n",grPatch->texture->data, grPatch->texture->downloaded);
return patch;
}
@ -1192,12 +1191,12 @@ patch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum)
}
// Need to do this because they aren't powers of 2
static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 pblockheight,
static void HWR_DrawFadeMaskInCache(HWRTexture_t *texture, INT32 pblockwidth, INT32 pblockheight,
lumpnum_t fademasklumpnum, UINT16 fmwidth, UINT16 fmheight)
{
INT32 i,j;
fixed_t posx, posy, stepx, stepy;
UINT8 *block = mipmap->data; // places the data directly into here
UINT8 *block = texture->data; // places the data directly into here
UINT8 *flat;
UINT8 *dest, *src, texel;
RGBA_t col;
@ -1212,7 +1211,7 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32
for (j = 0; j < pblockheight; j++)
{
posx = 0;
dest = &block[j*(mipmap->width)]; // 1bpp
dest = &block[j*(texture->width)]; // 1bpp
src = &flat[(posy>>FRACBITS)*SHORT(fmwidth)];
for (i = 0; i < pblockwidth;i++)
{
@ -1230,14 +1229,14 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32
Z_Free(flat);
}
static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum)
static void HWR_CacheFadeMask(HWRTexture_t *hwrTexture, lumpnum_t fademasklumpnum)
{
size_t size;
UINT16 fmheight = 0, fmwidth = 0;
// setup the texture info
grMipmap->format = GL_TEXFMT_ALPHA_8; // put the correct alpha levels straight in so I don't need to convert it later
grMipmap->flags = 0;
hwrTexture->format = GPU_TEXFMT_ALPHA_8; // put the correct alpha levels straight in so I don't need to convert it later
hwrTexture->flags = 0;
size = W_LumpLength(fademasklumpnum);
@ -1266,12 +1265,12 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum)
}
// Thankfully, this will still work for this scenario
grMipmap->width = fmwidth;
grMipmap->height = fmheight;
hwrTexture->width = fmwidth;
hwrTexture->height = fmheight;
MakeBlock(grMipmap);
MakeBlock(hwrTexture);
HWR_DrawFadeMaskInCache(grMipmap, fmwidth, fmheight, fademasklumpnum, fmwidth, fmheight);
HWR_DrawFadeMaskInCache(hwrTexture, fmwidth, fmheight, fademasklumpnum, fmwidth, fmheight);
// I DO need to convert this because it isn't power of 2 and we need the alpha
}
@ -1280,14 +1279,14 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum)
void HWR_GetFadeMask(lumpnum_t fademasklumpnum)
{
patch_t *patch = HWR_GetCachedGLPatch(fademasklumpnum);
GLMipmap_t *grmip = ((GLPatch_t *)Patch_AllocateHardwarePatch(patch))->mipmap;
if (!grmip->downloaded && !grmip->data)
HWR_CacheFadeMask(grmip, fademasklumpnum);
HWRTexture_t *hwrtex = ((GLPatch_t *)Patch_AllocateHardwarePatch(patch))->texture;
if (!hwrtex->downloaded && !hwrtex->data)
HWR_CacheFadeMask(hwrtex, fademasklumpnum);
HWD.pfnSetTexture(grmip);
HWD.pfnSetTexture(hwrtex);
// The system-memory data can be purged now.
Z_ChangeTag(grmip->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(hwrtex->data, PU_HWRCACHE_UNLOCKED);
}
#endif //HWRENDER

View file

@ -22,28 +22,27 @@
#include "../doomdef.h"
#include "../screen.h"
// ==========================================================================
// TEXTURE INFO
// ==========================================================================
typedef enum GLTextureFormat_e
enum GLTextureFormat_e
{
GL_TEXFMT_P_8 = 0x01, /* 8-bit palette */
GL_TEXFMT_AP_88 = 0x02, /* 8-bit alpha, 8-bit palette */
GPU_TEXFMT_P_8 = 0x01, /* 8-bit palette */
GPU_TEXFMT_AP_88 = 0x02, /* 8-bit alpha, 8-bit palette */
GL_TEXFMT_RGBA = 0x10, /* 32 bit RGBA! */
GPU_TEXFMT_RGBA = 0x10, /* 32 bit RGBA! */
GL_TEXFMT_ALPHA_8 = 0x20, /* (0..0xFF) alpha */
GL_TEXFMT_INTENSITY_8 = 0x21, /* (0..0xFF) intensity */
GL_TEXFMT_ALPHA_INTENSITY_88 = 0x22,
} GLTextureFormat_t;
GPU_TEXFMT_ALPHA_8 = 0x20, /* (0..0xFF) alpha */
GPU_TEXFMT_INTENSITY_8 = 0x21, /* (0..0xFF) intensity */
GPU_TEXFMT_ALPHA_INTENSITY_88 = 0x22,
};
typedef enum GLTextureFormat_e GLTextureFormat_t;
// data holds the address of the graphics data cached in heap memory
// NULL if the texture is not in Doom heap cache.
struct GLMipmap_s
// NULL if the texture is not in Doom heap cache.
struct HWRTexture_s
{
// for TexDownloadMipMap
GLTextureFormat_t format;
void *data;
@ -52,32 +51,26 @@ struct GLMipmap_s
UINT16 width;
UINT32 downloaded; // The GPU has this texture.
struct GLMipmap_s *nextcolormap;
struct HWRTexture_s *nextcolormap;
const UINT8 *colormap;
struct GLMipmap_s *nextmipmap; // Linked list of all textures
};
typedef struct GLMipmap_s GLMipmap_t;
typedef struct HWRTexture_s HWRTexture_t;
//
// Doom texture info, as cached for hardware rendering
//
// Texture info, as cached for hardware rendering
struct GLMapTexture_s
{
GLMipmap_t mipmap;
float scaleX; //used for scaling textures on walls
float scaleY;
HWRTexture_t texture;
float scaleX;
float scaleY;
};
typedef struct GLMapTexture_s GLMapTexture_t;
// a cached patch as converted to hardware format
// A cached patch, as converted to hardware format
struct GLPatch_s
{
float max_s,max_t;
GLMipmap_t *mipmap;
} ATTRPACK;
HWRTexture_t *texture;
};
typedef struct GLPatch_s GLPatch_t;
#endif //_HWR_DATA_

View file

@ -18,52 +18,26 @@
#define ZCLIP_PLANE 4.0f // Used for the actual game drawing
#define NZCLIP_PLANE 0.9f // Seems to be only used for the HUD and screen textures
// ==========================================================================
// SIMPLE TYPES
// ==========================================================================
typedef long FINT;
typedef unsigned long FUINT;
typedef unsigned char FUBYTE;
typedef unsigned long FBITFIELD;
#ifndef __MINGW32__
typedef float FLOAT;
#endif
typedef unsigned char FBOOLEAN;
// ==========================================================================
// COLORS
// ==========================================================================
// byte value for paletted graphics, which represent the transparent color
#define HWR_PATCHES_CHROMAKEY_COLORINDEX 255
//#define HWR_CHROMAKEY_EQUIVALENTCOLORINDEX 130
#define GPU_PATCHES_CHROMAKEY_COLORINDEX 255
// the chroma key color shows on border sprites, set it to black
#define HWR_PATCHES_CHROMAKEY_COLORVALUE (0x00000000) //RGBA format as in grSstWinOpen()
#define GPU_PATCHES_CHROMAKEY_COLORVALUE (0x00000000) //RGBA format as in grSstWinOpen()
#define GPU_DEFAULTMIX 0x00000000
#define GPU_DEFAULTFOG 0xFF000000
// RGBA Color components with float type ranging [ 0 ... 1 ]
struct FRGBAFloat
{
FLOAT red;
FLOAT green;
FLOAT blue;
FLOAT alpha;
float red, green, blue, alpha;
};
typedef struct FRGBAFloat FRGBAFloat;
struct FColorARGB
{
FUBYTE alpha;
FUBYTE red;
FUBYTE green;
FUBYTE blue;
};
typedef struct FColorARGB ARGB_t;
typedef struct FColorARGB FColorARGB;
// ==========================================================================
// VECTORS
// ==========================================================================
@ -71,21 +45,15 @@ typedef struct FColorARGB FColorARGB;
// Simple 2D coordinate
typedef struct
{
FLOAT x,y;
float x,y;
} F2DCoord, v2d_t;
// Simple 3D vector
typedef struct FVector
{
FLOAT x,y,z;
float x,y,z;
} FVector;
// ======================
// wallVert3D
// ----------------------
// :crab: IS GONE! :crab:
// ======================
// -----------
// structures
// -----------
@ -102,21 +70,21 @@ typedef struct FVector
typedef struct
{
FLOAT x,y,z; // position
float x,y,z; // position
#ifdef USE_FTRANSFORM_ANGLEZ
FLOAT anglex,angley,anglez; // aimingangle / viewangle
float anglex,angley,anglez; // aimingangle / viewangle
#else
FLOAT anglex,angley; // aimingangle / viewangle
float anglex,angley; // aimingangle / viewangle
#endif
FLOAT scalex,scaley,scalez;
FLOAT fovxangle, fovyangle;
float scalex,scaley,scalez;
float fovxangle, fovyangle;
UINT8 splitscreen;
boolean flip; // screenflip
boolean roll;
SINT8 rollflip;
FLOAT rollangle; // done to not override USE_FTRANSFORM_ANGLEZ
float rollangle; // done to not override USE_FTRANSFORM_ANGLEZ
UINT8 rotaxis;
FLOAT centerx, centery;
float centerx, centery;
#ifdef USE_FTRANSFORM_MIRROR
boolean mirror; // SRB2Kart: Encore Mode
#endif
@ -127,83 +95,11 @@ typedef struct
// Transformed vector, as passed to HWR API
typedef struct
{
FLOAT x,y,z;
FLOAT s; // s texture ordinate (s over w)
FLOAT t; // t texture ordinate (t over w)
float x, y, z;
float s; // s texture ordinate (s over w)
float t; // t texture ordinate (t over w)
} FOutVector;
#ifdef GL_SHADERS
// Predefined shader types
enum
{
SHADER_DEFAULT = 0,
SHADER_FLOOR,
SHADER_WALL,
SHADER_SPRITE,
SHADER_MODEL, SHADER_MODEL_LIGHTING,
SHADER_WATER,
SHADER_FOG,
SHADER_SKY,
NUMBASESHADERS,
};
// Maximum amount of shader programs
// Must be higher than NUMBASESHADERS
#define HWR_MAXSHADERS 16
// Shader sources (vertex and fragment)
typedef struct
{
char *vertex;
char *fragment;
} shadersource_t;
// Custom shader reference table
typedef struct
{
const char *type;
INT32 id;
} customshaderxlat_t;
#endif
typedef struct vbo_vertex_s
{
float x, y, z;
float u, v;
unsigned char r, g, b, a;
} gl_skyvertex_t;
typedef enum gl_skyloopmode_e
{
HWD_SKYLOOP_FAN,
HWD_SKYLOOP_STRIP
} gl_skyloopmode_t;
typedef struct
{
gl_skyloopmode_t mode;
int vertexcount;
int vertexindex;
boolean use_texture;
} gl_skyloopdef_t;
typedef struct
{
unsigned int vbo;
int rows, columns;
int loopcount;
int detail, vertex_count;
int texture, width, height;
boolean rebuild; // VBO needs to be rebuilt
gl_skyloopdef_t *loops;
gl_skyvertex_t *data;
} gl_sky_t;
// ==========================================================================
// RENDER MODES
// ==========================================================================
@ -240,7 +136,6 @@ enum EPolyFlags
PF_ForceWrapY = 0x00040000 // Forces repeat texture on Y
};
enum ESurfFlags
{
SF_DYNLIGHT = 0x00000001,
@ -255,71 +150,141 @@ enum ETextureFlags
TF_TRANSPARENT = 0x00000040, // texture with some alpha == 0
};
typedef struct GLMipmap_s FTextureInfo;
struct FTextureInfo
{
UINT32 width, height;
UINT32 name;
UINT32 format;
struct HWRTexture_s *texture;
struct FTextureInfo *prev, *next;
};
typedef struct FTextureInfo FTextureInfo;
// jimita 14032019
struct FLightInfo
{
FUINT light_level;
FUINT fade_start;
FUINT fade_end;
UINT32 LightLevel;
UINT32 FadeStart, FadeEnd;
};
typedef struct FLightInfo FLightInfo;
// Description of a renderable surface
struct FSurfaceInfo
{
FUINT PolyFlags;
UINT32 PolyFlags;
RGBA_t PolyColor;
RGBA_t TintColor;
RGBA_t FadeColor;
FLightInfo LightInfo; // jimita 14032019
FLightInfo LightInfo;
};
typedef struct FSurfaceInfo FSurfaceInfo;
#define GL_DEFAULTMIX 0x00000000
#define GL_DEFAULTFOG 0xFF000000
//Hurdler: added for backward compatibility
enum hwdsetspecialstate
// Hurdler: added for backward compatibility
enum EGPUState
{
HWD_SET_MODEL_LIGHTING = 1,
HWD_SET_SHADERS,
HWD_SET_TEXTUREFILTERMODE,
HWD_SET_TEXTUREANISOTROPICMODE,
HWD_NUMSTATE
GPU_STATE_TEXTUREFILTERMODE,
GPU_STATE_TEXTUREANISOTROPICMODE,
GPU_STATE_SHADERS,
GPU_STATE_MODEL_LIGHTING
};
typedef enum hwdsetspecialstate hwdspecialstate_t;
// Lactozilla: Shader options
enum hwdshaderoption
enum EShaderOption
{
HWD_SHADEROPTION_OFF,
HWD_SHADEROPTION_ON,
HWD_SHADEROPTION_NOCUSTOM,
GPU_SHADEROPTION_OFF,
GPU_SHADEROPTION_ON,
GPU_SHADEROPTION_NOCUSTOM,
};
typedef enum hwdshaderoption hwdshaderoption_t;
// Lactozilla: Shader info
// Generally set at the start of the frame.
enum hwdshaderinfo
enum EShaderInfo
{
HWD_SHADERINFO_LEVELTIME = 1,
GPU_SHADERINFO_LEVELTIME = 1,
};
typedef enum hwdshaderinfo hwdshaderinfo_t;
enum hwdfiltermode
enum EFilterMode
{
HWD_SET_TEXTUREFILTER_POINTSAMPLED,
HWD_SET_TEXTUREFILTER_BILINEAR,
HWD_SET_TEXTUREFILTER_TRILINEAR,
HWD_SET_TEXTUREFILTER_MIXED1,
HWD_SET_TEXTUREFILTER_MIXED2,
HWD_SET_TEXTUREFILTER_MIXED3,
GPU_TEXFILTER_POINTSAMPLED,
GPU_TEXFILTER_BILINEAR,
GPU_TEXFILTER_TRILINEAR,
GPU_TEXFILTER_MIXED1,
GPU_TEXFILTER_MIXED2,
GPU_TEXFILTER_MIXED3,
};
#ifdef GL_SHADERS
// Predefined shader types
enum
{
SHADER_DEFAULT = 0,
SHADER_FLOOR,
SHADER_WALL,
SHADER_SPRITE,
SHADER_MODEL, SHADER_MODEL_LIGHTING,
SHADER_WATER,
SHADER_FOG,
SHADER_SKY,
NUMBASESHADERS,
};
// Maximum amount of shader programs
// Must be higher than NUMBASESHADERS
#define HWR_MAXSHADERS 16
// Shader sources (vertex and fragment)
struct FShaderSource
{
char *vertex;
char *fragment;
};
typedef struct FShaderSource FShaderSource;
// Custom shader reference table
struct FShaderReferenceArray
{
const char *type;
INT32 id;
};
typedef struct FShaderReferenceArray FShaderReferenceArray;
#endif
struct FSkyVertex
{
float x, y, z;
float u, v;
unsigned char r, g, b, a;
};
typedef struct FSkyVertex FSkyVertex;
enum ESkyLoopMode
{
GPU_SKYLOOP_FAN,
GPU_SKYLOOP_STRIP
};
struct FSkyLoopDef
{
int mode;
int vertexcount;
int vertexindex;
boolean use_texture;
};
typedef struct FSkyLoopDef FSkyLoopDef;
struct FSkyDome
{
unsigned int vbo;
int rows, columns;
int loopcount;
int detail, vertex_count;
int texture, width, height;
boolean rebuild; // VBO needs to be rebuilt
FSkyLoopDef *loops;
FSkyVertex *data;
};
typedef struct FSkyDome FSkyDome;
#endif //_HWR_DEFS_

View file

@ -71,7 +71,7 @@ static UINT8 softwaretranstogl_lo[11] = { 0, 12, 24, 36, 48, 60, 71, 83, 95,111
void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option)
{
FOutVector v[4];
FBITFIELD flags;
UINT32 flags;
GLPatch_t *hwrPatch;
// 3--2
@ -131,7 +131,7 @@ 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)
{
FOutVector v[4];
FBITFIELD flags;
UINT32 flags;
float cx = FIXED_TO_FLOAT(x);
float cy = FIXED_TO_FLOAT(y);
UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT);
@ -385,7 +385,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p
void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h)
{
FOutVector v[4];
FBITFIELD flags;
UINT32 flags;
float cx = FIXED_TO_FLOAT(x);
float cy = FIXED_TO_FLOAT(y);
UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT);

View file

@ -35,21 +35,20 @@ EXPORT void HWRAPI(GetModeList) (vmode_t **pvidmodes, INT32 *numvidmodes);
EXPORT void HWRAPI(SetPalette) (RGBA_t *ppal);
EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl);
EXPORT void HWRAPI(Draw2DLine) (F2DCoord *v1, F2DCoord *v2, RGBA_t Color);
EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags);
EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, UINT32 *IndexArray);
EXPORT void HWRAPI(RenderSkyDome) (gl_sky_t *sky);
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(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, UINT32 iNumPts, UINT32 PolyFlags);
EXPORT void HWRAPI(DrawIndexedTriangles) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, UINT32 iNumPts, UINT32 PolyFlags, UINT32 *IndexArray);
EXPORT void HWRAPI(RenderSkyDome) (FSkyDome *sky);
EXPORT void HWRAPI(SetBlend) (UINT32 PolyFlags);
EXPORT void HWRAPI(ClearBuffer) (boolean ColorMask, boolean DepthMask, FRGBAFloat *ClearColor);
EXPORT void HWRAPI(SetTexture) (HWRTexture_t *TexInfo);
EXPORT void HWRAPI(UpdateTexture) (HWRTexture_t *TexInfo);
EXPORT void HWRAPI(DeleteTexture) (HWRTexture_t *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);
EXPORT void HWRAPI(ClearCacheList) (void);
EXPORT void HWRAPI(ClearTextureCache) (void);
//Hurdler: added for backward compatibility
EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value);
EXPORT void HWRAPI(SetState) (INT32 State, INT32 Value);
//Hurdler: added for new development
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface);
@ -75,7 +74,7 @@ EXPORT void HWRAPI(CleanShaders) (void);
EXPORT void HWRAPI(SetShader) (int type);
EXPORT void HWRAPI(UnSetShader) (void);
EXPORT void HWRAPI(SetShaderInfo) (hwdshaderinfo_t info, INT32 value);
EXPORT void HWRAPI(SetShaderInfo) (INT32 info, INT32 value);
EXPORT void HWRAPI(LoadCustomShader) (int number, char *code, size_t size, boolean isfragment);
// ==========================================================================
@ -100,9 +99,8 @@ struct hwdriver_s
DeleteTexture pfnDeleteTexture;
ReadRect pfnReadRect;
GClipRect pfnGClipRect;
ClearMipMapCache pfnClearMipMapCache;
ClearCacheList pfnClearCacheList;
SetSpecialState pfnSetSpecialState;//Hurdler: added for backward compatibility
ClearTextureCache pfnClearTextureCache;
SetState pfnSetState;
DrawModel pfnDrawModel;
CreateModelVBOs pfnCreateModelVBOs;
SetTransform pfnSetTransform;

View file

@ -121,10 +121,9 @@ void HWR_GetLevelFlat(levelflat_t *levelflat);
void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum);
void HWR_FreeTexture(patch_t *patch);
void HWR_FreeTextureData(patch_t *patch);
void HWR_FreeTextureColormaps(patch_t *patch);
void HWR_ClearAllTextures(void);
void HWR_FreeColormapCache(void);
void HWR_ClearColormapCache(void);
void HWR_UnlockCachedPatch(GLPatch_t *gpatch);
void HWR_SetPalette(RGBA_t *palette);
@ -133,7 +132,7 @@ void HWR_SetPalette(RGBA_t *palette);
// --------
// hw_draw.c
// --------
extern INT32 patchformat;
extern INT32 textureformat;
extern INT32 gl_patchformat;
extern INT32 gl_textureformat;
#endif //_HW_GLOB_

View file

@ -1206,8 +1206,8 @@ void HWR_DL_AddLight(gl_vissprite_t *spr, GLPatch_t *patch)
dynlights->nb++;
}
static GLMipmap_t lightmappatchmipmap;
static GLPatch_t lightmappatch = { .mipmap = &lightmappatchmipmap };
static HWRTexture_t lightmappatchtexture;
static GLPatch_t lightmappatch = { .texture = &lightmappatchtexture };
void HWR_InitLight(void)
{
@ -1217,7 +1217,7 @@ void HWR_InitLight(void)
for (i = 0;i < NUMLIGHTS;i++)
lspr[i].dynamic_sqrradius = lspr[i].dynamic_radius*lspr[i].dynamic_radius;
lightmappatch.mipmap->downloaded = false;
lightmappatch.texture->downloaded = false;
coronalumpnum = W_CheckNumForName("CORONA");
}
@ -1228,10 +1228,10 @@ static void HWR_SetLight(void)
{
int i, j;
if (!lightmappatch.mipmap->downloaded && !lightmappatch.mipmap->data)
if (!lightmappatch.texture->downloaded && !lightmappatch.texture->data)
{
UINT16 *Data = Z_Malloc(129*128*sizeof (UINT16), PU_HWRCACHE, &lightmappatch.mipmap->data);
UINT16 *Data = Z_Malloc(129*128*sizeof (UINT16), PU_HWRCACHE, &lightmappatch.texture->data);
for (i = 0; i < 128; i++)
{
@ -1244,18 +1244,18 @@ static void HWR_SetLight(void)
Data[i*128+j] = 0;
}
}
lightmappatch.mipmap->format = GL_TEXFMT_ALPHA_INTENSITY_88;
lightmappatch.texture->format = GPU_TEXFMT_ALPHA_INTENSITY_88;
lightmappatch.width = 128;
lightmappatch.height = 128;
lightmappatch.mipmap->width = 128;
lightmappatch.mipmap->height = 128;
lightmappatch.mipmap->flags = 0; //TF_WRAPXY; // DEBUG: view the overdraw !
lightmappatch.texture->width = 128;
lightmappatch.texture->height = 128;
lightmappatch.texture->flags = 0; //TF_WRAPXY; // DEBUG: view the overdraw !
}
HWD.pfnSetTexture(lightmappatch.mipmap);
HWD.pfnSetTexture(lightmappatch.texture);
// The system-memory data can be purged now.
Z_ChangeTag(lightmappatch.mipmap->data, PU_HWRCACHE_UNLOCKED);
Z_ChangeTag(lightmappatch.texture->data, PU_HWRCACHE_UNLOCKED);
}
//**********************************************************

View file

@ -65,9 +65,9 @@ static void HWR_ProjectSprite(mobj_t *thing);
static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing);
#endif
void HWR_AddTransparentFloor(levelflat_t *levelflat, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap);
void HWR_AddTransparentFloor(levelflat_t *levelflat, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, UINT32 blend, boolean fogplane, extracolormap_t *planecolormap);
void HWR_AddTransparentPolyobjectFloor(levelflat_t *levelflat, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight,
INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap);
INT32 lightlevel, INT32 alpha, sector_t *FOFSector, UINT32 blend, extracolormap_t *planecolormap);
boolean drawsky = true;
@ -178,8 +178,8 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
RGBA_t poly_color, tint_color, fade_color;
poly_color.rgba = 0xFFFFFFFF;
tint_color.rgba = (colormap != NULL) ? (UINT32)colormap->rgba : GL_DEFAULTMIX;
fade_color.rgba = (colormap != NULL) ? (UINT32)colormap->fadergba : GL_DEFAULTFOG;
tint_color.rgba = (colormap != NULL) ? (UINT32)colormap->rgba : GPU_DEFAULTMIX;
fade_color.rgba = (colormap != NULL) ? (UINT32)colormap->fadergba : GPU_DEFAULTFOG;
// Crappy backup coloring if you can't do shaders
if (!cv_glshaders.value || !gl_shadersavailable)
@ -224,9 +224,9 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
Surface->PolyColor.rgba = poly_color.rgba;
Surface->TintColor.rgba = tint_color.rgba;
Surface->FadeColor.rgba = fade_color.rgba;
Surface->LightInfo.light_level = light_level;
Surface->LightInfo.fade_start = (colormap != NULL) ? colormap->fadestart : 0;
Surface->LightInfo.fade_end = (colormap != NULL) ? colormap->fadeend : 31;
Surface->LightInfo.LightLevel = light_level;
Surface->LightInfo.FadeStart = (colormap != NULL) ? colormap->fadestart : 0;
Surface->LightInfo.FadeEnd = (colormap != NULL) ? colormap->fadeend : 31;
}
UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if this can work
@ -234,7 +234,7 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if
RGBA_t realcolor, surfcolor;
INT32 alpha;
realcolor.rgba = (colormap != NULL) ? colormap->rgba : GL_DEFAULTMIX;
realcolor.rgba = (colormap != NULL) ? colormap->rgba : GPU_DEFAULTMIX;
if (cv_glshaders.value && gl_shadersavailable)
{
@ -259,7 +259,7 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if
return surfcolor.s.alpha;
}
static FUINT HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y)
static UINT32 HWR_CalcWallLight(UINT32 lightnum, fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y)
{
INT16 finallight = lightnum;
@ -295,10 +295,10 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t
}
}
return (FUINT)finallight;
return (UINT32)finallight;
}
static FUINT HWR_CalcSlopeLight(FUINT lightnum, angle_t dir, fixed_t delta)
static UINT32 HWR_CalcSlopeLight(UINT32 lightnum, angle_t dir, fixed_t delta)
{
INT16 finallight = lightnum;
@ -339,7 +339,7 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, angle_t dir, fixed_t delta)
}
}
return (FUINT)finallight;
return (UINT32)finallight;
}
// ==========================================================================
@ -351,7 +351,7 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, angle_t dir, fixed_t delta)
// -----------------+
// HWR_RenderPlane : Render a floor or ceiling convex polygon
// -----------------+
static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, levelflat_t *levelflat, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap)
static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, UINT32 PolyFlags, INT32 lightlevel, levelflat_t *levelflat, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap)
{
polyvertex_t * pv;
float height; //constant y for all points on the convex flat polygon
@ -702,7 +702,7 @@ static void HWR_RenderSkyPlane(extrasubsector_t *xsub, fixed_t fixedheight)
#endif //doplanes
FBITFIELD HWR_GetBlendModeFlag(INT32 ast)
UINT32 HWR_GetBlendModeFlag(INT32 ast)
{
switch (ast)
{
@ -742,7 +742,7 @@ UINT8 HWR_GetTranstableAlpha(INT32 transtablenum)
return 0xff;
}
FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf)
UINT32 HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf)
{
if (!transtablenum)
{
@ -754,7 +754,7 @@ FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf
return HWR_GetBlendModeFlag(style);
}
FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf)
UINT32 HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf)
{
if (!transtablenum)
{
@ -766,7 +766,7 @@ FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf)
return PF_Translucent;
}
static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, UINT32 blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
// ==========================================================================
// Wall generation from subsector segs
@ -783,7 +783,7 @@ static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, I
//
// HWR_ProjectWall
//
static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blendmode, INT32 lightlevel, extracolormap_t *wallcolormap)
static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, UINT32 blendmode, INT32 lightlevel, extracolormap_t *wallcolormap)
{
HWR_Lighting(pSurf, lightlevel, wallcolormap);
HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode|PF_Modulated|PF_Occlude, SHADER_WALL, false); // wall shader
@ -857,7 +857,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
INT32 solid, i;
lightlist_t * list = sector->lightlist;
const UINT8 alpha = Surf->PolyColor.s.alpha;
FUINT lightnum = HWR_CalcWallLight(sector->lightlevel, v1x, v1y, v2x, v2y);
UINT32 lightnum = HWR_CalcWallLight(sector->lightlevel, v1x, v1y, v2x, v2y);
extracolormap_t *colormap = NULL;
realtop = top = wallVerts[3].y;
@ -1046,7 +1046,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
fixed_t h, l; // 3D sides and 2s middle textures
fixed_t hS, lS;
FUINT lightnum = 0; // shut up compiler
UINT32 lightnum = 0; // shut up compiler
extracolormap_t *colormap;
FSurfaceInfo Surf;
@ -1184,7 +1184,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (gl_frontsector->numlights)
HWR_SplitWall(gl_frontsector, wallVerts, gl_toptexture, &Surf, FF_CUTLEVEL, NULL);
else if (grTex->mipmap.flags & TF_TRANSPARENT)
else if (grTex->texture.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, &Surf, gl_toptexture, PF_Environment, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
@ -1250,7 +1250,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (gl_frontsector->numlights)
HWR_SplitWall(gl_frontsector, wallVerts, gl_bottomtexture, &Surf, FF_CUTLEVEL, NULL);
else if (grTex->mipmap.flags & TF_TRANSPARENT)
else if (grTex->texture.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, &Surf, gl_bottomtexture, PF_Environment, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
@ -1258,7 +1258,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture);
if (gl_midtexture)
{
FBITFIELD blendmode;
UINT32 blendmode;
sector_t *front, *back;
fixed_t popentop, popenbottom, polytop, polybottom, lowcut, highcut;
fixed_t texturevpeg = 0;
@ -1557,7 +1557,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, &Surf, FF_CUTLEVEL, NULL);
else
{
if (grTex->mipmap.flags & TF_TRANSPARENT)
if (grTex->texture.flags & TF_TRANSPARENT)
HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, PF_Environment, false, lightnum, colormap);
else
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
@ -1707,7 +1707,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
}
if (rover->flags & FF_FOG)
{
FBITFIELD blendmode;
UINT32 blendmode;
blendmode = PF_Fog|PF_NoTexture;
@ -1723,7 +1723,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
}
else
{
FBITFIELD blendmode = PF_Masked;
UINT32 blendmode = PF_Masked;
if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256)
{
@ -1819,7 +1819,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (rover->flags & FF_FOG)
{
FBITFIELD blendmode;
UINT32 blendmode;
blendmode = PF_Fog|PF_NoTexture;
@ -1835,7 +1835,7 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
}
else
{
FBITFIELD blendmode = PF_Masked;
UINT32 blendmode = PF_Masked;
if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256)
{
@ -2656,7 +2656,7 @@ static inline void HWR_AddPolyObjectSegs(void)
}
static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight,
FBITFIELD blendmode, UINT8 lightlevel, levelflat_t *levelflat, sector_t *FOFsector,
UINT32 blendmode, UINT8 lightlevel, levelflat_t *levelflat, sector_t *FOFsector,
UINT8 alpha, extracolormap_t *planecolormap)
{
float height; //constant y for all points on the convex flat polygon
@ -2875,7 +2875,7 @@ static void HWR_AddPolyObjectPlanes(void)
if (po_ptrs[i]->translucency > 0)
{
FSurfaceInfo Surf;
FBITFIELD blendmode;
UINT32 blendmode;
memset(&Surf, 0x00, sizeof(Surf));
blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
HWR_AddTransparentPolyobjectFloor(&levelflats[polyobjsector->floorpic], po_ptrs[i], false, polyobjsector->floorheight,
@ -2898,7 +2898,7 @@ static void HWR_AddPolyObjectPlanes(void)
if (po_ptrs[i]->translucency > 0)
{
FSurfaceInfo Surf;
FBITFIELD blendmode;
UINT32 blendmode;
memset(&Surf, 0x00, sizeof(Surf));
blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
HWR_AddTransparentPolyobjectFloor(&levelflats[polyobjsector->ceilingpic], po_ptrs[i], true, polyobjsector->ceilingheight,
@ -3506,9 +3506,9 @@ static void HWR_LinkDrawHackFinish(void)
surf.PolyColor.rgba = 0xFFFFFFFF;
surf.TintColor.rgba = 0xFFFFFFFF;
surf.FadeColor.rgba = 0xFFFFFFFF;
surf.LightInfo.light_level = 0;
surf.LightInfo.fade_start = 0;
surf.LightInfo.fade_end = 31;
surf.LightInfo.LightLevel = 0;
surf.LightInfo.FadeStart = 0;
surf.LightInfo.FadeEnd = 31;
for (i = 0; i < linkdrawcount; i++)
{
// draw sprite shape, only to z-buffer
@ -3588,7 +3588,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale)
alpha = 255 - alpha;
gpatch = (patch_t *)W_CachePatchName("DSHADOW", PU_SPRITE);
if (!(gpatch && ((GLPatch_t *)gpatch->hardware)->mipmap->format)) return;
if (!(gpatch && ((GLPatch_t *)gpatch->hardware)->texture->format)) return;
HWR_GetPatch(gpatch);
scalemul = FixedMul(FRACUNIT - floordiff/640, scale);
@ -3702,10 +3702,10 @@ static void HWR_SplitSprite(gl_vissprite_t *spr)
patch_t *gpatch;
FSurfaceInfo Surf;
extracolormap_t *colormap = NULL;
FUINT lightlevel;
UINT32 lightlevel;
boolean lightset = true;
FBITFIELD blend = 0;
FBITFIELD occlusion;
UINT32 blend = 0;
UINT32 occlusion;
boolean use_linkdraw_hack = false;
boolean splat = R_ThingIsFloorSprite(spr->mobj);
UINT8 alpha;
@ -4219,8 +4219,8 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
}
{
FBITFIELD blend = 0;
FBITFIELD occlusion;
UINT32 blend = 0;
UINT32 occlusion;
boolean use_linkdraw_hack = false;
// if sprite has linkdraw, then dont write to z-buffer (by not using PF_Occlude)
@ -4282,7 +4282,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
// Sprite drawer for precipitation
static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
{
FBITFIELD blend = 0;
UINT32 blend = 0;
FOutVector wallVerts[4];
patch_t *gpatch; // sprite patch converted to hardware
FSurfaceInfo Surf;
@ -4469,7 +4469,7 @@ typedef struct
FOutVector wallVerts[4];
FSurfaceInfo Surf;
INT32 texnum;
FBITFIELD blend;
UINT32 blend;
INT32 drawcount;
boolean fogwall;
INT32 lightlevel;
@ -4479,7 +4479,7 @@ typedef struct
static wallinfo_t *wallinfo = NULL;
static size_t numwalls = 0; // a list of transparent walls to be drawn
void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, UINT32 blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap);
#define MAX_TRANSPARENTWALL 256
@ -4492,7 +4492,7 @@ typedef struct
levelflat_t *levelflat;
INT32 alpha;
sector_t *FOFSector;
FBITFIELD blend;
UINT32 blend;
boolean fogplane;
extracolormap_t *planecolormap;
INT32 drawcount;
@ -4510,7 +4510,7 @@ typedef struct
levelflat_t *levelflat;
INT32 alpha;
sector_t *FOFSector;
FBITFIELD blend;
UINT32 blend;
extracolormap_t *planecolormap;
INT32 drawcount;
} polyplaneinfo_t;
@ -4535,7 +4535,7 @@ static INT32 drawcount = 0;
#define MAX_TRANSPARENTFLOOR 512
// This will likely turn into a copy of HWR_Add3DWater and replace it.
void HWR_AddTransparentFloor(levelflat_t *levelflat, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap)
void HWR_AddTransparentFloor(levelflat_t *levelflat, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, UINT32 blend, boolean fogplane, extracolormap_t *planecolormap)
{
static size_t allocedplanes = 0;
@ -4566,7 +4566,7 @@ void HWR_AddTransparentFloor(levelflat_t *levelflat, extrasubsector_t *xsub, boo
// Adding this for now until I can create extrasubsector info for polyobjects
// When that happens it'll just be done through HWR_AddTransparentFloor and HWR_RenderPlane
void HWR_AddTransparentPolyobjectFloor(levelflat_t *levelflat, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap)
void HWR_AddTransparentPolyobjectFloor(levelflat_t *levelflat, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, UINT32 blend, extracolormap_t *planecolormap)
{
static size_t allocedpolyplanes = 0;
@ -4768,7 +4768,7 @@ static void HWR_DrawSprites(void)
{
UINT32 i;
boolean skipshadow = false; // skip shadow if it was drawn already for a linkdraw sprite encountered earlier in the list
HWD.pfnSetSpecialState(HWD_SET_MODEL_LIGHTING, cv_glmodellighting.value);
HWD.pfnSetState(GPU_STATE_MODEL_LIGHTING, cv_glmodellighting.value);
for (i = 0; i < gl_visspritecount; i++)
{
gl_vissprite_t *spr = gl_vsprorder[i];
@ -4826,7 +4826,7 @@ static void HWR_DrawSprites(void)
}
}
}
HWD.pfnSetSpecialState(HWD_SET_MODEL_LIGHTING, 0);
HWD.pfnSetState(GPU_STATE_MODEL_LIGHTING, 0);
// At the end of sprite drawing, draw shapes of linkdraw sprites to z-buffer, so they
// don't get drawn over by transparent surfaces.
@ -5420,9 +5420,9 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
// Sky dome rendering, ported from PrBoom+
// ==========================================================================
static gl_sky_t gl_sky;
static FSkyDome SkyDome;
static void HWR_SkyDomeVertex(gl_sky_t *sky, gl_skyvertex_t *vbo, int r, int c, signed char yflip, float delta, boolean foglayer)
static void HWR_SkyDomeVertex(FSkyDome *sky, FSkyVertex *vbo, int r, int c, signed char yflip, float delta, boolean foglayer)
{
const float radians = (float)(M_PIl / 180.0f);
const float scale = 10000.0f;
@ -5466,7 +5466,7 @@ static void HWR_SkyDomeVertex(gl_sky_t *sky, gl_skyvertex_t *vbo, int r, int c,
// Clears the sky dome.
void HWR_ClearSkyDome(void)
{
gl_sky_t *sky = &gl_sky;
FSkyDome *sky = &SkyDome;
if (sky->loops)
free(sky->loops);
@ -5495,8 +5495,8 @@ void HWR_BuildSkyDome(void)
int col_count = 4;
float delta;
gl_sky_t *sky = &gl_sky;
gl_skyvertex_t *vertex_p;
FSkyDome *sky = &SkyDome;
FSkyVertex *vertex_p;
texture_t *texture = textures[texturetranslation[skytexture]];
sky->detail = 16;
@ -5525,7 +5525,7 @@ void HWR_BuildSkyDome(void)
for (yflip = 0; yflip < 2; yflip++)
{
sky->loops[sky->loopcount].mode = HWD_SKYLOOP_FAN;
sky->loops[sky->loopcount].mode = GPU_SKYLOOP_FAN;
sky->loops[sky->loopcount].vertexindex = vertex_p - &sky->data[0];
sky->loops[sky->loopcount].vertexcount = col_count;
sky->loops[sky->loopcount].use_texture = false;
@ -5547,7 +5547,7 @@ void HWR_BuildSkyDome(void)
for (r = 0; r < row_count; r++)
{
sky->loops[sky->loopcount].mode = HWD_SKYLOOP_STRIP;
sky->loops[sky->loopcount].mode = GPU_SKYLOOP_STRIP;
sky->loops[sky->loopcount].vertexindex = vertex_p - &sky->data[0];
sky->loops[sky->loopcount].vertexcount = 2 * col_count + 2;
sky->loops[sky->loopcount].use_texture = true;
@ -5604,7 +5604,7 @@ static void HWR_DrawSkyBackground(player_t *player)
HWR_GetTexture(texturetranslation[skytexture]);
if (gl_sky.texture != texturetranslation[skytexture])
if (SkyDome.texture != texturetranslation[skytexture])
{
HWR_ClearSkyDome();
HWR_BuildSkyDome();
@ -5612,7 +5612,7 @@ static void HWR_DrawSkyBackground(player_t *player)
HWD.pfnSetShader(SHADER_SKY); // sky shader
HWD.pfnSetTransform(&dometransform);
HWD.pfnRenderSkyDome(&gl_sky);
HWD.pfnRenderSkyDome(&SkyDome);
}
else
{
@ -5787,12 +5787,12 @@ static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean
//
static void HWR_SetShaderState(void)
{
hwdshaderoption_t state = cv_glshaders.value;
INT32 state = cv_glshaders.value;
if (!cv_glallowshaders.value)
state = (cv_glshaders.value == HWD_SHADEROPTION_ON ? HWD_SHADEROPTION_NOCUSTOM : cv_glshaders.value);
state = (cv_glshaders.value == GPU_SHADEROPTION_ON ? GPU_SHADEROPTION_NOCUSTOM : cv_glshaders.value);
HWD.pfnSetSpecialState(HWD_SET_SHADERS, (INT32)state);
HWD.pfnSetState(GPU_STATE_SHADERS, (INT32)state);
HWD.pfnSetShader(SHADER_DEFAULT);
}
@ -6012,7 +6012,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
ClearColor.alpha = 1.0f;
if (cv_glshaders.value)
HWD.pfnSetShaderInfo(HWD_SHADERINFO_LEVELTIME, (INT32)leveltime); // The water surface shader needs the leveltime.
HWD.pfnSetShaderInfo(GPU_SHADERINFO_LEVELTIME, (INT32)leveltime); // The water surface shader needs the leveltime.
if (viewnumber == 0) // Only do it if it's the first screen being rendered
HWD.pfnClearBuffer(true, false, &ClearColor); // Clear the Color Buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs.
@ -6239,7 +6239,7 @@ void HWR_LoadLevel(void)
// 3D ENGINE COMMANDS
// ==========================================================================
static CV_PossibleValue_t glshaders_cons_t[] = {{HWD_SHADEROPTION_OFF, "Off"}, {HWD_SHADEROPTION_ON, "On"}, {HWD_SHADEROPTION_NOCUSTOM, "Ignore custom shaders"}, {0, NULL}};
static CV_PossibleValue_t glshaders_cons_t[] = {{GPU_SHADEROPTION_OFF, "Off"}, {GPU_SHADEROPTION_ON, "On"}, {GPU_SHADEROPTION_NOCUSTOM, "Ignore custom shaders"}, {0, NULL}};
static CV_PossibleValue_t glmodelinterpolation_cons_t[] = {{0, "Off"}, {1, "Sometimes"}, {2, "Always"}, {0, NULL}};
static CV_PossibleValue_t glfakecontrast_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Smooth"}, {0, NULL}};
static CV_PossibleValue_t glshearing_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Third-person"}, {0, NULL}};
@ -6247,11 +6247,11 @@ static CV_PossibleValue_t glshearing_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Thi
static void CV_glfiltermode_OnChange(void);
static void CV_glanisotropic_OnChange(void);
static CV_PossibleValue_t glfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSAMPLED, "Nearest"},
{HWD_SET_TEXTUREFILTER_BILINEAR, "Bilinear"}, {HWD_SET_TEXTUREFILTER_TRILINEAR, "Trilinear"},
{HWD_SET_TEXTUREFILTER_MIXED1, "Linear_Nearest"},
{HWD_SET_TEXTUREFILTER_MIXED2, "Nearest_Linear"},
{HWD_SET_TEXTUREFILTER_MIXED3, "Nearest_Mipmap"},
static CV_PossibleValue_t glfiltermode_cons_t[]= {{GPU_TEXFILTER_POINTSAMPLED, "Nearest"},
{GPU_TEXFILTER_BILINEAR, "Bilinear"}, {GPU_TEXFILTER_TRILINEAR, "Trilinear"},
{GPU_TEXFILTER_MIXED1, "Linear_Nearest"},
{GPU_TEXFILTER_MIXED2, "Nearest_Linear"},
{GPU_TEXFILTER_MIXED3, "Nearest_Mipmap"},
{0, NULL}};
CV_PossibleValue_t glanisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}};
@ -6286,13 +6286,13 @@ consvar_t cv_glbatching = CVAR_INIT ("gr_batching", "On", 0, CV_OnOff, NULL);
static void CV_glfiltermode_OnChange(void)
{
if (rendermode == render_opengl)
HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value);
HWD.pfnSetState(GPU_STATE_TEXTUREFILTERMODE, cv_glfiltermode.value);
}
static void CV_glanisotropic_OnChange(void)
{
if (rendermode == render_opengl)
HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value);
HWD.pfnSetState(GPU_STATE_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value);
}
//added by Hurdler: console varibale that are saved
@ -6358,9 +6358,7 @@ void HWR_Startup(void)
gl_shadersavailable = false;
}
if (rendermode == render_opengl)
textureformat = patchformat = GL_TEXFMT_RGBA;
gl_patchformat = gl_textureformat = GPU_TEXFMT_RGBA;
gl_init = true;
}
@ -6374,8 +6372,8 @@ void HWR_Switch(void)
HWR_AddSessionCommands();
// Set special states from CVARs
HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value);
HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value);
HWD.pfnSetState(GPU_STATE_TEXTUREFILTERMODE, cv_glfiltermode.value);
HWD.pfnSetState(GPU_STATE_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value);
// Load textures
if (!gl_maptexturesloaded)
@ -6383,10 +6381,7 @@ void HWR_Switch(void)
// Create plane polygons
if (!gl_maploaded && (gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction)))
{
HWR_ClearAllTextures();
HWR_LoadLevel();
}
}
// --------------------------------------------------------------------------
@ -6424,7 +6419,7 @@ void transform(float *cx, float *cy, float *cz)
*cx *= gl_fovlud;
}
void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap)
void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 texnum, UINT32 blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap)
{
static size_t allocedwalls = 0;
@ -6449,9 +6444,9 @@ void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, INT32 te
numwalls++;
}
void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap)
void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, UINT32 blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap)
{
FBITFIELD blendmode = blend;
UINT32 blendmode = blend;
UINT8 alpha = pSurf->PolyColor.s.alpha; // retain the alpha
int shader;
@ -6666,7 +6661,7 @@ boolean HWR_CompileShaders(void)
return HWD.pfnCompileShaders();
}
customshaderxlat_t shaderxlat[] =
FShaderReferenceArray shaderxlat[] =
{
{"Flat", SHADER_FLOOR},
{"WallTexture", SHADER_WALL},

View file

@ -40,7 +40,7 @@ void HWR_SetViewSize(void);
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_MakePatch(const patch_t *patch, GLPatch_t *grPatch, HWRTexture_t *hwrTexture, boolean makebitmap);
void HWR_CreatePlanePolygons(INT32 bspnum);
void HWR_CreateStaticLightmaps(INT32 bspnum);
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color);
@ -69,9 +69,9 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap); // Let's see if this can work
UINT8 HWR_GetTranstableAlpha(INT32 transtablenum);
FBITFIELD HWR_GetBlendModeFlag(INT32 ast);
FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf);
FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf);
UINT32 HWR_GetBlendModeFlag(INT32 ast);
UINT32 HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf);
UINT32 HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf);
boolean HWR_CompileShaders(void);
@ -79,7 +79,7 @@ void HWR_LoadAllCustomShaders(void);
void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3);
const char *HWR_GetShaderName(INT32 shader);
extern customshaderxlat_t shaderxlat[];
extern FShaderReferenceArray shaderxlat[];
extern CV_PossibleValue_t glanisotropicmode_cons_t[];

View file

@ -201,7 +201,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
//CONS_Debug(DBG_RENDER, "libpng load error on %s\n", filename);
png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL);
fclose(png_FILE);
Z_Free(grpatch->mipmap->data);
Z_Free(grpatch->texture->data);
return 0;
}
#ifdef USE_FAR_KEYWORD
@ -242,7 +242,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
{
png_uint_32 i, pitch = png_get_rowbytes(png_ptr, png_info_ptr);
png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRMODELTEXTURE, &grpatch->mipmap->data);
png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRMODELTEXTURE, &grpatch->texture->data);
png_bytepp row_pointers = png_malloc(png_ptr, height * sizeof (png_bytep));
for (i = 0; i < height; i++)
row_pointers[i] = PNG_image + i*pitch;
@ -255,7 +255,7 @@ static GLTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_
fclose(png_FILE);
*w = (int)width;
*h = (int)height;
return GL_TEXFMT_RGBA;
return GPU_TEXFMT_RGBA;
}
#endif
@ -322,7 +322,7 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
pw = *w = header.xmax - header.xmin + 1;
ph = *h = header.ymax - header.ymin + 1;
image = Z_Malloc(pw*ph*4, PU_HWRMODELTEXTURE, &grpatch->mipmap->data);
image = Z_Malloc(pw*ph*4, PU_HWRMODELTEXTURE, &grpatch->texture->data);
if (fread(palette, sizeof (UINT8), PALSIZE, file) != PALSIZE)
{
@ -356,7 +356,7 @@ static GLTextureFormat_t PCX_Load(const char *filename, int *w, int *h,
}
}
fclose(file);
return GL_TEXFMT_RGBA;
return GPU_TEXFMT_RGBA;
}
// -----------------+
@ -373,7 +373,7 @@ static void md2_loadTexture(md2_t *model)
patch = model->grpatch;
grPatch = (GLPatch_t *)(patch->hardware);
if (grPatch)
Z_Free(grPatch->mipmap->data);
Z_Free(grPatch->texture->data);
}
else
model->grpatch = patch = Patch_Create(NULL, 0, NULL);
@ -384,33 +384,33 @@ static void md2_loadTexture(md2_t *model)
if (grPatch == NULL)
grPatch = (GLPatch_t *)(patch->hardware);
if (!grPatch->mipmap->downloaded && !grPatch->mipmap->data)
if (!grPatch->texture->downloaded && !grPatch->texture->data)
{
int w = 0, h = 0;
UINT32 size;
RGBA_t *image;
#ifdef HAVE_PNG
grPatch->mipmap->format = PNG_Load(filename, &w, &h, grPatch);
if (grPatch->mipmap->format == 0)
grPatch->texture->format = PNG_Load(filename, &w, &h, grPatch);
if (grPatch->texture->format == 0)
#endif
grPatch->mipmap->format = PCX_Load(filename, &w, &h, grPatch);
if (grPatch->mipmap->format == 0)
grPatch->texture->format = PCX_Load(filename, &w, &h, grPatch);
if (grPatch->texture->format == 0)
{
model->notexturefile = true; // mark it so its not searched for again repeatedly
return;
}
grPatch->mipmap->downloaded = 0;
grPatch->mipmap->flags = 0;
grPatch->texture->downloaded = 0;
grPatch->texture->flags = 0;
patch->width = (INT16)w;
patch->height = (INT16)h;
grPatch->mipmap->width = (UINT16)w;
grPatch->mipmap->height = (UINT16)h;
grPatch->texture->width = (UINT16)w;
grPatch->texture->height = (UINT16)h;
// Lactozilla: Apply colour cube
image = grPatch->mipmap->data;
image = grPatch->texture->data;
size = w*h;
while (size--)
{
@ -418,7 +418,7 @@ static void md2_loadTexture(md2_t *model)
image++;
}
}
HWD.pfnSetTexture(grPatch->mipmap);
HWD.pfnSetTexture(grPatch->texture);
}
// -----------------+
@ -438,7 +438,7 @@ static void md2_loadBlendTexture(md2_t *model)
patch = model->blendgrpatch;
grPatch = (GLPatch_t *)(patch->hardware);
if (grPatch)
Z_Free(grPatch->mipmap->data);
Z_Free(grPatch->texture->data);
}
else
model->blendgrpatch = patch = Patch_Create(NULL, 0, NULL);
@ -449,30 +449,30 @@ static void md2_loadBlendTexture(md2_t *model)
if (grPatch == NULL)
grPatch = (GLPatch_t *)(patch->hardware);
if (!grPatch->mipmap->downloaded && !grPatch->mipmap->data)
if (!grPatch->texture->downloaded && !grPatch->texture->data)
{
int w = 0, h = 0;
#ifdef HAVE_PNG
grPatch->mipmap->format = PNG_Load(filename, &w, &h, grPatch);
if (grPatch->mipmap->format == 0)
grPatch->texture->format = PNG_Load(filename, &w, &h, grPatch);
if (grPatch->texture->format == 0)
#endif
grPatch->mipmap->format = PCX_Load(filename, &w, &h, grPatch);
if (grPatch->mipmap->format == 0)
grPatch->texture->format = PCX_Load(filename, &w, &h, grPatch);
if (grPatch->texture->format == 0)
{
model->noblendfile = true; // mark it so its not searched for again repeatedly
Z_Free(filename);
return;
}
grPatch->mipmap->downloaded = 0;
grPatch->mipmap->flags = 0;
grPatch->texture->downloaded = 0;
grPatch->texture->flags = 0;
patch->width = (INT16)w;
patch->height = (INT16)h;
grPatch->mipmap->width = (UINT16)w;
grPatch->mipmap->height = (UINT16)h;
grPatch->texture->width = (UINT16)w;
grPatch->texture->height = (UINT16)h;
}
HWD.pfnSetTexture(grPatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary
HWD.pfnSetTexture(grPatch->texture); // We do need to do this so that it can be cleared and knows to recreate it when necessary
Z_Free(filename);
}
@ -702,7 +702,7 @@ spritemodelfound:
#define SETBRIGHTNESS(brightness,r,g,b) \
brightness = (UINT8)(((1063*(UINT16)(r))/5000) + ((3576*(UINT16)(g))/5000) + ((361*(UINT16)(b))/5000))
static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMipmap_t *grMipmap, INT32 skinnum, skincolornum_t color)
static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, HWRTexture_t *hwrTexture, INT32 skinnum, skincolornum_t color)
{
GLPatch_t *hwrPatch = gpatch->hardware;
GLPatch_t *hwrBlendPatch = blendgpatch->hardware;
@ -718,29 +718,29 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi
memset(translation, 0, sizeof(translation));
memset(cutoff, 0, sizeof(cutoff));
if (grMipmap->width == 0)
if (hwrTexture->width == 0)
{
grMipmap->width = gpatch->width;
grMipmap->height = gpatch->height;
hwrTexture->width = gpatch->width;
hwrTexture->height = gpatch->height;
// no wrap around, no chroma key
grMipmap->flags = 0;
hwrTexture->flags = 0;
// setup the texture info
grMipmap->format = GL_TEXFMT_RGBA;
hwrTexture->format = GPU_TEXFMT_RGBA;
}
if (grMipmap->data)
if (hwrTexture->data)
{
Z_Free(grMipmap->data);
grMipmap->data = NULL;
Z_Free(hwrTexture->data);
hwrTexture->data = NULL;
}
cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &grMipmap->data);
cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &hwrTexture->data);
memset(cur, 0x00, size*4);
image = hwrPatch->mipmap->data;
blendimage = hwrBlendPatch->mipmap->data;
image = hwrPatch->texture->data;
blendimage = hwrBlendPatch->texture->data;
// TC_METALSONIC includes an actual skincolor translation, on top of its flashing.
if (skinnum == TC_METALSONIC)
@ -1084,34 +1084,34 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski
// mostly copied from HWR_GetMappedPatch, hence the similarities and comment
GLPatch_t *grPatch = patch->hardware;
GLPatch_t *grBlendPatch = NULL;
GLMipmap_t *grMipmap, *newMipmap;
HWRTexture_t *hwrTexture, *newTexture;
if (blendpatch == NULL || colormap == colormaps || colormap == NULL)
{
// Don't do any blending
HWD.pfnSetTexture(grPatch->mipmap);
HWD.pfnSetTexture(grPatch->texture);
return;
}
if ((blendpatch && (grBlendPatch = blendpatch->hardware) && grBlendPatch->mipmap->format)
if ((blendpatch && (grBlendPatch = blendpatch->hardware) && grBlendPatch->texture->format)
&& (patch->width != blendpatch->width || patch->height != blendpatch->height))
{
// Blend image exists, but it's bad.
HWD.pfnSetTexture(grPatch->mipmap);
HWD.pfnSetTexture(grPatch->texture);
return;
}
// search for the mipmap
// search for the texture
// skip the first (no colormap translated)
for (grMipmap = grPatch->mipmap; grMipmap->nextcolormap; )
for (hwrTexture = grPatch->texture; hwrTexture->nextcolormap; )
{
grMipmap = grMipmap->nextcolormap;
if (grMipmap->colormap == colormap)
hwrTexture = hwrTexture->nextcolormap;
if (hwrTexture->colormap == colormap)
{
if (grMipmap->downloaded && grMipmap->data)
if (hwrTexture->downloaded && hwrTexture->data)
{
HWD.pfnSetTexture(grMipmap); // found the colormap, set it to the correct texture
Z_ChangeTag(grMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED);
HWD.pfnSetTexture(hwrTexture); // found the colormap, set it to the correct texture
Z_ChangeTag(hwrTexture->data, PU_HWRMODELTEXTURE_UNLOCKED);
return;
}
}
@ -1119,21 +1119,16 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendpatch, INT32 ski
// If here, the blended texture has not been created
// So we create it
//BP: WARNING: don't free it manually without clearing the cache of harware renderer
// (it have a liste of mipmap)
// this malloc is cleared in HWR_FreeColormapCache
// (...) unfortunately z_malloc fragment alot the memory :(so malloc is better
newMipmap = calloc(1, sizeof (*newMipmap));
if (newMipmap == NULL)
newTexture = calloc(1, sizeof (*newTexture));
if (newTexture == NULL)
I_Error("%s: Out of memory", "HWR_GetBlendedTexture");
grMipmap->nextcolormap = newMipmap;
newMipmap->colormap = colormap;
hwrTexture->nextcolormap = newTexture;
newTexture->colormap = colormap;
HWR_CreateBlendedTexture(patch, blendpatch, newMipmap, skinnum, color);
HWR_CreateBlendedTexture(patch, blendpatch, newTexture, skinnum, color);
HWD.pfnSetTexture(newMipmap);
Z_ChangeTag(newMipmap->data, PU_HWRMODELTEXTURE_UNLOCKED);
HWD.pfnSetTexture(newTexture);
Z_ChangeTag(newTexture->data, PU_HWRMODELTEXTURE_UNLOCKED);
}
#define NORMALFOG 0x00000000
@ -1376,7 +1371,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
hwrPatch = ((GLPatch_t *)gpatch->hardware);
if (!gpatch || !hwrPatch
|| ((!hwrPatch->mipmap->format || !hwrPatch->mipmap->downloaded) && !md2->notexturefile))
|| ((!hwrPatch->texture->format || !hwrPatch->texture->downloaded) && !md2->notexturefile))
md2_loadTexture(md2);
// Load it again, because it isn't being loaded into gpatch after md2_loadtexture...
@ -1389,9 +1384,9 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
if (blendgpatch)
hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware);
if ((gpatch && hwrPatch && hwrPatch->mipmap->format) // don't load the blend texture if the base texture isn't available
if ((gpatch && hwrPatch && hwrPatch->texture->format) // don't load the blend texture if the base texture isn't available
&& (!blendgpatch || !hwrBlendPatch
|| ((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !md2->noblendfile)))
|| ((!hwrBlendPatch->texture->format || !hwrBlendPatch->texture->downloaded) && !md2->noblendfile)))
md2_loadBlendTexture(md2);
if (md2->error)
@ -1407,7 +1402,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
md2_printModelInfo(md2->model);
// If model uses sprite patch as texture, then
// adjust texture coordinates to take power of two textures into account
if (!gpatch || !hwrPatch->mipmap->format)
if (!gpatch || !hwrPatch->texture->format)
adjustTextureCoords(md2->model, spr->gpatch);
// note down the max_s and max_t that end up in the VBO
md2->model->vbo_max_s = md2->model->max_s;
@ -1426,7 +1421,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr)
finalscale = md2->scale;
//Hurdler: arf, I don't like that implementation at all... too much crappy
if (gpatch && hwrPatch && hwrPatch->mipmap->format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture
if (gpatch && hwrPatch && hwrPatch->texture->format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture
{
INT32 skinnum = TC_DEFAULT;

View file

@ -58,7 +58,6 @@ PFNglGetString pglGetString;
#define MAX_VIDEO_MODES 32
static vmode_t video_modes[MAX_VIDEO_MODES];
INT32 oglflags = 0;
// **************************************************************************
// FUNCTIONS
@ -239,7 +238,6 @@ int SetupPixelFormat(INT32 WantColorBits, INT32 WantStencilBits, INT32 WantDepth
// -----------------+
static INT32 WINAPI SetRes(viddef_t *lvid, vmode_t *pcurrentmode)
{
LPCSTR renderer;
BOOL WantFullScreen = !(lvid->u.windowed); //(lvid->u.windowed ? 0 : CDS_FULLSCREEN);
UNREFERENCED_PARAMETER(pcurrentmode);
@ -332,40 +330,37 @@ static INT32 WINAPI SetRes(viddef_t *lvid, vmode_t *pcurrentmode)
}
}
gl_extensions = pglGetString(GL_EXTENSIONS);
// Get info and extensions.
//BP: why don't we make it earlier ?
//Hurdler: we cannot do that before intialising gl context
renderer = (LPCSTR)pglGetString(GL_RENDERER);
GL_DBG_Printf("Vendor : %s\n", pglGetString(GL_VENDOR));
GL_DBG_Printf("Renderer : %s\n", renderer);
GL_DBG_Printf("Version : %s\n", pglGetString(GL_VERSION));
GL_DBG_Printf("Extensions : %s\n", gl_extensions);
GLVersion = pglGetString(GL_VERSION);
GLRenderer = pglGetString(GL_RENDERER);
GLExtensions = pglGetString(GL_EXTENSIONS);
// BP: disable advenced feature that don't work on somes hardware
// Hurdler: Now works on G400 with bios 1.6 and certified drivers 6.04
if (strstr(renderer, "810")) oglflags |= GLF_NOZBUFREAD;
GL_DBG_Printf("oglflags : 0x%X\n", oglflags);
GL_DBG_Printf("OpenGL %s\n", GLVersion);
GL_DBG_Printf("GPU: %s\n", GLRenderer);
GL_DBG_Printf("Vendor: %s\n", pglGetString(GL_VENDOR));
GL_DBG_Printf("Extensions: %s\n", GLExtensions);
#ifdef USE_WGL_SWAP
if (isExtAvailable("WGL_EXT_swap_control",gl_extensions))
if (isExtAvailable("WGL_EXT_swap_control", GLExtensions))
wglSwapIntervalEXT = GetGLFunc("wglSwapIntervalEXT");
else
wglSwapIntervalEXT = NULL;
#endif
if (isExtAvailable("GL_EXT_texture_filter_anisotropic",gl_extensions))
pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy);
if (isExtAvailable("GL_EXT_texture_filter_anisotropic", GLExtensions))
pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &GPUMaximumAnisotropy);
else
maximumAnisotropy = 0;
GPUMaximumAnisotropy = 0;
SetupGLFunc13();
screen_depth = (GLbyte)(lvid->bpp*8);
if (screen_depth > 16)
textureformatGL = GL_RGBA;
GPUScreenDepth = (GLbyte)(lvid->bpp*8);
if (GPUScreenDepth > 16)
GPUTextureFormat = GL_RGBA;
else
textureformatGL = GL_RGB5_A1;
GPUTextureFormat = GL_RGB5_A1;
SetModelView(lvid->width, lvid->height);
SetStates();
@ -568,9 +563,9 @@ EXPORT void HWRAPI(SetPalette) (RGBA_t *pal)
{
size_t palsize = (sizeof(RGBA_t) * 256);
// on a palette change, you have to reload all of the textures
if (memcmp(&myPaletteData, pal, palsize))
if (memcmp(&GPUTexturePalette, pal, palsize))
{
memcpy(&myPaletteData, pal, palsize);
memcpy(&GPUTexturePalette, pal, palsize);
Flush();
}
}

File diff suppressed because it is too large Load diff

View file

@ -117,25 +117,15 @@ static PFNglEnableClientState pglEnableClientState;
// GLOBAL
// ==========================================================================
extern const GLubyte *gl_version;
extern const GLubyte *gl_renderer;
extern const GLubyte *gl_extensions;
extern const GLubyte *GLVersion;
extern const GLubyte *GLRenderer;
extern const GLubyte *GLExtensions;
extern RGBA_t myPaletteData[];
extern GLint screen_width;
extern GLint screen_height;
extern GLbyte screen_depth;
extern GLint maximumAnisotropy;
/** \brief OpenGL flags for video driver
*/
extern INT32 oglflags;
extern GLint textureformatGL;
typedef enum
{
GLF_NOZBUFREAD = 0x01,
GLF_NOTEXENV = 0x02,
} oglflags_t;
extern GLint GPUTextureFormat;
extern RGBA_t GPUTexturePalette[256];
extern GLint GPUScreenWidth;
extern GLint GPUScreenHeight;
extern GLbyte GPUScreenDepth;
extern GLint GPUMaximumAnisotropy;
#endif

View file

@ -4134,9 +4134,8 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
R_FlushTranslationColormapCache();
#ifdef HWRENDER
// Free GPU textures before freeing patches.
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWR_ClearAllTextures();
HWR_ClearColormapCache();
#endif
Patch_FreeTag(PU_PATCH_LOWPRIORITY);
@ -4499,7 +4498,7 @@ boolean P_AddWadFile(const char *wadfilename)
CONS_Printf(M_GetText("%s digital musics replaced\n"), sizeu1(digmreplaces));
#ifdef HWRENDER
// Free GPU textures before freeing patches.
// Free all GPU textures.
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWR_ClearAllTextures();
#endif

View file

@ -79,7 +79,7 @@ typedef struct
// for textures
UINT8 *picture;
#ifdef HWRENDER
void *mipmap;
void *texture;
#endif
} levelflat_t;

View file

@ -141,7 +141,7 @@ void *Patch_AllocateHardwarePatch(patch_t *patch)
if (!patch->hardware)
{
GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, &patch->hardware);
grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, &grPatch->mipmap);
grPatch->texture = Z_Calloc(sizeof(HWRTexture_t), PU_HWRPATCHINFO, &grPatch->texture);
}
return (void *)(patch->hardware);
}
@ -153,8 +153,8 @@ void *Patch_AllocateHardwarePatch(patch_t *patch)
void *Patch_CreateGL(patch_t *patch)
{
GLPatch_t *grPatch = (GLPatch_t *)Patch_AllocateHardwarePatch(patch);
if (!grPatch->mipmap->data) // Run HWR_MakePatch in all cases, to recalculate some things
HWR_MakePatch(patch, grPatch, grPatch->mipmap, false);
if (!grPatch->texture->data) // Run HWR_MakePatch in all cases, to recalculate some things
HWR_MakePatch(patch, grPatch, grPatch->texture, false);
return grPatch;
}
#endif // HWRENDER

View file

@ -89,9 +89,8 @@ void *hwSym(const char *funcName,void *handle)
GETFUNC(DeleteTexture);
GETFUNC(ReadRect);
GETFUNC(GClipRect);
GETFUNC(ClearMipMapCache);
GETFUNC(ClearCacheList);
GETFUNC(SetSpecialState);
GETFUNC(ClearTextureCache);
GETFUNC(SetState);
GETFUNC(GetTextureUsed);
GETFUNC(DrawModel);
GETFUNC(CreateModelVBOs);

View file

@ -1568,6 +1568,9 @@ boolean VID_CheckRenderer(void)
}
SCR_SetDrawFuncs();
if (vid.glstate == VID_GL_LIBRARY_LOADED)
HWR_ClearAllTextures();
}
#ifdef HWRENDER
else if (rendermode == render_opengl && rendererchanged)
@ -1861,9 +1864,8 @@ void VID_StartupOpenGL(void)
HWD.pfnDeleteTexture = hwSym("DeleteTexture",NULL);
HWD.pfnReadRect = hwSym("ReadRect",NULL);
HWD.pfnGClipRect = hwSym("GClipRect",NULL);
HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL);
HWD.pfnClearCacheList = hwSym("ClearCacheList",NULL);
HWD.pfnSetSpecialState = hwSym("SetSpecialState",NULL);
HWD.pfnClearTextureCache= hwSym("ClearTextureCache",NULL);
HWD.pfnSetState = hwSym("SetState",NULL);
HWD.pfnSetPalette = hwSym("SetPalette",NULL);
HWD.pfnGetTextureUsed = hwSym("GetTextureUsed",NULL);
HWD.pfnDrawModel = hwSym("DrawModel",NULL);

View file

@ -69,7 +69,6 @@ PFNglGetString pglGetString;
/** \brief SDL video display surface
*/
INT32 oglflags = 0;
void *GLUhandle = NULL;
SDL_GLContext sdlglcontext = 0;
@ -156,20 +155,18 @@ boolean OglSdlSurface(INT32 w, INT32 h)
INT32 cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value;
static boolean first_init = false;
oglflags = 0;
if (!first_init)
{
gl_version = pglGetString(GL_VERSION);
gl_renderer = pglGetString(GL_RENDERER);
gl_extensions = pglGetString(GL_EXTENSIONS);
GLVersion = pglGetString(GL_VERSION);
GLRenderer = pglGetString(GL_RENDERER);
GLExtensions = pglGetString(GL_EXTENSIONS);
GL_DBG_Printf("OpenGL %s\n", gl_version);
GL_DBG_Printf("GPU: %s\n", gl_renderer);
GL_DBG_Printf("Extensions: %s\n", gl_extensions);
GL_DBG_Printf("OpenGL %s\n", GLVersion);
GL_DBG_Printf("GPU: %s\n", GLRenderer);
GL_DBG_Printf("Extensions: %s\n", GLExtensions);
if (strcmp((const char*)gl_renderer, "GDI Generic") == 0 &&
strcmp((const char*)gl_version, "1.1.0") == 0)
if (strcmp((const char*)GLRenderer, "GDI Generic") == 0 &&
strcmp((const char*)GLVersion, "1.1.0") == 0)
{
// Oh no... Windows gave us the GDI Generic rasterizer, so something is wrong...
// The game will crash later on when unsupported OpenGL commands are encountered.
@ -182,14 +179,14 @@ boolean OglSdlSurface(INT32 w, INT32 h)
}
first_init = true;
if (isExtAvailable("GL_EXT_texture_filter_anisotropic", gl_extensions))
pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy);
if (isExtAvailable("GL_EXT_texture_filter_anisotropic", GLExtensions))
pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &GPUMaximumAnisotropy);
else
maximumAnisotropy = 1;
GPUMaximumAnisotropy = 1;
SetupGLFunc4();
glanisotropicmode_cons_t[1].value = maximumAnisotropy;
glanisotropicmode_cons_t[1].value = GPUMaximumAnisotropy;
SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0);
@ -198,7 +195,7 @@ boolean OglSdlSurface(INT32 w, INT32 h)
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
HWR_Startup();
textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1;
GPUTextureFormat = cbpp > 16 ? GL_RGBA : GL_RGB5_A1;
return true;
}
@ -237,9 +234,9 @@ EXPORT void HWRAPI(OglSdlSetPalette) (RGBA_t *palette)
{
size_t palsize = (sizeof(RGBA_t) * 256);
// on a palette change, you have to reload all of the textures
if (memcmp(&myPaletteData, palette, palsize))
if (memcmp(&GPUTexturePalette, palette, palsize))
{
memcpy(&myPaletteData, palette, palsize);
memcpy(&GPUTexturePalette, palette, palsize);
Flush();
}
}

View file

@ -110,9 +110,8 @@ static loadfunc_t hwdFuncTable[] = {
{"DeleteTexture@4", &hwdriver.pfnDeleteTexture},
{"ReadRect@24", &hwdriver.pfnReadRect},
{"GClipRect@20", &hwdriver.pfnGClipRect},
{"ClearMipMapCache@0", &hwdriver.pfnClearMipMapCache},
{"ClearCacheList@0", &hwdriver.pfnClearCacheList},
{"SetSpecialState@8", &hwdriver.pfnSetSpecialState},
{"ClearTextureCache@0", &hwdriver.pfnClearTextureCache},
{"SetState@8", &hwdriver.pfnSetState},
{"DrawModel@16", &hwdriver.pfnDrawModel},
{"SetTransform@4", &hwdriver.pfnSetTransform},
{"GetTextureUsed@0", &hwdriver.pfnGetTextureUsed},
@ -144,9 +143,8 @@ static loadfunc_t hwdFuncTable[] = {
{"DeleteTexture", &hwdriver.pfnDeleteTexture},
{"ReadRect", &hwdriver.pfnReadRect},
{"GClipRect", &hwdriver.pfnGClipRect},
{"ClearMipMapCache", &hwdriver.pfnClearMipMapCache},
{"ClearCacheList", &hwdriver.pfnClearCacheList},
{"SetSpecialState", &hwdriver.pfnSetSpecialState},
{"ClearTextureCache", &hwdriver.pfnClearTextureCache},
{"SetState", &hwdriver.pfnSetState},
{"DrawModel", &hwdriver.pfnDrawModel},
{"SetTransform", &hwdriver.pfnSetTransform},
{"GetTextureUsed", &hwdriver.pfnGetTextureUsed},

View file

@ -814,7 +814,7 @@ static void Command_Memfree_f(void)
if (rendermode == render_opengl)
{
CONS_Printf(M_GetText("Patch info headers: %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHINFO)>>10));
CONS_Printf(M_GetText("Mipmap patches : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHCOLMIPMAP)>>10));
CONS_Printf(M_GetText("Colormap textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHCOLTEXTURE)>>10));
CONS_Printf(M_GetText("HW Texture cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10));
CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10));
CONS_Printf(M_GetText("HW model textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRMODELTEXTURE)>>10));

View file

@ -51,7 +51,7 @@ enum
PU_HUDGFX = 19, // HUD patch, static until WAD added
PU_HWRPATCHINFO = 21, // Hardware GLPatch_t struct for OpenGL texture cache
PU_HWRPATCHCOLMIPMAP = 22, // Hardware GLMipmap_t struct colormap variation of patch
PU_HWRPATCHCOLTEXTURE = 22, // Hardware HWRTexture_t struct colormap variation of patch
PU_HWRMODELTEXTURE = 23, // Hardware model texture
PU_HWRCACHE = 48, // static until unlocked