Obvious Posted December 27, 2003 Posted December 27, 2003 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: Graphics.TextureManager.AddTexture(FilePath) Another option is to wrap the texture manager methods in the graphics class like: 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: 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. Quote
*Experts* mutant Posted December 27, 2003 *Experts* Posted December 27, 2003 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.