Stop using NextTexAvail you dunce

This commit is contained in:
Jaime Passos 2020-01-25 21:37:33 -03:00
parent b9b1958886
commit c219a170da

View file

@ -55,13 +55,12 @@ static float NEAR_CLIPPING_PLANE = NZCLIP_PLANE;
// **************************************************************************
static GLuint NextTexAvail = FIRST_TEX_AVAIL;
static GLuint tex_downloaded = 0;
static GLfloat fov = 90.0f;
static FBITFIELD CurrentPolyFlags;
static FTextureInfo* gr_cachetail = NULL;
static FTextureInfo* gr_cachehead = NULL;
static FTextureInfo *gr_cachetail = NULL;
static FTextureInfo *gr_cachehead = NULL;
RGBA_t myPaletteData[256];
GLint screen_width = 0; // used by Draw2DLine()
@ -1245,33 +1244,12 @@ void Flush(void)
while (gr_cachehead)
{
// this is not necessary at all, because you have loaded them normally,
// and so they already are in your list!
#if 0
//Hurdler: 25/04/2000: now support colormap in hardware mode
FTextureInfo *tmp = gr_cachehead->nextskin;
// The memory should be freed in the main code
while (tmp)
{
pglDeleteTextures(1, &tmp->downloaded);
tmp->downloaded = 0;
tmp = tmp->nextcolormap;
}
#endif
pglDeleteTextures(1, (GLuint *)&gr_cachehead->downloaded);
if (gr_cachehead->downloaded)
pglDeleteTextures(1, (GLuint *)&gr_cachehead->downloaded);
gr_cachehead->downloaded = 0;
gr_cachehead = gr_cachehead->nextmipmap;
}
gr_cachetail = gr_cachehead = NULL; //Hurdler: well, gr_cachehead is already NULL
NextTexAvail = FIRST_TEX_AVAIL;
#if 0
if (screentexture != FIRST_TEX_AVAIL)
{
pglDeleteTextures(1, &screentexture);
screentexture = FIRST_TEX_AVAIL;
}
#endif
tex_downloaded = 0;
}
@ -1648,8 +1626,10 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo)
static RGBA_t tex[2048*2048];
const GLvoid *ptex = tex;
INT32 w, h;
GLuint texnum = 0;
//GL_DBG_Printf ("DownloadMipmap %d %x\n",NextTexAvail,pTexInfo->grInfo.data);
pglGenTextures(1, &texnum);
//GL_DBG_Printf ("DownloadMipmap %d %x\n",(INT32)texnum,pTexInfo->grInfo.data);
w = pTexInfo->width;
h = pTexInfo->height;
@ -1737,9 +1717,10 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo)
else
GL_DBG_Printf ("SetTexture(bad format) %ld\n", pTexInfo->grInfo.format);
pTexInfo->downloaded = NextTexAvail++;
tex_downloaded = pTexInfo->downloaded;
pglBindTexture(GL_TEXTURE_2D, pTexInfo->downloaded);
// the texture number was already generated by pglGenTextures
pglBindTexture(GL_TEXTURE_2D, texnum);
pTexInfo->downloaded = texnum;
tex_downloaded = texnum;
// disable texture filtering on any texture that has holes so there's no dumb borders or blending issues
if (pTexInfo->flags & TF_TRANSPARENT)