Jump to content
  • Advertisement
Sign in to follow this  
ishikawa-san

OpenGL C#, DirectX, and Vectors

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

Ok, so here's a deal. I'm writting a Game Engine. So there's an IRenderer interface. So I make Directx, opengl, whatever renderer. So another thing, Vector3D class. It's clear that I cannot use diffrent vectors classes, for every renderer. So how can I deal with it? I mean, how can I use my custom vectors in directx? It's about drawUserPrimitive stuff right? I know, I found some examples on the net, but either it uses unsafe code, which does not satisfies me, or it just simply does not explain anything. Common, help me out. DirectX for C# is just soo poor documented. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
I think DX for C# is poorly documented because XNA and, latterly, WPF may overtake its use.

Anyway, if I've understood your question correctly, I believe your IRenderer interface will deal in your own Vector3D class (or, perhaps your IVector3D interface).

Each specific implementation of your IRenderer (D3DRenderer, OGLRenderer, etc.) will have to convert from the generic vector to their own specific implementation.

If you created an IVector3D, you could provide an adapter for each renderer:


class D3DVector : IVector3D
{
private Direct3DSpecificVector _vector;

public double X
{
get { return _vector.X; }
}

// etc...
}

Share this post


Link to post
Share on other sites
So this is what I was afraid of. I need to implement/convert, my Vector3D class, to OGL or DirectX one. But I looked to Irrlicht code, also Ogre3D, none of this engines does it. So there must be some other way I bieleve.

Thanks very much for the anwser anyway!

Share this post


Link to post
Share on other sites
Thinking about it, that's largely because renderers don't need to know anything about vectors... Vertex data, yes, but I don't think the client needs to pass the renderer any vectors directly?

Share this post


Link to post
Share on other sites
First, I wouldn't bother with C#/DX, just use XNA. You are stuck on Windows already (?) so make your life easier and use XNA which is the most well-documented SDK I have ever used.

Second, if you really want to make an OpenGL renderer in C# you probably need an OpenGL/C# wrapper like this:

http://csgl.sourceforge.net/

BTW, in C++ at least, OpenGL calls accept DirectX Vectors and Matrices. For example,

- any OpenGL call that expects float[2] can be passed DX Vector2
- any OpenGL call that expects float[3] can be passed DX Vector3
- etc...

So you might be able to use only the DirectX math library for both your DX and OpenGL renderer.

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!