Archived

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

billybob

to those who have used both opengl and directx...

Recommended Posts

how similar are they? i''m abstracting the API from the program, but i have never used openGL, therefore my wrapper is heavily influenced by directx. if i design it so its mostly like directx, will it be possible to write an openGL version of it?

Share this post


Link to post
Share on other sites
yes it is possible

similar? depends on what part of the api.. i''ll suggest to code a little in gl, to get some idea. not much, just a little playing..

on www.opengl.org would be the full documented specs then:D

"take a look around" - limp bizkit
www.google.com

Share this post


Link to post
Share on other sites
It looks really difficult to me to add support for both the API''s... I''ve worked with both but I''m not so advanced that I could make something like that...

Nehe has good tutorials. You should get the feeling for OpenGl pretty fast. How are you planning to implement it? I''m currently planning a new engine and the design is giving some problems for me... Where to start, what to proces, which functions in the game engine and what in the game..

So if you want to tell me te theorie behind your idea i''m really interested

Share this post


Link to post
Share on other sites
About similarity: I think they both have about the same options (although DirectX has better shader support atm, when you get to shaders OpenGL has probably cought up anyway so that's no reason to go for DirectX I think)

I started with DirectX, which I found not very logical. When I switched to OpenGL, everything seemed so simple! I think OpenGL works more like your mind works. With DirectX you do all these things which someone who's new to DirectX doesn't understand. So you end up typing code someone else tells you to type.

With OpenGL, after a few days I understood how it worked, and I was able to create code on my own, because with OpenGL you do no (or few) things that are hard to understand for anyone. It just makes more sense...

That's why I chose OpenGL, but when I use DirectX now, I get it too. Maybe it's just that I started with DirectX, maybe if I started with OpenGL I'd be using DirectX now. But I think not. I think OpenGL is really easier.

About using both as a renderer, (OpenGL can only be used as a renderer) this is hard at first but when you get into programming, check out "The Engine" or "NGine" (it's the same) it's a project, a game engine done by the nehe.gamedev.net game programmers community. It's based on OOP (the only way to program an engine if you ask me) and it lets you chose between Direct3D and OpenGL too. It's kinda hard to explain in newb terms, but it's a bit like this:

You create an engine class:


class COGLRENDERER
{
void m_vInit(); // Init function
void m_vTerminate(); // Termination function
void m_vSetDrawMethod(); // Sets everything for drawing
}

class CD3DRENDERER
{
void m_vInit(); // Init function
void m_vTerminate(); // Termination function
void m_vSetDrawMethod(); // Sets everything for drawing
}

class CENGINE
{
int m_iType; // This integer is 0 for Direct3D, 1 for OpenGL
CD3DRENDERER* m_pcD3DRenderer; // Direct3D as the renderer
COGLRENDERER* m_pcOGLRenderer; // OpenGL as the renderer

void m_vInit(int a_iType); // Init function
void m_vTerminate(); // Termination function
void m_vSetDrawMethod(); // Sets everything for drawing
}

CENGINE::m_vInit(int a_iType)
{
m_iType = a_iType; // a_iType is the argument passed with the function, it's 0 for Direct3D and 1 for OpenGL

if (m_iType = 0)
{
m_pcD3DRenderer->vInit(); // Only D3D is set as renderer
}
else
{
m_pcOGLRenderer->vInit(); // Only OpenGL is set as renderer
}
}

CENGINE::m_vTerminate()
{
if (m_iType = 0) // The type was already set in init function
{
m_pcD3DRenderer->vTerminate();
}
else
{
m_pcOGLRenderer->vTerminate();
}
}

CENGINE::m_vSetDrawMethod()
{
if (m_iType = 0) // The type was already set in init function
{
m_pcD3DRenderer->vSetDrawMethod();
}
else
{
m_pcOGLRenderer->vSetDrawMethod();
}
}


If you do it right, you might even not need seperate Draw() functions (not SetDrawMethod, but Draw, that's not the same)

well this requires quite some programming knowledge so don't try this at home yet

but just ask in these forums where you can download the engine I was talking about, it'll show what I mean once you understand it

[edited by - Subotron on December 25, 2002 9:10:32 AM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I''ve been doing research on DirectX and Opengl and so far what i have discovered is, DirectX was designed to be a platform in wich developers could add special features like 3d shadows, Tripple Buffering, Antialiasing,ect. without worrying about what hardware the user has, For example If you make a program that uses special sound features like eviroment fadeing and directional sound you won''t have to worry about what sound card the user has or have to write specific hardware code, now OpenGL doesn''t do sound to my knowlage so you would have to either use directsound drivers anyway or program software drivers. With graphics you can put in all the 3dFx you want with direct 3d and you won''t have to worry too much about programing hardware code, But OpenGL wasn''t designed for wide flexability amongst all graphics cards just the ones that support its advanced features so you will either have to include software drivers or include GLsetup and pray there card has a counterpart with compatible drivers that support OpenGL (I.E.: Elsa WinnerII card can use S3 Savage4 drivers to make it compatible with OpenGL). OpenGL just does video unlike DirectX wich was designed to handle: Video, Sound, Input Devices, Network Interface devices, and on top of all that will diagnose and trouble shoot all of these. DirectX was designed by microsoft so compatability with windows is insured. OpenGL was designed by ID (i think plz correct me if i''m wrong) so its really meant mostly for games and has quite a few issues with windows and some video cards, but for compatible cards from time to time seems to draw faster and perform better (rarely) but others runs really slow, and tends to cause computers to crash more often than DirectX. So you tell me which is better?

Share this post


Link to post
Share on other sites
I do this with my engine (see signature). It is easier than you''d think to support both OpenGL and Direct3D; the hardest part is at the beginning, when you''re trying to come up with a scheme abstract enough to use the same interface for working with both APIs.

~CGameProgrammer( );
DevImg.net - Post screenshots, comment on others.
Town 3D Engine - A city-rendering 3D engine. Download the demo.

Share this post


Link to post
Share on other sites
I like the idea of some DLLs. you can have the same names and parameters for all the stuff that your program would call and then only load the DLL you want, so to the game loop, it doesn''t matter what you''re using, OGL or D3D.

Share this post


Link to post
Share on other sites
I have never heard that OpenGL was developed by ID, its development is handled by the ARB which is a board consisting of people from different corporations even microsoft untill recently when microsoft left. I know SGI and 3dlabs are developing openGL 2.0, and this is the second time ive heard someone mention hardware issues with OpenGL would you please show me these, because I have never run into any and I dont think all the quakes have either. John carmack programs in OpenGL because its multi platform and he likes it more, tho he has stated that Directx can't be ignored. Also I have never seen a direct3d program run faster than an OpenGL one. OpenGL I would say has a much greater compatibility due to it being multi platform. Also the thing about hardware specific code is through extensions. These are used to acess certain features because microsoft hasnt updated their openGL implementation since version 1.1. However from what I gather the ARB decides on an extension that works for all cards so you don't have to do hardware specific code(i dont know much about how that works tho), however somtimes the hardware specific code preforms better. Every effect I have seen done with direct3d i have seen done with openGL. If you google for info about openGL and stop by OpenGL.org you will discover alot.

Im not saying its better than direct3d jst that it can do everything direct3d can from what ive seen. DOOM3 uses OpenGL and thats one of the most graphicaly impressive games I have ever seen. Also there are programs that are platform independent that you can use for sound and input. SDL, FMOD, OpenAL. DirectX was designed for use with windows and thats it, in the early days of windows 95 graphic support for windows was so crappy that people still used DOS to program their games, but now directX is a good API for windows, thats the only catch is its only for windows. There is an article on this site comparing openGL and direct3d and it does a good job I suggest reading that. Also OpenGL is used in various graphical industries not just games. For example 3d rendering and animation software, like the one used to make toy story, or hte spirits within use openGL, also the medical and many other industries use it for their software.



[edited by - dead_roses on April 3, 2003 6:12:41 PM]

Share this post


Link to post
Share on other sites
wow, megabump. just in case anyone is wondering, i made a system with a pure virtual base class, which is my api independant interface, and implemented each api. i used void * to represent api dependant data, and the rendering class casts it to whatever it made it as.

Share this post


Link to post
Share on other sites