Thread: Open GL Question

  1. #1
    Registered User
    Join Date
    Jul 2004

    Open GL Question

    Before i acutall make a window can anyone tell me if anything is wrong in this code
    #include <windows.h>               //Line One
    #include <gl/gl.h>                 //Line Two
    #include <gl/glu.h>                //Line Three
    #include <gl/glaux.h>              //Line Four
    //End Of Header Includes           //Line Five
    HGLRC hRC=NULL;                    //Line Six
    HDC   hDC=NULL;                    //Line Seven
    HWND  hWND=NULL;                   //Line Eight
    HINSTANCE hInstance;               //Line Nine
    bool keys[256];                    //Line Ten
    bool active=true;                  //Line Eleven
    bool fullscreen=true;              //Line Twelve
    GLvoid ReSizeGLScene(GLsizei width, GLsizei height)   //Line Fourteen
    {                                  //Line Fifteen
        if (height==0)                 //Line Sixteen
        {                              //Line Seventeen
            height=1;                  //Line Eighteen
        }                              //Line Nineteen
        glViewport(0, 0, width, height);                 //Line Twenty
        glmatrixmode(GL_PROJECTION);   //Line Twenty One
        glIdentity();                  //Line Twenty Two
        gluPerspective(45.0f, GLfloat)width/(GLfloat)height,0.1f,100.0f); //Line Twenty Three
        glmatrixmode(GL_MODELVIEW);    //Line Twenty Four
        glLoadIdentity();              //Line Twenty Five
    }                                  //Line Twenty Six
    int InitGL(GLVoid)                 //Line Twenty Seven
    {                                  //Line Twenty Eight
        glShadeModel(GL_SMOOTH);       //Line Twenty Nine
        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);           //Line Thirty
        glClearDepth(1.0f);            //Line Thirty One
        glEnable(GL_DEPTH_TEST);       //Line Thirty Two
        glDepthFunc(GL_LEQUAL);        //Line Thirty Three
        glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);               //Line Thirty Four
        return TRUE;                   //Line Thirty Five
    }                                  //Line Thirty Six
    GLvoid KillGLWindow(GLvoid)        //Line Thirty Seven
    {                                  //Line Thirty Eight
        if(fullscreen)                 //Line Thirty Nine
        {                              //Line Fourty 
        ChangeDisplaySettings(NULL,0); //Line Fourty One
        ShowCursor(TRUE);              //Line Fourty Two
    }                                  //Line Fourty Three
    if (hRC)                           //Line Fourty Four
    {                                  //Line Fourty Five
        if (!wglMakeCurrent(NULL,NULL)) //Line Fourty Six
        {                              //Line Fourty Seven
            MessageBox(NULL,"Release Of DC and RC Failed","Shutdown Error",MB_OK | MB_ICONINFORMATION);  //Line Forty Eight
        }                              //Line Fourty Nine
        if (!wglDeleteContext(HRC))    //Line Fifty
        {                              //Line Fifty One
            MessageBox(NULL,"Release Rendring Context Failed","Shutdown Error",MB_OK | MB_INCONINFORMATION); //Line Fifty Two
        }                              //Line Fifty Two
        hRC=NULL;                      //Line Fifty Three
    }                                  //Line Fifty Four
    if (hDC && !ReleaseDC(hWnd,hDC))   //Line Fifty Five
    {                                  //Line Fifty Six
        MessageBox(NULL,"Release Device Context Failed","Shutdown Error",MB_OK | MB_INCONINFORMATION //Line Fifty Seven
        hDC=NULL;                      //Line Fifty Eight
    }                                  //Line Fifty Nine
    if (hWnd && !DestroyWindow(Hwnd))  //Line Sixty
    {                                  //Line Sixty One
        MessageBox(NULL,"Could Not Unregister Class.","Shutdown Error",MB_OK | MB_INCONINFORMATION  //Line Sixty Two
        hInstance=NULL;                //Line Sixty Two
    }                                  //Line Sixty Three
    Thanks In Advance

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    That's what a debugger is for. Try compiling it. Or you could try entering your code into Google and seeing if there are sites that list the errors for this code. [edit] [/edit]
    Last edited by sean; 08-01-2004 at 08:59 PM.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Well line 43 onwards is badly indented
    So much so that the missing } on line 64 is not obvious

    Oh, and get a compiler
    It will tell you all this in a couple of seconds, rather than hours for message board replies.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open GL
    By alexnb185 in forum Game Programming
    Replies: 4
    Last Post: 08-18-2007, 11:52 AM
  2. I need help to compile this code...
    By wise_ron in forum C Programming
    Replies: 17
    Last Post: 05-07-2006, 12:22 PM
  3. 2 Open GL problems
    By Isometric in forum Game Programming
    Replies: 0
    Last Post: 11-30-2003, 10:09 PM
  4. open gl coding, animating an object
    By chris285 in forum Game Programming
    Replies: 1
    Last Post: 11-18-2003, 10:51 AM
  5. What's easier: Open GL or Direct X
    By Ryeguy457 in forum Game Programming
    Replies: 2
    Last Post: 09-13-2002, 12:04 AM