Convert DirectX 9.0 to OpenGL

Dear Experts,

I am looking for a way to convert an application that uses DirectX 9.0 to render its graphics, to use OpenGL instead. This means I need to change the DirectX 9.0 API calls with OpenGL ones.
I am aware of the HLSL2GLSL from ATI but that is only for shaders? I am looking for a documentation (?) or a resource that can help me with the porting.

Any help is appreciated.
Who is Participating?
Jose ParrotConnect With a Mentor Graphics ExpertCommented:
There is no FROM-TO between OpenGL and DirectX, despite their similiarities. Their environments aren't equally described, althought the concepts are the same. The better approach to port is to classify the called functions in your program such that you see them in blocks, thus allowing you to port blocks, instead to try port from one API call to the other in a function by function basis
For example, a simple initialization of an empty window in DX9 will call the following functions:
Direct3DCreate9, GetAdapterDisplayMode, CheckDeviceFormat, GetDeviceCaps, CreateDevice, Clear, BeginScene, EndScene, Present, Release, D3D_SDK_VERSION, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16, D3DCREATE_HARDWARE_VERTEXPROCESSING, D3DSWAPEFFECT_DISCARD, D3DCLEAR_TARGET, D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE, BackBufferFormat, SwapEffect, Windowed, EnableAutoDepthStencil, and AutoDepthStencilFormat.
The "same" initialization io OpenGL will call:
GetDC, ChoosePixelFormat, DescribePixelFormat, SetPixelFormat, GetLastError, wglCreateContext, wglMakeCurrent, wglDeleteContext, ReleaseDC, glClearColor, SwapBuffers, PIXELFORMATDESCRIPTOR, PFD_DRAW_TO_WINDOW, PFD_SUPPORT_OPENGL, PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, nSize, nVersion, dwFlags, iPixelType, cColorBits, cDepthBits, GL_COLOR_BUFFER_BIT, and GL_DEPTH_BUFFER_BIT.
So you can define the INITIALIZATION block as a high level programming function.
I can suggest you to walk at the Kevin Harris' site, where you'll find good equivalent sample codes in both DX and GL, at There you'll find the way.
Jose Parrot
ChoklanderAuthor Commented:
Thanks. That helps.
All Courses

From novice to tech pro — start learning today.