Jump to content
  • Advertisement

Archived

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

Steveyboy

OpenGL OpenGL & DirectX Matrix Library

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

I''m currently designing a game engine, which makes extensive use of DLLs. The render system is loaded from a DLL to enable me to switch between DirectX and OpenGL. However, i need to do something with my matrices. At current, all the matrix stuff is accessable to the renderer and the application, and at current the matrices are row-major (D3D) format. When i create the OpenGL renderer, i''ll need to convert everything every time i use a matrix. What should i do? I was considering allowing the render DLL to do all matrix stuff, and the application would just get a void* for a matrix - but if i do this, i''ll need to keep jumping into the render DLL to e.g. multiply matrices. Won''t this be a bit slow? It''ll be quicker than converting matrices for OpenGL calls, but i''m still worried about the performance. I also considered doing what OpenGL does - matrix stacks; a render DLL would have access to a matrix stack, and the application can call e.g. LoadIdentity(), MultMatrix(), etc. But surely this would quickly get confusing when 3 or more matrices are needed? Anyone know how games like UnrealTournament handle this? Cheers, Steve

Share this post


Link to post
Share on other sites
Advertisement
TO solve the matric formats, you could havet he DLL return a flag to indicate which format it uses. All the matrix math would be done with local functions in the EXE that would call either the D3D or OGL functions depending on which type is used. you could even add a 3DNOW function into there and use that (check the AMD website, their SDK has d3d and ogl functions)

so you would have s single multiply function, and that either calls the d3d, ogl or 3dnow functions based on the CPU caps and what format the render DLL wants

as for the matrix stacks, you wither have to bypass the stack on the OGL side or emulate it on the D3D side (maybe by having an array of matricies that is all added together before rendering) I guess you have to prefer an API for this one

Share this post


Link to post
Share on other sites
quote:

You would have s single multiply function, and that either calls the d3d, ogl or 3dnow functions based on the CPU caps and what format the render DLL wants


If i do that, then the EXE will need to be exposed to Direct3D and OpenGL - which is bad. I want to keep everything encapsulated, so the EXE doesn''t know (and doesn''t care) what its rendering on. I could have it spewing out ASCII art to a console if i so wanted.

As you said, i would be bybassing the OpenGL matrix stacks on the OGL side, and i''d be using an array of matrics on the D3D side.

I''m pretty sure i want the DLL handling all the matrix math, which would also allow me to choose whatever format i want within the DLL. The DLL could use SIMD, 3DNow!, etc (my current stuff already detects all this, it just isn''t optimized to use it *yet*).

Any suggestions on speeding this all up?
Steve

Share this post


Link to post
Share on other sites

  • 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!