PDA

View Full Version : How to support both OpenGL and D3D



srhadden1
07-03-2000, 05:55 AM
In game development, some games support both direct3D and opengl. Is there any reason why they do this?

Code wise, is it as simple a matter to support openGL as to replace the D3D graphical calls with opengl calls?

dans
07-03-2000, 09:10 AM
No, its not this simple. You need to create an OpenGL compatable window for starters..

If you keep your data in a managable format it shouldnt be to much of a job to add simple OpenGL support. IE rendering primitives lighting color textures etc. You will need to use OpenGL only calls to do some of the more fancy tricks. Keeping to an earlier discussion -transperancy would need to be done diferently on each API.

If you isolated the functions that you were going to use, then you could make a wrapper around both API's where you just feed *your* API calls the data and then depending on what rendering API is chosen the data is passed the the relevant subroutine. If you are really intrested in this the check up on the Genesis 3D engine, it supports both openGL and Direct3D, the source is available on the web somewhere, I think they have changed names now so you may have to dig a little deeper to find info. Im sure that could give you more information than i could.

I almost forgot to mention why the developers use both, alot of the time its for cross platform compatability, There is no direct3D for any OS other than windows32. OpenGL works on a host of other OS's. A game for a classic example Quake uses only OpenGL for rendering, thats why Q3 is available on IMac and Linux, SHOGO is coming out on Linux one of these days, the linux developers did a total rewrite to OpenGL of the rendering core to make this possible, SHOGO did not support OpenGL when it came out on windows. So if 'lith coded shogo in opengl all this extra development would not have to take place to bring it to other platforms.
Now I think with Lithtec2 that it supports OpenGL from the word go. I think developers are noticing that there is a future in other OS's out there beyond MS windows and are willing (again) to work with them.


[This message has been edited by dans (edited 07-03-2000).]