Sign in to follow this  
Mad_Kod3r

OpenGL Game Error

Recommended Posts

I made a lil opengl game but I have 12 lil annoying errors, I’m using MVC++ .NET. By the way how do I make the code be in a scoll box? Here is the code.............: <Code> ////////////////////////////// // // Gl.cpp // OpenGL and Glut Libraries // ///////////////////////////// #include <windows.h> #include <gl/glut.h> #include <gl/glu.h> #include <gl/gl.h> // Initial square position GLfloat x1 = 100.0f; GLfloat y1 = 100.0f; GLsizei rsize = 50; // Step size in x and y direction // (num of pixels to move each time) GLfloat xstep = 1.0f; GLfloat ystep = 1.0f; // Keep track of window changing width and height GLfloat windowWidth; GLfloat windowHeight; void RenderScene(void) { // Clears the window with the current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Set current drawing color ro red glColor3f(1.0f, 0.0f, 0.0f); // Draw a rectangle with current color glRectf(x1, y1 , x1+rsize, y1+rsize); // Flush drawing commands and swap glutSwapBuffers(); } // Called by GLUT library when idle (window is not being rezized or moved void TimerFunction(int value) { // Reverse direction when you reach left or right edge if(x1 > windowWidth -rsize || x1 < 0) xstep = -xstep; // Reverse direction when you reach the top or bottom side if(y1 > windowWidth - rsize || y1 < 0) ystep = -ystep; // Check bounds. this is in case the windoe is made small //and the rectangle is outside the clipping volume if (x1 > windowWidth - rsize) x1 = windowWidth - rsize; if (y1 > windowHeight - rsize) y1 = windowHeight - rsize; // Actually move the square x1 = xstep + 1; y1 = ystep + 1; // Redraw the scene with new coordinates glutPostRedisplay(); glutTimerFunc(33,TimerFunction, 1); } void SetupRC(void) { glClearColor(0.0f, 0.0f, 1.0f, 1.0f); } // Called by Glut library when the window has changed size void ChangeSize(GLsizei w, GLsizei h) { // Prevent a devide by zero if(h==0) h = 1; // Set vieport to window dimentions glViewport(0,0,w,h); // Reset coordinate system glMatrixMode(GL_PROJECTION); glLoadIdentity(); // Keep the square a suare; this time, //save calculated width and height for later use if (w <= h) { windowHeight = 250.0f*h/w; windowWidth = 250.0f; } else windowWidth = 250.0f*h/w; windowHeight = 250.0f; } // Set the clipping volume glOrtho(0.0f, windowWidth, 0.0f, windowHeight, 1.0f, -1.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } //Main Program Entry Point int main(int argc, char** argv) { glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutCreateWindow("Bounce"); glutDisplayFunc(RenderScene); glutReshapeFunc(ChangeSize); glutTimierFunc(33, TimerFunction, 1); SetupRC(); glutMainLoop(); } </Code> Here are the errorz.............................: I think I just have to do a few things but their is a lot of errors for each thing I did wrong, so don’t be intimidated by the number of errors. Compiling... Source2.cpp c:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio Projects\sx\Source2.cpp(113) : error C2501: 'glOrtho' : missing storage-class or type specifiers c:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio Projects\sx\Source2.cpp(113) : error C2365: 'glOrtho' : redefinition; previous definition was a 'function' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1341) : see declaration of 'glOrtho' c:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio Projects\sx\Source2.cpp(113) : error C2078: too many initializers c:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio Projects\sx\Source2.cpp(114) : error C2501: 'glMatrixMode' : missing storage-class or type specifiers c:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio Projects\sx\Source2.cpp(114) : error C2365: 'glMatrixMode' : redefinition; previous definition was a 'function' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1326) : see declaration of 'glMatrixMode' c:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio Projects\sx\Source2.cpp(115) : error C2556: 'int glLoadIdentity(void)' : overloaded function differs only by return type from 'void glLoadIdentity(void)' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1309) : see declaration of 'glLoadIdentity' c:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio Projects\sx\Source2.cpp(115) : error C2373: 'glLoadIdentity' : redefinition; different type modifiers c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\gl\GL.h(1309) : see declaration of 'glLoadIdentity' c:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio Projects\sx\Source2.cpp(116) : error C2059: syntax error : '}' c:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio Projects\sx\Source2.cpp(116) : error C2143: syntax error : missing ';' before '}' c:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio Projects\sx\Source2.cpp(116) : error C2059: syntax error : '}' c:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio Projects\sx\Source2.cpp(124) : error C2143: syntax error : missing ';' before '{' c:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio Projects\sx\Source2.cpp(124) : error C2447: '{' : missing function header (old-style formal list?)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this