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?
}
Sprite engine optimization question...
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....
[Edited by - Khaosifix on January 10, 2005 12:13:06 PM]
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.
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.
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?
You could point to the already loaded image, but you would still have to blit the image onto each surface.. or?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement