Jump to content
  • Advertisement
Sign in to follow this  
Khaosifix

Sprite engine optimization question...

This topic is 4935 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I've come to realize that having 50 sprite class objects that loads in the same exact image is a waste of memory. I want to make it so that any future sprite class object that loads in a image which already resides in memory to point to the memory location of which the already loaded sprite resides....
class cShip : cObject
{

   // Same stuff as cObject but defined.

   cSprite m_sTexture ;

} ;

std::vector<cObject*> g_EnemyShips( 50 ) ;

GLvoid cGame::SetupData( )
{

   // define all 50 elements in a loop obviously
   // The problem lies here though. When 50 cObject/cShip objects
   // are defined here 50 of the same texture/image are loaded 
   // via cSprite. From my judgment it is a bad idea to have 50
   // of the game images loaded into memory. Any suggestions?
}



[Edited by - Khaosifix on January 10, 2005 12:13:06 PM]

Share this post


Link to post
Share on other sites
Advertisement
Use some sort of texture manager.
As a simple one this could be a simple list. Check if you have already loaded this texture. If yes, then return a pointer to the loaded texture.

Share this post


Link to post
Share on other sites
He's not necessarily using a 3D API, what if each ship has its own surface?
You could point to the already loaded image, but you would still have to blit the image onto each surface.. or?

Share this post


Link to post
Share on other sites
I'm using SDL for this. I am, however, very familiar with OpenGL and plan on using it for future projects. I think OpenGL using a similar texture manager system since each texture you load has a 32-bit ID. Maybe I should construct a system similar to that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!