Archived

This topic is now archived and is closed to further replies.

jmszczap82

Clearing a texture...

Recommended Posts

Hi, Simple question... what''s an easy way to clear a texture from the screen. For example, during collision detection. Also, what''s the proper way to "destroy" a texture. For instance, if it moves off the screen and has no need to be in memory any longer. - JS

Share this post


Link to post
Share on other sites
Well,
Say that texture A (player) collides with texture B (enemy). How would you clear/erase A, so it can be replaced with an animation or another texture. This, I''d assume, would be done prior to my second question.
Thanks for your response.
- JS

Share this post


Link to post
Share on other sites
I personally would load the data for the model (texcoords and vertices) only once and use a resource manager to parcel out the data as needed by different objects. As for swapping textures, I would keep everything resident and just switch to a different texcoord set (and possibly a different texture) when a change needed to occur. In general, your graphics card will do better with prioritizing textures (by caching often- and recently-used textures) than you will (by constantly loading/unloading what you need).

Later,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links


[edited by - zealouselixir on August 30, 2002 12:15:11 AM]

Share this post


Link to post
Share on other sites
Well, generally one has either a list of textures used for animation. If you want to have a special animation for the player colliding with an enemy, you just load a second texture and do something like

  
if(Player.IsColliding())
glBindTexture(GL_TEXTURE_2D, Player.CollidingFrame);
else
glBindTexture(GL_TEXTURE_2D, Player.NormalFrame);
<draw code here>

or something similar.

Next: Generally, the only time you want to load and unload textures is on a level change or when starting or closing the game. Even if an object using texture B moves off screen, it could come back, or maybe a new object using texture B will be created somewhere on the screen and you would need the texture again. But, when you need to unload the texture, what ZealousElixir said is correct.

"The Requested Information Is Unknown Or Classified" -Anonymous

Share this post


Link to post
Share on other sites