Skip to main content
gamedev.net
🔒 Locked

Texture swapping

Started by Maddibob Oct 27, 2004 at 7:13 AM 2 replies 550+ views
Original Post
Maddibob
Maddibob
When rendering with multiple textures, what's the best way to swap them. I have 3 textures used for landscape and 1 for objects. The 3 textures for landscape are loaded into 0,1,2 and the landscape drawn using 4 stages. Then to draw the objects, I change texture 0 to the object texture and disable the texture stages and render the objects. In the next render pass, I have to reset texture 0 to the first landscape texture (1 and 2 are left intact from the first pass). Is this the right way to do it? If I have 4 object textures, do I just change texture 0 to each of the object textures and render? If you do SetTexture(0, ) is that actually loading the texture onto the video card? Or is it already on the card when you do LoadTextureFromFile (or whatever the method is). Thanks
Lutz
Lutz
The textures are already in VRam if there is sufficient VRam memory available (which should be the case for 4 or 5 textures). Only if the size of all textures exceeds the VRam, then textures are dynamically uploaded from CPU RAM to VRam by the GL driver.

The way you do it is absolutely OK. Binding textures is said to be a quite expensive operation in terms of execution time, but binding 10 or even 100 textures each frame should still be OK. See for example Ysaneya's Journal . He draws maybe several 100 clouds. Each cloud has it's own billboarding texture, so he needs to bind several 100 textures each frame and he still gets >200 FPS.
Maddibob
Maddibob
Thanks Lutz

What do you mean by 'Binding textures'?
Lutz
Lutz
Calling glBindTexture

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.