OpenGL question

This is a discussion on OpenGL question within the Windows Programming forums, part of the Platform Specific Boards category; When looking on the web at various tutorials, I have seen two main different ways OpenGL is implemented, and I ...

  1. #1
    Malek
    Guest

    OpenGL question

    When looking on the web at various tutorials, I have seen two main different ways OpenGL is implemented, and I was wondering if someone could tell me what the difference is.

    The first way (and the easiest way to implement it seems to me) is when you use the main OpenGL functions. Here's an example:

    int main(int argc, char **argv)
    {
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
    glutInitWindowPosition(100,100);
    glutInitWindowSize(640,360);
    glutCreateWindow("My Window");
    glutKeyboardFunc(keyPressed);
    glutDisplayFunc(myDisplay);
    glutReshapeFunc(myReshape);
    glutMainLoop();

    return(0);
    }

    This method you just make the functions you passed in, and have them do what you want, and it seems uncomplicated and easy to do. But then there is the other method, which goes about implimenting OpenGL by first going through all the windows stuff. It has the functions like:


    HDC hDC=NULL;
    HGLRC hRC=NULL;
    HWND hWnd=NULL;
    HINSTANCE hInstance;

    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

    and things like that, and doesn't use many of the opengl functions described above, yet you still use the opengl drawing functions.

    I was wondering what the difference was, and what (if any) the advantage of using the more complicated second method is? It seems to require a lot more lines of code, but does it have some advantage?

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    ok heres the difference's

    on the first:

    its a platform independant library called the GLut OpenGL Utility Toolkit its used to handle all the window code for you and the same code will run on virtually any Operating System.
    this does limit you in a few ways but it depends on what you want to do with gl, whether you'll wan't to use GLut.

    on the second:

    its win32 code used to setup a GL window for Windows only
    while this gives a little more flexibility it is many more lines of code and a bit more complicated that GLut.

    bottom line:

    use Glut if your starting out and wan't to learn GL with out the hassels of Win32.

    if you know Win32 already then either is fine.

    >I was wondering what the difference was, and what (if any) the advantage of using the more complicated second method is? It seems to require a lot more lines of code, but does it have some advantage?<

    Win32 is slightly faster and gives more control to the programmer but is only for Windows and it's more complicated to use.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL Question
    By Halo3Master in forum Game Programming
    Replies: 16
    Last Post: 10-02-2007, 02:40 AM
  2. Opengl question
    By Shadowwoelf in forum Windows Programming
    Replies: 3
    Last Post: 06-03-2007, 01:21 PM
  3. OpenGL Camera Question
    By Astra in forum Game Programming
    Replies: 2
    Last Post: 03-25-2007, 01:53 PM
  4. OpenGL Question
    By Shamino in forum C++ Programming
    Replies: 5
    Last Post: 05-05-2005, 02:35 PM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21