Archived

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

Aface

How To Structure OO App

Recommended Posts

Aface    124
Hi Guys, I am after some answers in my questions with setting up my app in an OO style. This is just one example, but i have a few situations where the problem is similar. I setting up a basic D3D app (for 2d drawing), and i am using the d3dxsprite helper class to render sprites. I have wrapped up the direct3D functions i think i will need (basically the init and release funcs). I also have a sprite class that encapsulated the data that goes with a d3dxsprite. Note that the example does not have to be the d3d derived sprite, but any sprite class. Now the question is this : as far as i understand it, some of the principles of oo is encapsulation and abstraction? I take that to mean that the sprite should not necessarily know about the direct3d class, and vice versa. The problem is, to render, the sprite requires a pointer to a direct3d backbuffer, which must be locked before being passed, so at least one class needs to be aware of the other. I can think of a few ways to get around this but currently i am using this method : The sprite draw() method takes the backbuffer as an argument. The direct3D calls a redrawgui() function, passing the backbuffer after locking it. This requires a global Gui object, which the direct3D class must know about as well. Am i missing something? is this method optimal? Thanks for any help or ideas. Aface

Share this post


Link to post
Share on other sites