Jump to content
  • Advertisement
Sign in to follow this  
beebs1

Interfaces

This topic is 3668 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

Hiya, I posted about this a while ago, and jpetrie kindly gave me some advice. I've taken this on board, but I still have a problem I can't seem to solve. Could anyone help? The problem is with abstracting a renderer. I have a Renderer interface, and an implementation which contains a D3D9 device - and also a VertexBuffer interface which contains a D3D9 vertex buffer. The problem is that as they are both pure-virtual interfaces (which shouldn't expose D3D objects), the D3D device can't easily 'get at' the D3D vertex buffer to draw it. The only way I can think of getting around this is by creating a third object - some sort of buffer 'handle' given to the client code, instead of the actual buffer. Then the renderer can own all the VertexBuffers, and look them up in a map (using the handle) to draw them. I'm not sure if this is good though, or if it might be too slow? There is likely to be a large number of buffers in use... Can anyone comment? Thanks very much for any help [smile]

Share this post


Link to post
Share on other sites
Advertisement
If the D3D9 implementations are in the same library (and they should be), you can cast from the interface to the implementation.

For example:, from the user's perspective, your abstract RenderSystem class receives a VertexBuffer. In actuality, the RenderSystem is say, a D3D9RenderSystem, that casts the VertexBuffer to a D3D9VertexBuffer. D3D9VertexBuffer would expose the underlying buffer.

A good library to use as an example of this (aside from all the singletons) is Ogre3D.

Share this post


Link to post
Share on other sites
Thanks for your reply. I didn't realize you could do that, I guess a static_cast should do the trick. Thanks!

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!