Help with OO approach to D3D9 Graphics engine

Obvious

Newcomer
Joined
Dec 23, 2003
Messages
2
I'm writing a small graphics class for direct3d 9 and have some OOP problems.

CGraphics contains the d3d device and initialization/drawing code. It also contains CTextureManager as public.

I figured there's nothing wrong with typing something like:

Code:
Graphics.TextureManager.AddTexture(FilePath)

Another option is to wrap the texture manager methods in the graphics class like:

Code:
Sub CGraphics.AddTexture(FilePath)
    TextureManager.AddTexture(FilePath)
End Sub

Graphics.AddTexture(FilePath)

Which way is best and why?

Now my problem is the texture manager needs access to the d3d device in order to load textures. How should I set up my scope and structure in a professional way?

I could get around this by making the Device a public property and typing:

Code:
TextureManager.Device = Graphics.Device

but that would be sloppy and I know there's a better way.

If my whole approach isn't right, I'd be happy to be shown a better structure.
 
For your first question. I would say a better approach is the first one. Since the instance of the TextureLoader is public, why not let it handle its own business. You don't want one class to handle everything just by setting up methods that simply forward to another method.

You could padd the device through a constructor to the TextureLoader. That is how a lot of Direct3D objects get a reference to a device when they need it.
 
Back
Top