PDA

View Full Version : OpenGL GLUTGameMode



Nube78
01-02-2010, 05:38 PM
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(&amp;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\n");
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 :-)

arekkusu
01-06-2010, 09:02 AM
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 (http://blog.onesadcookie.com/2007/12/xcodeglut-tutorial.html).

Ragnemalm
02-16-2010, 02:15 PM
Compiles for me. No sweat. Same warning.