Stuck on NeHe OpenGL tutorial....the first one >:(

Discussion in 'Mac Programming' started by chrono1081, Dec 22, 2010.

  1. chrono1081 macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #1
    Hi Guys.

    I'm new to OpenGL. The only experience I have in it was tweaking code in already written OpenGL code. Now I am learning it on my own.

    I bought the OpenGL SuperBible and its nice but I want to learn to set it up and use it without requiring the GLTools framework the book requires. I turned to the Nehe tutorials, and started this one: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=Mac_OS_X

    Anyway XCode appears to be set up correctly, here is the code in its entirety. (GLUT and OpenGL frameworks have been added to the project)


    Code:
    #include <OpenGL/gl.h>
    #include <OpenGL/glu.h>
    #include <GLUT/glut.h>
    
    #define kWindowWidth	400
    #define kWindowHeight	300
    
    GLvoid InitGL(GLvoid);
    GLvoid DrawGLScene(GLvoid);
    GLvoid ReSizeGLScene(int Width, int Height);
    
    int main(int argc, char** argv)
    {
    	glutInit(&argc, argv);
    	glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    	glutInitWindowSize (kWindowWidth, kWindowHeight);
    	glutInitWindowPosition (100, 100);
    	glutCreateWindow (argv[0]);
    	
    	InitGL();
    	
    	glutDisplayFunc(DrawGLScene);
    	glutReshapeFunc(ReSizeGLScene);
    	
    	glutMainLoop();
    	
    	return 0;
    }
    
    Is this code supposed to work in this form? (The functions have prototypes but no definition which makes me wonder)

    Anyway the errors I get are:


    I'm not sure why the program can't find GLvoid. Its a valid data type, I checked for it. I just don't know enough about OpenGL to be able to tell if this is supposed to happen or if a window is to open. Anyone have any ideas?

    Basically I am just looking for bare minimum code needed to open a window that I can build the stuff I've been learning off of.
     
  2. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #2
    The code as presented is incomplete as you've surmised!

    Does the following compile:

    Code:
    /* =============================================================================
     * File -
     * -----------------------------------------------------------------------------
     */
    
    /* =============================================================================
     * -----------------------------------------------------------------------------
     */
    
    #include <GLUT/glut.h>
    #include <OpenGL/gl.h>
    #include <OpenGL/glu.h>
    
    
    /* =============================================================================
     * -----------------------------------------------------------------------------
     */
    
    #define kWindowWidth	400
    #define kWindowHeight	300
    
    
    /* =============================================================================
     * -----------------------------------------------------------------------------
     */
    
    void DrawGLScene()
    {}
    
    
    /* =============================================================================
     * -----------------------------------------------------------------------------
     */
    
    void ReSizeGLScene(int xWidth, int yHeight)
    {}
    
    
    /* =============================================================================
     * -----------------------------------------------------------------------------
     */
    
    void InitGL()
    {}
    
    
    /* =============================================================================
     * -----------------------------------------------------------------------------
     */
    
    int main(int argc, char** argv)
    {
    	glutInit(&argc, argv);
    	
    	glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    	
    	glutInitWindowSize (kWindowWidth, kWindowHeight);
    	glutInitWindowPosition (100, 100);
    	glutCreateWindow (argv[0]);
    	
    	InitGL();
    	
    	glutDisplayFunc(DrawGLScene);
    	glutReshapeFunc(ReSizeGLScene);
    	
    	glutMainLoop();
    	
    	return 0;
    }
    
     
  3. chrono1081, Dec 22, 2010
    Last edited: Dec 22, 2010

    chrono1081 thread starter macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #3
    Yes it does! Thank you so much again lloyddean :D I promise I won't be so needy once I get started learning OpenGL :p I've never programmed using a 3D API before. I'm used to working in game engines or with SDL.

    It seems like the NeHe tutorials are way out of date. I've been searching for the most basic code to open a window and use the knowledge I'm gaining from the OpenGL SuperBible to try and make something. The OpenGL Superbible is nice, but it moves pretty fast and offers no exercises to try.

    Thank you again for the help :D
     
  4. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #4
    I'd really recommend you check out this.

    I haven't tried compiling the downloadable Mac code available through the site so if it gives you trouble I have something that works and compiles on the current version of Xcode. But beware I have a habit of reformatting/reorganizing everything during my process of learning (it forces me to visit and understand the code) so it won't be 100% identical to his.

    Let me know!
     

Share This Page