Design issue concerning objects and directx

Started by
3 comments, last by lubby 18 years, 6 months ago
Ive always kept objects (the actual geometrical objects that are drawn) sperately from the rest in opengl. Meaning I have a class that handles opengl states setups etc. and an object class. Now I have a minor difficulty porting this to directx due to its necessity for handling device resets. Basically the only thing I came up with so far is to keep a list in the setup class which contains all objects. A device reset then traverses the list and calls a reset function for all objects. I just find this unecessary overhead and its difficult to remove elemts from the list (requires a find call wich is at least O(log n). Any design ideas? Thanks in advance. -CProgrammer
Advertisement
I dont really see the problem with maintaining this list, even if you are adding removing objects every frame, the overhead should not be significant.

However if you do not want this list in setup all together, I am taking a punt that you do maintain a list/array of your objects somewhere (ObjectManager?) In this case why not allow the class like Setup() access to that list.

const std::vector<Object*>& objects = ObjectManager::GetInstance().GetObjectList();

Just make sure use const ref.. but even if not, for resetting the device is not going to be so time critical.

If you do not have this list somewhere, then I begin to worry about how you manage your objects :)

Yes I do in fact have a quadtree managing all the objects.
The quadtree is actually not a part of the API wrappers (opengl and DX now) and neither is the object class that the quadtree hold instances of. Now I wanted to to avoid incorporating the whole reset command for objects in the general engine code and keep it in the dx wrapper.

What do you think? Make an extra list to keep all dx specific code in the wrapper or adjust the overall engine design, leaving the reset command unused when using opengl?

-CProgrammer
How does OGL avoid the issues of device loss? MS didn't just put it in D3D for a reason, so what's with that? Is everything backed up in sysmem for OGL and it restores it automatically? You can kind of do this in DX my using managed textures, buffers etc.
So the object class is capable of rendering itself / or passing itself to the renderer, and the Quadtree contains pointers to these objects? If this is your method, I really see no other way than to implement a OnDeviceReset() method for each object.

This topic is closed to new replies.

Advertisement