Texture mapping

Is there a limit to the number of textures you can use in one application ?

In practice, no. Assuming you’re using texture objects (and if you aren’t, you should be) the OpenGL implementation will eventually run out of identifier names, but we’re talking billions here.

That said…

If you have a graphics card that accelerates OpenGL, it will store textures in the card’s own memory whenever possible. This gives a big boost in performance. If you start using more textures than will fit into the onboard RAM, the driver has to upload textures from main system memory to card memory every frame, and this is usually very bad for performance.

So: there’s no hard limit to how many textures you can use, but too many will hurt performance. The exact number will depend on lots of things - how much memory your card has, how much of that memory s taken up by the framebuffer, and how big your individual textures are.

Hope this helps,

Mike

You can also put 64 32x32 textures in a single 256x256 OpenGL texture, with a simple adjust to your texcoords.

Originally posted by coco:
You can also put 64 32x32 textures in a single 256x256 OpenGL texture, with a simple adjust to your texcoords.

True, but I don’t know that I’d recommend that in a beginner thread. Once you start using sub-textures you get a whole bunch of messy issues with filtering around the edges - bits of adjacent subtextures getting mixed in with the edges of “your” subtexture - and you can’t just clamp or wrap any more.

MikeC

big boost in performance. If you start using more textures than will fit into the onboard RAM, the driver has to upload textures from main system memory to card memory every frame, and this is usually very bad for performance.

So how do I load my textures into the
graphic board memory explicity? Or this
an automatic process.

cc246 - no, you don’t need to worry about this. The driver is responsible for loading textures into card memory, and if you have more textures than will fit it’ll usually try to optimize by keeping the most recently used ones loaded. Some drivers (recent Permedia ones in particular) can get very advanced in this respect.

With OpenGL texture objects you can also specify a priority as a hint to the driver, but there’s been a fair bit of discussion lately (mostly from Tim Sweeney) as to whether this is adequate, and new functionality in this area may appear in a future release.

Cheers,

MikeC

Supposedly, the idiots that wrote 3dfx’s drivers hard coded a max number of textures into the drivers (something like 256). It was one of the major graphics bugs in the game recently released game Asheron’s Call. I’m not sure if they fixed it or not. Other than that unusual case, most drivers don’t hyave a max number of allowed textures.

-Daedalus