Remove MAX_GLTEXTURES limit.

This commit is contained in:
Shpoike 2020-07-11 20:43:19 +01:00
parent bd6d2ab660
commit 6e809c4999

View file

@ -33,7 +33,6 @@ static cvar_t gl_max_size = {"gl_max_size", "0", CVAR_NONE};
static cvar_t gl_picmip = {"gl_picmip", "0", CVAR_NONE}; static cvar_t gl_picmip = {"gl_picmip", "0", CVAR_NONE};
static GLint gl_hardware_maxsize; static GLint gl_hardware_maxsize;
#define MAX_GLTEXTURES 2048
static int numgltextures; static int numgltextures;
static gltexture_t *active_gltextures, *free_gltextures; static gltexture_t *active_gltextures, *free_gltextures;
gltexture_t *notexture, *nulltexture; gltexture_t *notexture, *nulltexture;
@ -382,8 +381,14 @@ gltexture_t *TexMgr_NewTexture (void)
{ {
gltexture_t *glt; gltexture_t *glt;
if (numgltextures == MAX_GLTEXTURES) if (!free_gltextures)
Sys_Error("numgltextures == MAX_GLTEXTURES\n"); {
int i, newtexturecount = 64;
free_gltextures = (gltexture_t *) malloc (newtexturecount * sizeof(gltexture_t));
for (i = 0; i < newtexturecount - 1; i++)
free_gltextures[i].next = &free_gltextures[i+1];
free_gltextures[i].next = NULL;
}
glt = free_gltextures; glt = free_gltextures;
free_gltextures = glt->next; free_gltextures = glt->next;
@ -660,9 +665,10 @@ void TexMgr_Init (void)
extern texture_t *r_notexture_mip, *r_notexture_mip2; extern texture_t *r_notexture_mip, *r_notexture_mip2;
// init texture list // init texture list
free_gltextures = (gltexture_t *) Hunk_AllocName (MAX_GLTEXTURES * sizeof(gltexture_t), "gltextures"); int initialtexturecount = 256;
free_gltextures = (gltexture_t *) Hunk_AllocName (initialtexturecount * sizeof(gltexture_t), "gltextures");
active_gltextures = NULL; active_gltextures = NULL;
for (i = 0; i < MAX_GLTEXTURES - 1; i++) for (i = 0; i < initialtexturecount - 1; i++)
free_gltextures[i].next = &free_gltextures[i+1]; free_gltextures[i].next = &free_gltextures[i+1];
free_gltextures[i].next = NULL; free_gltextures[i].next = NULL;
numgltextures = 0; numgltextures = 0;