Thread: Errors with header files in OpenGL using VisualC++

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    4

    Question Errors with header files in OpenGL using VisualC++

    Hi, my name is Danny and I am very new to Visual C++ and OpenGL. I began using NeHe's tutorials and everything was going great. Later, I wanted to try some clipping so I transfered this code from OpenGL Programming Guide (the red book, pg 107):

    Code:
    #include <windows.h>
    #include <gl\gl.h>
    #include <gl\glu.h>
    #include "aux.h"
    
    void display(void)
    {
    GLdouble eqn[4] = {0.0,1.0,0.0,0.0};
    GLdouble eqn2[4] = {1.0,0.0,0.0,0.0};
    
    glClear(GL_COLOR_BUFFER_BIT);
    
    glColor3f(1.0,1.0,1.0);
    glPushMatrix();
    glTranslatef(0.0,0.0,-0.5);
    
    glClipPlane(GL_CLIP_PLANE0, eqn);
    glEnable(GL_CLIP_PLANE0);
    glClipPlane(GL_CLIP_PLANE1, eqn2);
    glEnable(GL_CLIP_PLANE1);
    
    glRotate(9.0,1.0,0.0,0.0);
    auxWireSphere(1.0);
    glPopMatrix();
    glFlush();
    
    }
    
    
    void myinit(void);
    {
    glShadeModel(GL_FLAT);
    }
    
    
    void myReshape(GLsizei w, GLsizei h)
    {
    glViewport(0,0,w,h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60.0, (GLfloat) w /(GLfloat) h, 1.0,20.0);
    glMatrixMode(GL_MODELVIEW);
    
    }
    
    int main(int argc, char** argv);
    {
    auxInitDisplayMode(AUX_SINGLE | AUX_RGBA);
    auxInitPosition(0,0,500,500);
    auxInitWondow(argv[0]);
    myinit();
    auxReshapeFunc(myReshape);
    auxMainLoop(display)
    
    }
    this is the first time I encountered these errors. This is just a few of the errors I recieved:

    c:\program files\microsoft visual studio\vc98\include\gl\glu.h(384) : error C2165: 'left-side modifier' : cannot modify pointers to data
    c:\program files\microsoft visual studio\vc98\include\gl\glu.h(384) : error C2071: 'GLUnurbsErrorProc' : illegal storage class
    c:\program files\microsoft visual studio\vc98\include\gl\glu.h(561) : error C2061: syntax error : identifier 'GLenum'
    c:\program files\microsoft visual studio\vc98\include\gl\glut.h(535) : error C2146: syntax error : missing ')' before identifier 'layer'
    c:\program files\microsoft visual studio\vc98\include\gl\glut.h(535) : warning C4229: anachronism used : modifiers on data are ignored
    c:\program files\microsoft visual studio\vc98\include\gl\glut.h(535) : error C2182: 'glutUseLayer' : illegal use of type 'void'
    c:\program files\microsoft visual studio\vc98\include\gl\glut.h(535) : error C2059: syntax error : ')'
    c:\program files\microsoft visual studio\vc98\include\gl\glut.h(600) : error C2061: syntax error : identifier 'GLfloat'
    c:\program files\microsoft visual studio\vc98\include\gl\glut.h(601) : error C2143: syntax error : missing ';' before '__stdcall'
    c:\program files\microsoft visual studio\vc98\include\gl\glut.h(605) : error C2146: syntax error : missing ')' before identifier 'type'


    After trying to resolve these problems and making sure I linked the appropriate libraries(OpenGL32.lib GLu32.lib GLaux.lib), I placed the above code in a newly downloaded NeHe tutorial and I got the same errors. Now everything I compile in Visual C++ is incurring the same errors, whether they are simple programs I wrote or tutorials I downloaded!!

    I would greatly appreciate some assistance regarding this issue, thanks and have a great day!!

    Danny

  2. #2
    Yah. Morgul's Avatar
    Join Date
    Feb 2005
    Posts
    109
    Have you been able to successfully compile any programs in OpenGL? If not, are you sure that it is correctly configured for MSVC++? Did you put the correct include and library directories in so it knows where to look for them?
    Sic vis pacum para bellum. If you want peace, prepare for war.

  3. #3
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    ... continued from http://cboard.cprogramming.com/showthread.php?t=55663.

    Code:
    int main(int argc, char** argv);
    {
    auxInitDisplayMode(AUX_SINGLE | AUX_RGBA);
    auxInitPosition(0,0,500,500);
    That semicolon is causing some problems.
    Code:
    void myinit(void);
    {
    glShadeModel(GL_FLAT);
    }
    Same here.

    You're missing a semicolon here:
    Code:
    int main(int argc, char** argv);
    {
    auxInitDisplayMode(AUX_SINGLE | AUX_RGBA);
    auxInitPosition(0,0,500,500);
    auxInitWondow(argv[0]);
    myinit();
    auxReshapeFunc(myReshape);
    auxMainLoop(display);
    
    }
    And there should probably be a return 0 at the end of main().
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #4
    Registered User
    Join Date
    Jun 2006
    Posts
    4

    Question

    Thanks alot!!! I did make a few mistakes coping the code unfortunately those errors didn't change anything. I still have the same amount of errors!!

    I was told to put in the glut header file, but that doesn't change anything. this is the modified code. I added return O; then return TRUE, still no change.

    To Morgul: Initially all the tutorials I downloaded and the programs I wrote were compiling. After I encountered this errors, all the other projects had the same errors! (However, I didn't try to compile a project without graphics). I included the correct libraries and linked them to the project. Thanks!

    Code:
    #include		<windows.h>
    #include		<gl\gl.h>				// Header file for the OpenGL32 library
    #include		<gl\glu.h>				// Header file for the GLu32 library
    #include		"aux.h"					// Header file for the auxillary library
    
    void display(void)
    {
    	GLdouble eqn[4] = {0.0,1.0,0.0,0.0};	// this arguement points to the 4 coefficients of the plane equation	
    	GLdouble eqn2[4] = {1.0,0.0,0.0,0.0};	// same as above
    
    	glClear(GL_COLOR_BUFFER_BIT);			// clears color buffer
    
    	glColor3f(1.0,1.0,1.0);					// sets color to white
    	glPushMatrix();							// this pushes the current matrix stack down by one, duplicating the current matrix
    	glTranslatef(0.0,0.0,-5.0);				// this moves the current view matrix 5 units deeper into the screen
    
    	glClipPlane(GL_CLIP_PLANE0, eqn);		// indicates the clipping plane
    	glEnable(GL_CLIP_PLANE0);				// enables clip plane0
    	glClipPlane(GL_CLIP_PLANE1, eqn2);		// indicates the clipping plane
    	glEnable(GL_CLIP_PLANE1);				// enables clip plane1
    
    	glRotate(90.0,1.0,0.0,0.0);				// rotates object 90 degrees on the X axis (ie it moves up and down away from the viewer)
    	auxWireSphere(1.0);						// draws a wire sphere with a diameter of 1?
    	glPopMatrix();							// pops the current matrix stack, replace the current matrix with the one below it on the stack
    	glFlush();								// empties all the buffers causing all issued commands to execute in finite time (as quickly as they're accepted by the actual rendering engine)
    
    }
    // closes the display(void) function
    
    void myinit(void)
    {
    	glShadeModel(GL_FLAT);					// this selects which type of shading is used (Flat shading selects the computed color of one vertex and assigns it to the entire object)
    
    }
    
    
    void myReshape(GLsizei w, GLsizei h)
    {
    	glViewport(0,0,w,h);										// specifies the affine transformation of x and y(0,0) from normalized device co ords to windows co ords
    	glMatrixMode(GL_PROJECTION);								// specifies which matrix is the current matrix ie the Projection matrix stack
    	glLoadIdentity();											// replaces the current matrix with the identity matrix
    	gluPerspective(60.0, (GLfloat) w /(GLfloat) h, 1.0,20.0);	// sets up a perspective projection  matrix
    	glMatrixMode(GL_MODELVIEW);									// specifies which matrix is the current matrix ie the Modelview matrix stack
    
    }
    
    int main(int argc, char** argv)								
    {
    	auxInitDisplayMode(AUX_SINGLE | AUX_RGBA);					// tells auxInitWindow to create a RGBA and a single buffered window
    	auxInitPosition(0,0,500,500);								// tells auxInitWindow where to position a window on the screen 
    	auxInitWondow(argv[0]);										// opens a window with the characteristics specificied by the two previous commands, the string argv appears in the title window)
    	myinit();													// calls the myinit() function above
    	auxReshapeFunc(myReshape);									// specifies the function that is called when the window is resized( in this case the myReshape() function), moved or exposed. the arguement is a pointer to a function that expects 2 parameters
    	auxMainLoop(display);										// specifies the function that's called when the window needs to be updated. This function should redraw the objects on the screen
            return TRUE;
    }
    thanks for all the help!!! If you know of any websites or books that will give me assistance with this project I would greatly appreciate it. Have a great day!!!!

    Danny

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Opengl files missing...
    By Jake.c in forum Game Programming
    Replies: 6
    Last Post: 06-16-2009, 09:08 AM
  2. Confusion on header and source files
    By dnguyen1022 in forum C++ Programming
    Replies: 4
    Last Post: 01-17-2009, 03:42 AM
  3. C Header Files
    By devarishi in forum C Programming
    Replies: 8
    Last Post: 12-10-2008, 04:53 PM
  4. header and source files
    By gtriarhos in forum C Programming
    Replies: 3
    Last Post: 10-02-2005, 03:16 AM
  5. Using c++ standards
    By subdene in forum C++ Programming
    Replies: 4
    Last Post: 06-06-2002, 09:15 AM