Sign in to follow this  

Design Question

This topic is 3149 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello! I have a question about my design. I'm writing a little C++ (DirectX10) Engine and currently I am writing on the math classes (Matrix, Spline etc). I put all math classes in the namespace "math" and obviously I thought this namespace has no dependecies. But now I want to be able to render some of my math classes; for example I want to be able to render my Spline or my Line. Of course I could add a D3DX10Device* member and a method render() to all my math classes that a renderable, but this would make my pure math classes dependent from render details. I dont like this idea because actually my math classes should just be concerned about the math and not some Device/DirectX/Render Details. How could I solve this problem? Thanks!

Share this post


Link to post
Share on other sites
Introduce a helper class such as LineRenderer, which is a friend class of Math::Line. Pass the LineRenderer a Math::Line on construction. Place the rendering logic in the LineRenderer implementation, using the information it pulls out of the Math::Line to actually do the rendering.

Share this post


Link to post
Share on other sites
Sign in to follow this