DX9 Class Design?

Started by
4 comments, last by hplus0603 18 years, 7 months ago
Hi there, I am beginning to write a DirectX 9 graphics engine and want to know how other people are designing all the Direct3D functionality(ie-primitives, textures, lighting, models, etc.) in their game engine. Can anyone give me an overview of what classes you have in your graphics engine and a brief functionality of each? Thanks!
Advertisement
Thats quite a tall order, and I'm sure most people here would agree that their engines look very different and are quite different in design. I think figuring out how to make it all fit together and work is half of the fun anyway :)
Computers provide a reality second to none!
you have to make those classes that you need for your projects. Most of the engines out there are quite different than each other, and is made for different game styles.
As far as the basic primitive objects go (like VertexBuffer, Texture, ect...), I usually just wrap the useful functionality from the native D3D interfaces. I try to take any annoying aspects of the API out, as to make it much more developer-friendly. For example, VertexBuffer would have Fill() and Read() methods to suplement the standard Lock() function.

Also, it's really nice to have an object manager that automatically releases objects at engine shutdown. It should also destroy them on a device loss, and reset them on a device reset.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
It's a puzzle in which you define the shape of all the pieces and then try and put it together. =P

Everybody's implementation is different. The design is a reflection of your thought process.

My suggestion:

Start from a high-level point-of-view. Ask youself, "How would I like to use this framework/class/interface?"

"Sketch" the design of your code. I like to create empty classes with empty methods, and hook them up. It's an iterative process, filling in more detail, refactoring design, etc.

Don't have large classes with tons of methods. The best interface is minimal and compact. Strive for the simplest function signatures you can achieve.

Good luck.

I recommend having a look at Ogre -- and specifically the DX9 renderer module within Ogre.

As far as automatic release goes, you will need that for more cases than shutdown. Re-setting devices come to mind. Usually, it's a good idea to use CComPtr<> (from atlbase.h) for holding on to all your interfaces; it makes the reference counting pretty painless.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement