Jump to content
  • Advertisement
Sign in to follow this  
schupf

Design Question

This topic is 3396 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
Advertisement
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  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!