Archived

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

Zidane

Who should manage my graphic objects ??

Recommended Posts

Zidane    152
Ok first of hi! This is a design question and would like some input from you guys (and gals). My game engine works on the principle that the engine itself is not responsible for actually implementing rendering of any graphics rather it relies on the notion of a "driver" this driver exports a agreed interface with my engine and it is this driver that implements the rendering of any graphic objects. Now this is all fine and dandy but what I cant make my mind up is, should the driver or the engine be responsible for managing created graphic objects. The driver has the responsibility of creating these graphics as it derives from an ADT (IGraphic) and obviously the driver has to created a derived class and pass a base class pointer back to the engine, this hides all the implementation details of the graphic. At the moment the engine has the responsibility of managing the objects that the driver creates and then sending them back to the driver when they need to be drawn deleted etc As the graphic is just a member of the much larger game object class i was wondering do you think it better for the driver to manage the graphic object while the engine manages the game object class or should i stick with the engine managing the whole deal for example currently in my code when i create a graphic object it looks like this: CGameObject Player; Eden::CGraphicsManager::GetInstance()->CreateGraphicObject(&Player.m_pGraphic, GRAPHIC_STATIC); Now behind the scenes the CGraphicsManager singleton stores the pointer returned by the driver (CGraphicsManager is responsible for managing the loading of the driver, which on win32 is a dll) and when the Player is destroyed it is notified and deletes the graphic created for this object by calling a delete method the driver implements. But I still have a feeling that allowing my driver implementation to manage the memory asociated with the graphic objects may allow for better performance. BUT aaah i dont know any ideas???

Share this post


Link to post
Share on other sites
Mage2k    336
Object management is an issue of memory management and is not really related to rendering. The point of an object manager is mostly to ensure that you do not instantiate a given object more than once. The point of a rendering engine (your driver class) is to draw arbitrary objects to the frame buffer. For example, when you have multiple enemies of the same type in a level, you don''t want to store vertex information for each separate instance of the enemy on the level. Rather you want to load the model''s vertex data into memory once, and keep a reference along with transformation informartion in the separate enemy instances. So, whenever you are loading a level, when you load any given enemy, the object manager checks to see if the necessary model data is already loaded into memory; if not, it is and, in either case, a reference of some sort the vertex data is returned.

peace and (trance) out

Mage

Share this post


Link to post
Share on other sites