Super bible examples

I’m reading the OpenGL super bible 4th edition. I’ve installed glut, glew, glee. I am using Microsoft visual C++ 2008. when I complie the following code I get the following errors:

#include "opengl.h"  // Custom open GL header

// Called to draw a scene

void RenderScene(void)
{
	// Clear the window with current clearing color
	glClear(GL_COLOR_BUFFER_BIT);

	// Flush drawing commands
	glFlush();
}

// Setup the rendering state

void SetupRC(void)
{
	glClearColor(0.0f, 0.0F, 1.0f, 1.0f);
}

// Main program entry point

void main(void)
int main(int argc, char* argv[])
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
	glutCreateWindow("Simple");
	glutDisplayFunc(RenderScene);

	SetupRC();

	glutMainLoop();

	return 0;
} 

With that code I get these following errors…

error C2144: syntax error : ‘int’ should be preceded by ‘;’
error C2731: ‘main’ : function cannot be overloaded
see declaration of ‘main’

Here is the header file just incase:

// Windows
#ifdef WIN32
#include <windows.h>
#include <glee.h>
#include <gl/gl.h>

#include <gl/glu.h>
#include <glut.h>
#endif

// Mac Os X
#ifdef _APPLE_
#include <Carbon/Carbon.h>
#include "glee.h"
#include <OpenGL/gl.h>

#include <OpenGL/glu.h>
#include <Glut/glut.h>
#endif 

I advice you to take a course in programming (or at least get a book on C) first, as you apparently have absolutely no idea what you are doing. To solve your “problem”, try removing that “void main(void)” line

I am in C++. Forgive me if I follow the example in the OpenGL book and didn’t know void main(void) wasn’t suppose to be there. You know everyone begins somewhere.

Thank you for your assistance. That was my mistake. I’ve never seen

void main(void)

used before. I will take that lesson with me in the future. Again Ty the program now works as intended.

Well, I am somehow irritated because, IMHO, any person (yes, even a C++ programmer :wink: ) who actually have some programming experience should be able to interpret a simple compiler output like that; I mean, I’ve never wrote a single line in C myself in my life.

But hey, anyone can have a bad day…

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.