Jump to content
  • Advertisement
Sign in to follow this  
wforl

'exit': identifier not found

This topic is 3923 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, : error C3861: 'exit': identifier not found I get this error when runnin the following piece of code,
GLvoid timerLoop(int value)
{	
	if (checkKeys() )		//check for user escape 
		exit(0);

	glutPostRedisplay();
	glutTimerFunc(1, timerLoop, 0);
}

Any ideas? Im following this code form a tutorial, and they dont explain the exit function, thankyou i've also included the full code here, should that help
#include <GL/glut.h>

#define red 1.0, 0.0, 0.0
#define green 0.0, 1.0, 0.0
#define blue 0.0, 0.0, 1.0
#define yellow 1.0, 1.0, 0.2
#define brown 0.4, 0.19, 0.0
#define vanilla 1.0, 0.95, 0.56

#define GLUT_KEY_ESCAPE 27


const GLsizei windowWidth = 500;
const GLsizei windowHeight = 500;

bool keys[255];


GLvoid establishProjMatrix(GLsizei width, GLsizei height)
{
	glViewport(0, 0, width, height);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective( 45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 200.0f);
}

GLvoid initGL(GLsizei width, GLsizei height)
{
	establishProjMatrix(width, height);	
	glShadeModel (GL_SMOOTH);
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
	glEnable(GL_PERSPECTIVE_CORRECTION_HINT);

}

GLvoid drawScene(GLvoid)
{
	glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glTranslatef( 0, 0, -5.0f);
	glRotatef(45.0, 1, 0, 0);
	glRotatef(45.0, 0, 1, 0);
	

	//drawcube
	glBegin(GL_QUADS);
		glColor3f(red);
		glVertex3f(	1.0f, 1.0f, -1.0f);
		glVertex3f(-1.0f, 1.0f, -1.0f);
		glVertex3f(-1.0f, 1.0f, 1.0f);
		glVertex3f(	1.0f, 1.0f, 1.0f);
		
		glColor3f(green);
		glVertex3f(	1.0f, -1.0f, -1.0f);
		glVertex3f(-1.0f, -1.0f, -1.0f);
		glVertex3f(-1.0f, -1.0f, 1.0f);
		glVertex3f(	1.0f, -1.0f, 1.0f);
		
		glColor3f(yellow);
		glVertex3f(	1.0f, 1.0f, 1.0f);
		glVertex3f(-1.0f, 1.0f, 1.0f);
		glVertex3f(-1.0f, -1.0f, 1.0f);
		glVertex3f(	1.0f, -1.0f, 1.0f);
		
		glColor3f(blue);
		glVertex3f(	1.0f, 1.0f, -1.0f);
		glVertex3f(-1.0f, 1.0f, -1.0f);
		glVertex3f(-1.0f, 1.0f, -1.0f);
		glVertex3f(	1.0f, 1.0f, -1.0f);
		
		glColor3f(brown);
		glVertex3f(-1.0f, 1.0f, 1.0f);
		glVertex3f(-1.0f, 1.0f, -1.0f);
		glVertex3f(-1.0f, -1.0f,-1.0f);
		glVertex3f(-1.0f, -1.0f, 1.0f);
		
		glColor3f(vanilla);
		glVertex3f(	1.0f, 1.0f, -1.0f);
		glVertex3f(1.0f, 1.0f, -1.0f);
		glVertex3f(1.0f, -1.0f, 1.0f);
		glVertex3f(	1.0f, -1.0f, 1.0f);

	glEnd();
		
	glFlush();
	glutSwapBuffers();
}

GLboolean checkKeys(GLvoid)
{
	if (keys[GLUT_KEY_ESCAPE])
		return true;
	else
		return false;
}

GLvoid timerLoop(int value)
{	
	if (checkKeys() )		//check for user escape 
		//exit(1);

	glutPostRedisplay();
	glutTimerFunc(1, timerLoop, 0);
}



//=============================================================================================

GLvoid keyboardCB( unsigned char key, int x, int y)
{
	keys[key] = true;
}


GLvoid keyboardUpCB( unsigned char key, int x, int y)
{
	keys[key] = false;
}

//============================================================================================

GLvoid keyboardSpecialCB( int key, int x, int y)
{
	keys[key] = true;
}


GLvoid keyboardSpecialUpCB( int key, int x, int y)
{
	keys[key] = false;
}

//================================================================================================

int main (int argc, char *argv[])
{	// initialize glut
	glutInit (&argc, argv);

	glutInitDisplayMode(GLUT_DOUBLE);

	int windowID = glutCreateWindow ("Opengl Cube");
	glutReshapeWindow(windowWidth, windowHeight);

	initGL(windowWidth, windowHeight);

	glutDisplayFunc (drawScene);


	glutKeyboardFunc(keyboardCB);			//functions for getting keyboard info (upkey and downkey)
	glutKeyboardUpFunc(keyboardUpCB);
	
	glutSpecialFunc(keyboardSpecialCB);			//functions for getting special key info (upkey and downkey)
	glutSpecialUpFunc(keyboardSpecialUpCB);
	
	glutTimerFunc(1, timerLoop, 0);

	glutMainLoop();

	//never gets here
	return 0;

}


Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!