Rune Central
http://runequake.com/forums/

Max textures fix?
http://runequake.com/forums/viewtopic.php?f=9&t=889
Page 1 of 1

Author:  Baker [ Mon Sep 19, 2005 12:18 am ]
Post subject:  Max textures fix?

Is this the fix for where the num textures > max textures

http://www.quakesrc.org/tutorials/old/78

"Quake has a major memory leak, LordHavoc discovered it and patched it while working on Nehahra some time ago, and fixes are now in Nehahra, DarkPlaces, QuakeWorld Forever, and QuakeForge. The patch code is below..
Note that it also contains code for fixing texture mismatches, and you thus need to add"


gl_draw.c

Code:
/*

================

GL_LoadTexture

================

*/

int lhcsumtable[256];

int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha)

{

 qboolean noalpha;

 int   i, p, s, lhcsum;

 gltexture_t *glt;



 // LordHavoc: do a checksum to confirm the data really is the same as previous

 // occurances. well this isn't exactly a checksum, it's better than that but

 // not following any standards.

 lhcsum = 0;

 s = width*height;

 for (i = 0;i < 256;i++) lhcsumtable[i] = i + 1;

 for (i = 0;i < s;i++) lhcsum += (lhcsumtable[data[i] & 255]++);



 // see if the texture is allready present

 if (identifier[0])

 {

  for (i=0, glt=gltextures ; iidentifier))

   {

    // LordHavoc: everyone hates cache mismatchs, so I fixed it

    if (lhcsum != glt->lhcsum || width != glt->width || height != glt->height)

    {

     Con_DPrintf("GL_LoadTexture: cache mismatch, replacing old texture\n");

     goto GL_LoadTexture_setup; // drop out with glt pointing to the texture to replace

    }

    return glt->texnum;

   }

  }

 }

 // LordHavoc: this was an else condition, causing disasterous results,

 // whoever at id or threewave must've been half asleep...

 glt = &gltextures[numgltextures];

 numgltextures++;



 strcpy (glt->identifier, identifier);

 glt->texnum = texture_extension_number;

 texture_extension_number++;



// LordHavoc: label to drop out of the loop into the setup code

GL_LoadTexture_setup:

 glt->lhcsum = lhcsum; // LordHavoc: used to verify textures are identical

 glt->width = width;

 glt->height = height;

 glt->mipmap = mipmap;



 if (!isDedicated)

 {

         GL_Bind(glt->texnum);

         GL_Upload8 (data, width, height, mipmap, alpha);

 }



 return glt->texnum;

}

Author:  Jozsef [ Thu Sep 22, 2005 3:46 am ]
Post subject: 

joequake already contains this fix.

the num_textures > MAX_TEXTURES issue is not a bug which should be fixed. Simply there's a limit for the maximal numbers of textures and if you reach that limit, you'll have to restart the game.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/