Advertisement

Direct X and Open GL

Started by December 12, 2002 02:27 PM
2 comments, last by smiley4 21 years, 11 months ago
Concerning the two, I don''t care wich is better. I''ve seen games that you can load and choose between wich you will use. I want to know: can you program your graphics in only one language and still use the swichable option for your game? Or, do you have to program it in both languages and then have C++ switch between wich one it will use?
Now I shall systematicly disimboule you with a .... Click here for Project Anime
Well, firstly, OpenGL and DirectX aren''t really analogous. Direct3D is the 3D graphics component of DirectX, the comparison should be between Direct3D and OpenGL.

Second, they aren''t "languages" - it''s all the same language, they''re just different ways of doing things, different APIs.

So, really you''re going to have to code a wrapper for each API, in order to provide functions common to both in the same interface. You can do this by creating a renderer base class with interfaces to common functions, then deriving a class and implementing them with respect to each API.

In short, you will have to write code for both Direct3D and OpenGL to use both. Something that many people recommend which I haven''t tried myself is to implement the derived renderers each in a DLL, so you can dynamically load each class on demand instead of loading everything at the beginning of the program.

Peace,
ZE.

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[twitter]warrenm[/twitter]

Advertisement
If you want the user to be able to switch between OpenGL and DirectX mode, you will have to write your code which accesses these 3D Graphics APIs twice, once for DirectX and once for OpenGL.

However, it may be easier for you to simply use a third-party 3D API which supports both Direct3D and OpenGL. That way, you only have to write code for one 3D Graphics API.
Heh... I made an abstract renderer class. An OpenGL (or D3D) renderer class inside a dll (plugin) inherits from that. Not that it''s new or something.... but it works so far.

I remember Trent Polak''s Ngine doing this at nehe''s site but due to lack of time, it has been removed . Luckily I downloaded it before it was removed.

Anyway, ZealousElixir''s solution combined with dll plugins is an option (assuming you use Windows-->D3D).

This topic is closed to new replies.

Advertisement