Error in run time...why?

hi guys, I use Xcode and I have a trouble with this program (written in c), that has to create a 3d duck that spins. The compile phase is ok, but this is the error that is returned
GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: Error (1002) creating CGSWindow
This is the source code:

#include <GLUT/glut.h>
#include <OPENGL/gl.h>

void duck(void);

void redraw(void)
{
static GLfloat angle = 0.0; //variabile che decide l’angolo di rotazione
glClearColor(0.0, 0.0, 0.0, 1.0); //settaggio colore sfondo
glClear( GL_COLOR_BUFFER_BIT);
glMatrixMode( GL_MODELVIEW);
glPushMatrix();
glRotatef(angle,0.0,1.0,0.0);
//glTranslatef(0.0,0.0,-0.3);
//glPushMatrix();
duck();
glPopMatrix();
glFlush();
glutSwapBuffers();
angle += 1;
}

void resize(int w,int h)
{
glMatrixMode ( GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0,(GLfloat) w/h, 0.0,200.0);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.5,0.4,0.0, 0.0,0.2,0.0, 0.0,0.0,0.4); // occhio target rotazione okkio
glViewport (0,0,w,h);

}

void duck (void)
{

	/*becco*/
glPushMatrix();
glColor3f(1.0,1.0,0.0);
glTranslatef(-0.18,0.14,0);
glRotatef(-90,0.0,1.0,0.0);
glScalef(1.9,1.0,1.0);
glutSolidCone(0.02,0.04,15,15);
glPopMatrix();
/*fine becco*/

glPushMatrix();
glColor3f(1.0,0,0);		//head
glTranslatef(-0.13,0.14,0.0);
glutSolidSphere(0.07,20,20);
glPopMatrix();			//end head

		/*body*/
glPushMatrix();		
glColor3f(1.0,1.0,1.0);
glScalef(1.6,1.0,1.0);
glutSolidSphere(0.1,20,20);
glPopMatrix();		
		/*end body*/

}

void main (int argc, char *argv[]){

glutInitWindowPosition(101,0);
glutInitWindowSize(500,500);
glutInitDisplayMode(GLUT_RGB |GLUT_DOUBLE);
glutCreateWindow("DUCK") ;
glutIdleFunc ( redraw );

// glutReshapeFunc( resize );
glutDisplayFunc( redraw );
glutMainLoop();

}

What’s the matter with this? Is the source code?? Tnx 4 the reply!!

in your main(), you MUST call
glutInit(&argc, argv);
prior to calling any other GLUT functions.

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