Thread: OpenGL vs. DirectX ???

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    56

    Question OpenGL vs. DirectX ???

    Tell me if my assumption is correct;

    While DirectX offers some more advanced options, OpenGL can be used earlier in the learning curve of a new C++ Programmer.

    Additionally, Whereas DirectX now has a 200+ Megabyte SDK, OpenGL has more readily available resources.

    Is this a correct assumption?

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Pretty much, yeah. OpenGL isn't as advanced as DirectX, but it's easier and portable.
    Away.

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    56
    Is OpenGL a good precursor to DirectX?

    And, can you use a little GL here and then some DX there in your code? Or is it one way or the other?

  4. #4
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    It's one or the other man. Not both.

    There seems to be a lot more documentation about OpenGL online than for DirectX. NeHe dwarfs NeXe, and most of the OpenGL tutorials seem to be better than the DirectX ones. Of course... OpenGL is old, and DirectX is current.
    Away.

  5. #5
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    I don't think that really describes it. OpenGL is easier to set up. It's like 300 lines of code and you're ready to go whereas in DirectX you'd need about 800 lines (or so I heard) (that is in both cases without using the utility libraries that make things a lot easier in DX as well as in OpenGL).
    Once you've set up everything, the basic stuff is done the same way in both APIs. DirectX has the major advantage that it doesn't need all those extensions OpenGL programmers have to fight. I think DirectX code will be easier to maintain unless you avoid GL extension, but if you do that, your OpenGL app won't be much better than a simple DirectX 3 application.

    As for speed, the APIs are equal. There is't much that DirectX can do that OpenGL can not do (and vice versa). If you are primarily interested in game coding, it may be a hard decision. If you want clean code, use DirectX. OpenGL extensions can really be a pest. Anyway, basically if you want to do anything but game coding, there is only one anwser: OpenGL. It's *the* standard.

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    56
    Thanks!

    I think the major difference in info availability has a lot to do with the difference between a .org and a .com

  7. #7
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Originally posted by Grumpy_Old_Man
    Thanks!

    I think the major difference in info availability has a lot to do with the difference between a .org and a .com
    Dou you mean the $ behind the M?

  8. #8
    Registered User
    Join Date
    Aug 2003
    Posts
    56
    LOL! Yes...

    But, I have another question...

    I checked out the OpenGL Tutorials on nehe.gamedev.net and couldnt get the first lesson to compile. it had a zip of the lessons source code;
    http://nehe.gamedev.net/data/lessons/devc/lesson01.zip
    I wanted to compile and run it then go back to the lesson to learn how it did what it did.


    I am using Dev C++ 4 and when I load the project file none of the other stuff loads into the project.

    I can copy and paste the source.cpp and the makefile.win into a new project, but once it goes from the compiler to the linker I get a slew of text telling me about undefined references as such;

    Is this a system, dense_operator,compiler, or other glitch?

    c:\windows\TEMP\cc7wVzfb.o(.text+0x38):lesson1.cpp : undefined reference to `glViewport@16'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x45):lesson1.cpp : undefined reference to `glMatrixMode@4'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x4d):lesson1.cpp : undefined reference to `glLoadIdentity@0'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x84):lesson1.cpp : undefined reference to `gluPerspective@32'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x91):lesson1.cpp : undefined reference to `glMatrixMode@4'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x99):lesson1.cpp : undefined reference to `glLoadIdentity@0'
    c:\windows\TEMP\cc7wVzfb.o(.text+0xb7):lesson1.cpp : undefined reference to `glShadeModel@4'
    c:\windows\TEMP\cc7wVzfb.o(.text+0xd1):lesson1.cpp : undefined reference to `glClearColor@16'
    c:\windows\TEMP\cc7wVzfb.o(.text+0xe0):lesson1.cpp : undefined reference to `glClearDepth@8'
    c:\windows\TEMP\cc7wVzfb.o(.text+0xf0):lesson1.cpp : undefined reference to `glEnable@4'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x100):lesson1.cp p: undefined reference to `glDepthFunc@4'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x115):lesson1.cp p: undefined reference to `glHint@8'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x13b):lesson1.cp p: undefined reference to `glClear@4'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x143):lesson1.cp p: undefined reference to `glLoadIdentity@0'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x258):lesson1.cp p: undefined reference to `wglMakeCurrent@8'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x282):lesson1.cp p: undefined reference to `wglDeleteContext@4'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x854):lesson1.cp p: undefined reference to `ChoosePixelFormat@8'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x898):lesson1.cp p: undefined reference to `SetPixelFormat@12'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x8ce):lesson1.cp p: undefined reference to `wglCreateContext@4'
    c:\windows\TEMP\cc7wVzfb.o(.text+0x914):lesson1.cp p: undefined reference to `wglMakeCurrent@8'
    c:\windows\TEMP\cc7wVzfb.o(.text+0xc2f):lesson1.cp p: undefined reference to `SwapBuffers@4'

  9. #9
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    It looks like you're forgetting to link some libraries.

    And there are things DirectX can do that OpenGL can not. For one, I don't think OpenGL has support for shaders (pixel/vertex) while DirectX does. Also, DirectX has support for your graphics looking good, while OpenGL does not DirectX also runs better on most video cards than OpenGL, since the cards are optimized with DX in mind.
    Away.

  10. #10
    Registered User
    Join Date
    Aug 2003
    Posts
    56
    Originally posted by confuted
    It looks like you're forgetting to link some libraries.
    <<Ohhhh...

    Uhhh, is that a compiler, coding, or preference thing?

  11. #11
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    It will be in the settings for your compiler somewhere.
    Away.

  12. #12
    Registered User Bieh's Avatar
    Join Date
    Sep 2002
    Posts
    83
    'Direct3D vs. OpenGL: Which API to Use When, Where, and Why' - here
    "It always takes longer than you think, even when you take Hofstadter's Law into account."
    -Hofstadter's Law

    Bored? Try my game SpaceWars , made in Allegro and VC++
    or see my new game Redoubt , made in OpenGL and VC++

  13. #13
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Originally posted by confuted
    It looks like you're forgetting to link some libraries.

    And there are things DirectX can do that OpenGL can not. For one, I don't think OpenGL has support for shaders (pixel/vertex) while DirectX does. Also, DirectX has support for your graphics looking good, while OpenGL does not DirectX also runs better on most video cards than OpenGL, since the cards are optimized with DX in mind.
    Cards optimized for DirectX ??? Since when ? OpenGL no vertex shaders ? It's an extension - like all the new stuff.
    I may be a bit biased, but as long as games like Quake and Doom3 prefer OpenGL over DirectX, I'll stick with OpenGL =)


    As for the linker errors: you need to specify some parameters for the linker so he knows which libraries to build into the exe.

    Go to the project options, linker parameters and enter

    -lopengl32
    -lglu32
    -lglaux

    if you need jpegs, you'll also need to specify
    -ljpeg

    on a sidenote: if you use jpeg.h, you will need to include the header as a plain C header with ...

    Code:
    extern "C" {
    #include <jpeglib.h>
    }
    I mention this because it took me ages to find out and I know the nehe tutorials will at some point require jpeg textures.

    Also, if you use the nehe tutorials, scroll all the way down. There are special downloads for DevC++

  14. #14
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    NVidia's latest cards have had built-in support for DX9 stuff.

    And a lot more games for Windows use DirectX than OpenGL. There is a reason.
    Away.

  15. #15
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    Originally posted by confuted
    NVidia's latest cards have had built-in support for DX9 stuff.

    And a lot more games for Windows use DirectX than OpenGL. There is a reason.
    Thats one way of putting it. All those features are available as NV_ extensions for OpenGL.
    Also the number of games doesn't say anything about neither OpenGL nor the quality of the games. It's logical to pick DirectX as Development platform if your game is Windows only because it is a lot easier to code applications for it. Sure, it's harder to set up, but after you did this you don't need to care about all those different vendor specific codepaths. DirectX does that all for you. So yeah, it's more productive to use DirectX. Thats why OpenGL 2.0 is on it's way - hopefully.

    Well, I won't turn this thread into a flamefest. DirecX has it's advantages as well as OpenGL has. You prefer DirectX, I don't. Nothing wrong with it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Going from DirectX to OpenGL
    By Wraithan in forum Game Programming
    Replies: 19
    Last Post: 02-24-2006, 11:07 AM
  2. Allegro, OpenGL.. or even DirectX?
    By Zeusbwr in forum C++ Programming
    Replies: 1
    Last Post: 11-14-2004, 08:16 AM
  3. Which is better: OpenGL or DirectX
    By Stan100 in forum Game Programming
    Replies: 2
    Last Post: 05-09-2003, 04:43 PM
  4. OpenGL 2 or DirectX ?
    By alex6852 in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 01-02-2003, 02:31 PM
  5. So.. what's the difference between DirectX and OpenGL?
    By QuestionC in forum Game Programming
    Replies: 6
    Last Post: 01-19-2002, 06:18 PM