Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

OpenGL Presetting Direct3D9 with OpenGL setup

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

What are the general procedures to setup the Direct3D API to act like a OpenGL one?

The conversion headache constantly pounding in the brain because it is too difficult to handle just like

the normals conversion.

Any good advices for me?

Thanks

Jack

Share this post


Link to post
Share on other sites
Advertisement

It would be helpful if you gave specific examples of the areas that caused you trouble.  In general, D3D9 and OpenGL, assuming you're using a reasonably modern level of OpenGL, are actually more similar than they are different.

Share this post


Link to post
Share on other sites
Direct3D9 cannot operator identically to OpenGL. Neither API (until relatively recently) offered enough features to completely mimic the other in terms of texture coordinates, depth ranges, etc.

You will typically have to abstract between D3D and GL at a slightly higher level. Your shader framework for instance will have to know to invert texture coordinates, and your projection matrix functions will have to know whether they're creating a matrix for D3D or GL.

iirc D3D9 and GL also use different offsets for pixel coordinates (corners rather than centers) requiring you to add a +0.5 offset to some operations. Again, this needs to be handled yourself in a some layer of code over the low-level device abstraction.

Note that you probably actually want the opposite of what you're asking - when possible, do things the D3D way. OpenGL carries some legacy decisions that weren't the best in hindsight (e.g. the GL NDC depth range of -1..+1 is consistent but nonoptimal).

Share this post


Link to post
Share on other sites

What are the general procedures to setup the Direct3D API to act like a OpenGL one?

 

technically, the answer is "write an abstraction layer".

 

the abstraction layer is a wrapper API for DX that mimics OGLs API (as well as possible).

 

as mhaigen says, they're both t-mapped poly engines with similar behavior. i can understand OGL code, while only being familiar with DX code.

 

but as sean says, they do have their differences, such as Left hand vs right hand coord systems by default.

 

if you're "porting" ogl code / data to DX, simply converting everything to DX, and then just using DX might be best. similar to the way i export blender data as dx9 format, then just use dx9 code in Caveman 3.0.

 

FYI, when starting a project, as its now evident to you no doubt, its a good idea to choose tools, file formats, libraries, and languages that can "talk" to each other easily. this avoids the headaches, you seem to be encountering.

 

OTOH, if truly porting existing code from one API to another, along with converting data formats, in that case, "sometimes you gotta break a few eggs to make a real mayonnaise".  such is life. into each life a little work must fall. soldier on - you'll get there. oh, and work smart, not hard.  Think first - then code.

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

...they do have their differences, such as Left hand vs right hand coord systems by default.

 

Actually this difference no longer exists, even in fixed pipeline D3D9 with D3DX matrices.  See eg.g D3DXMatrixPerspectiveRH.

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!