OpenGL GLUTGameMode

For some reason i am not able to compile this source (written by me…) on my Ibook with xcode…

this is the source file :

#include <GLUT/glut.h>
#include <OpenGL/gl.h>
#include <stdio.h>

float angle = 0.0;

void changeSize(int w, int h)
{
if(h == 0)
h = 1;

float ratio = 1.0* w / h;

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0, 0, w, h);
gluPerspective(45,ratio,1,1000);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0,0.0,5.0,
0.0,0.0,-1.0,
0.0f,1.0f,0.0f);
}

void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(angle,0.0,1.0,0.0);
glBegin(GL_TRIANGLES);
glVertex3f(-0.5,-0.5,0.0);
glVertex3f(0.5,0.0,0.0);
glVertex3f(0.0,0.5,0.0);
glEnd();
glPopMatrix();
angle++;
glutSwapBuffers();
}

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
/glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow(“Lighthouse 3D - GLUT Tutorial”);
/
glutGameModeString(“800x600:32@60”);
if (glutGameModeGet(GLUT_GAME_MODE_POSSIBLE))
glutEnterGameMode();
else
{
printf("Video Mode not available
");
exit (1);
}
glutDisplayFunc(renderScene);
glutIdleFunc(renderScene);
glutReshapeFunc(changeSize);
glutMainLoop();
return (0);
}

what’s wrong with this source ? could anyone tell me how to export the warning and the building errors to post them here… i am not able to copy and past them here… thanks :slight_smile:

Compiling this from the command line shows one warning:
gcc test.c -framework OpenGL -framework GLUT
warning: incompatible implicit declaration of built-in function ‘exit’

Which is because you didn’t #include <stdlib.h>

In Xcode, you probably need to add the OpenGL and GLUT frameworks. See the Xcode GLUT Tutorial.

Compiles for me. No sweat. Same warning.