I am doind a tutorial, here is my code:

#include "functions.h"
#include <glut.h>
#include <stdlib.h>


//this is the function with the error:
void HandleKeyPress ( unsigned char key, int x, int y )
{
	switch ( key )
	{
	case 27: // escape key
		exit ( 0 );
	}
}

void InitRendering ( void )
{
	glEnable ( GL_DEPTH_TEST );
}

void HandleResize ( int  w, int h )
{
	glViewport ( 0, 0, w, h );
	glMatrixMode ( GL_PROJECTION );
	glLoadIdentity ( );
	gluPerspective ( 45.0, (double)w / (double)h, 1.0, 200.0 );
}

void DrawScene ( void )
{
	glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	glMatrixMode ( GL_MODELVIEW );
	glLoadIdentity ( );
	glBegin ( GL_QUADS );

	// Trapedoid
	glVertex3f ( -0.7f, -1.5f, -5.0f );
    glVertex3f ( 0.7f, -1.5f, -5.0f );
    glVertex3f ( 0.4f, -0.5f, -5.0f );
    glVertex3f ( -0.4f, -0.5f, -5.0f );

	glEnd ( );

	glBegin ( GL_TRIANGLES );

	// Pentagon
	glVertex3f ( 0.5f, 0.5f, -5.0f );
    glVertex3f ( 1.5f, 0.5f, -5.0f );
    glVertex3f ( 0.5f, 1.0f, -5.0f );
    
    glVertex3f ( 0.5f, 1.0f, -5.0f );
    glVertex3f ( 1.5f, 0.5f, -5.0f );
    glVertex3f ( 1.5f, 1.0f, -5.0f );
    
    glVertex3f ( 0.5f, 1.0f, -5.0f );
    glVertex3f ( 1.5f, 1.0f, -5.0f );
    glVertex3f ( 1.0f, 1.5f, -5.0f );

	glVertex3f ( 0.5f, 0.5f, -5.0f );
    glVertex3f ( 1.5f, 0.5f, -5.0f );
    glVertex3f ( 0.5f, 1.0f, -5.0f );
    
    glVertex3f ( 0.5f, 1.0f, -5.0f );
    glVertex3f ( 1.5f, 0.5f, -5.0f );
    glVertex3f ( 1.5f, 1.0f, -5.0f );
    
    glVertex3f ( 0.5f, 1.0f, -5.0f );
    glVertex3f ( 1.5f, 1.0f, -5.0f );
    glVertex3f ( 1.0f, 1.5f, -5.0f );

	glEnd ( );
	
	glutSwapBuffers ( );
}

When i run it, the compiler tells me that exit() is not defined, but then i right click on it(im using VC++) and click "go to definition" it takes me there, and i have included the right file, i dont know whats happening.

any help would be greatly appreciated :)

i fixed it :)

To note, do not use exit(). In your main loop just break, and your destructors should clean anything.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.