Thread: opengl, or gdi?

  1. #1
    irregularly symmetrical n3v's Avatar
    Join Date
    Mar 2006
    Location
    Finland
    Posts
    67

    opengl, or gdi?

    alright, I feel that i've at least somewhat got a grip on c++, I've made a command line chess game, and I was trying to move on to big fancy graphics. First, I decided to take the next step in game complication. I'm trying to make a basic artillery trajectory game, like worms or pocket tanks. I figured gdi would be easier to get an initial grasp on, especially because i just need something 2d, but after a few weeks of scratching my head at my own code, i'm getting kind of frustrated. I can make a line that the cannonball should follow at the proper power and angle, but i've been hopelessly stuck at trying to get something to actually Follow the line. i guess my question boils down to this:

    1. is gdi even worth screwing with? if i plan to make more complex (3d) games in the future, i wouldn't think knowledge of gdi would help too much.

    2. is it any easier with opengl? right now i'm having to deal with changing the color of individual pixels on a window at specified coordinates, and i kinda think to myself that this probably isn't the most effective way to go about doing what i want to do.

    3. directx? i've heard directx is harder, but i've also heard that it's more robust, and can utilize effects and stuff more easily. either way, is it worth learning over opengl if my final goal is to make a robust game?

    thanks.
    If you make a man a fire,
    he will be warm for a day.
    If you set a man on fire,
    he will be warm for the rest of his life.

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    GDI is a waste of time.

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    Yep. It is.

  4. #4
    irregularly symmetrical n3v's Avatar
    Join Date
    Mar 2006
    Location
    Finland
    Posts
    67
    thanks guys. any other libraries i should consider, or is it opengl all the way?
    If you make a man a fire,
    he will be warm for a day.
    If you set a man on fire,
    he will be warm for the rest of his life.

  5. #5
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    499
    Use OpenGL. For windowing, use GLUT. It makes your code very portable, so if you suddenly want Linux or Mac users to join in on the fun, you can.

  6. #6
    irregularly symmetrical n3v's Avatar
    Join Date
    Mar 2006
    Location
    Finland
    Posts
    67
    windowing? by that, do you mean, small games that run in a window, or like, readily available to all? that's one piece of jargon i'm not familiar with.
    If you make a man a fire,
    he will be warm for a day.
    If you set a man on fire,
    he will be warm for the rest of his life.

  7. #7
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    Open GL is an open graphics library for Windows. Many window-based games use openGL.
    There is a good tutorial on this site about learning openGL, also check out gamdev.net for
    ne he tutorials. One word of caution, you will need to know some basic windows programming to get the best from openGL.

  8. #8
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Um no. OpenGL is not for windows, its a portable graphicslibrary that has been ported to many different OSs. And you dont really need to know any Windows-programming to get "the best out of it", its designed so your supposed to be able to use it with many platforms and still be able to get the best out of it.
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  9. #9
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    499
    I don't want this to get confusing. OpenGL runs on all systems, not just the operating system called "Windows". When I say windowing, I mean the window that a game runs in (even a fullscreen app has a window). GLUT makes creating a window much easier; you don't need Microsoft-specific code to make your window. The code will work on all operating sytems, not just MS Windows.

    Here's a GLUT sample:
    Code:
    glutInit(&arhc, argv);  // initalize glut
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);	// set the display mode
    glutInitWindowSize(width, height);	// choose the window size
    glutCreateWindow("GLUT Tutorial 2");	// display the window
    glutFullScreen();	// switch to fullscreen
    See? That's the only windowing code you will ever need (most of the time) in an OpenGL program. Much simpler!

  10. #10
    Banned SniperSAS's Avatar
    Join Date
    Aug 2005
    Posts
    175
    hey i am doing the opengl tutorial on this site you guys suggested

    can someone tell me why my compiler is ..........ing...

    Code:
    622 F:\drive\projects\opengl\first.cpp [Warning] passing NULL used for non-pointer converting 1 of `HWND__* CreateWindowExA(DWORD, const CHAR*, const CHAR*, DWORD, int, int, int, int, HWND__*, HMENU__*, HINSTANCE__*, void*)'
    for this line...

    Code:
            hwnd = CreateWindowEx(NULL, "MyClass",  //class name
                                                      "OpenGL Robot",       //app name
                                                      dwStyle |
                                                      WS_CLIPCHILDREN |
                                                      WS_CLIPSIBLINGS,
                                                      0, 0,                         //x and y coords
                                                      windowRect.right - windowRect.left,
                                                      windowRect.bottom - windowRect.top,//width, height
                                                      NULL,                 //handle to parent
                                                      NULL,                 //handle to menu
                                                      hInstance, 
                                                      NULL);                //no xtra params
    even though msdn says that parmeter can be null if no additional data is needed?

  11. #11
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>tell me why<<

    It's complaining about the first parameter being passed NULL, not the last as you have indicated. The first parameter of CreateWindowEx is a numeric (DWORD) type so use zero instead. It's arguably better to use zero instead of NULL for pointer types, too, unless you really want to make a statement to yourself about what types are involved.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  12. #12
    Banned SniperSAS's Avatar
    Join Date
    Aug 2005
    Posts
    175
    ahh, thanks

    in my defence the compiler did say it was that line

  13. #13
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    499
    Speaking of GDI, let me tell you about a book I just got out from the library. Never, ever buy this book. It's called "Beginning Game Programming" (Michael Morrison, published 2005 by Sams). Although it does have a few good points about game design, and what not, there is something seriously wrong with this book:

    It teaches you how to write games using GDI!!!!!!!

    I have never seen a book so stupid in my entire life, and I hope there never will be another like this. Granted, I picked out a beginning game programming book, even though I'm not exactly a beginner, but I just want everybody here to know how stupid this book is.

  14. #14
    Registered User
    Join Date
    Dec 2003
    Posts
    167
    It teaches you how to write games using GDI!!!!!!!]
    Is that all thats wrong with the book? If so then i don't think it's all that bad. I don't know anything about game programming but I would like to think that there are concepts important to game programming that doesn't necesarily have anything to do with a specific graphics api. The GDI choice may have been to *introduce* these concepts without getting bogged down with the complexities of the apis used in industry. I think the key word in the title is *beginning*.
    silk.odyssey

  15. #15
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    I wouldn't call it stupid, more "misguided". You can use any graphics library you want to write games, GDI is one of them. Back in the day, when DirectX didn't exist and OpenGL wasn't hardware-accelerated (and thus didn't exist on PCs), there were plenty of games that used GDI. Of course, given the constraints only puzzle games were really that feasible but for a good example look up Microsoft's rendition of Chips Challenge. It wasn't perfect, but it was good for the time, especially for Windows.

    These days, GDI practically uses the same hardware interface as DirectX when available, so you don't suffer much in the way of slowdown as far as 2D graphics is concerned. Of course, it don't do no 3D.

    It's somewhat surprising that they'd publish a book recently detailing the use of GDI for games, but what the hey, let Sams's profit margins take the flak.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  3. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM