MipMap Problem

I am working on a 3D engine that uses multitexturing. The lightmaps that i get are not necessarily in powers of 2, so i use gluBuild2DMipMaps(…) to build mipmaps of that image. Everything is fine and light maps come out perfectly. However, when i enter from a region with low poly count to another region with high poly count (i am using BSP and not portals), i experience a little bit of frame drop plus a very nasty jerk. However, if i disable lightmaps the rendering is very smooth i.e. no nasty jerks. I have been stuck in this problem for weeks, and i have managed to figure out that the problem is due to the building of mipmaps. I believe that gl builds mipmaps of a the textures, the first time they become visible (or determines the appropriate texture the first time a poly is rendered, or something like that), and that is what causes the jerk when i enter from a region of low poly to a one with high poly, since after the first time, the jerk does not reproduce e.g. if i enter from region A to B, i get a jerk the first time i do this, after that (even after roaming around in the map for a long time), when i return back to region A and enter region B via the same path, there is no jerk. Can anyone help me in this regards. My system specs are as follows:
P4 2.4HT, 512MB Ram, GeForce FX 5700 Ultra, ASUS MB with 875 chipset.


Textures seem to be, at least on some cards, uploaded the first time they’re actually being used, so you could try warming up the system by drawing one invisible frame at the beginning, where you use all the textures.


gluBuild2DMipMaps() is very slow; it’s implemented on the CPU (as are all glu functions). It’s not even well optimized for current CPUs.

You’d be better off using GENERATE_MIPMAPS – that’s available on anything modern (GeForce2 and up, Radeon and up, at least!)

If texture bandwidth is still a problem, look into storing pre-compressed S3TC compressed textures on disk, with MIP maps, and just upload in one go when needed; this can save tremendously on bandwidth usage.

Edit: spling eror

Thanks a lot for your information jwatte. However, the game that i am developing is targetted for low end machines with intel extreme graphics, so that makes it impossible to use GENERATE_MIPMAP_* extensions. i haven’t tried using S3TC compressed textures, but i think that it will be useful. Any other suggestions anyone?

Intel Extreme supports the GENERATE_MIPMAP extension:


It’s likely that the Intel extension is still implemented in software, but it’s also likely to be a ten times faster software implementation than gluBuild2DMipmaps().

Originally posted by jwatte:
[QB]Intel Extreme supports the GENERATE_MIPMAP extension:

Wow, I always thought Intel Extreme Graphics was a very limited OpenGL implementation but it seems it does support some of the important extensions.