OVH Cloud OVH Cloud

Problème de programmation en OpenGL C++

1 réponse
Avatar
eddywards
Bonjour =E0 tous,
voici un extrait de l'un de mes programmes en C++ utilisant GLUT :


#include<opengl/gl.h>
#include<glut/glut.h>
#define kWindowWidth 640
#define kWindowHeight 480

void DrawGLScene();
void clavfunc(unsigned char key,int x, int y);
float rtri=3D0.0;

int main(int arg, char **argc)
{
glutInit(&arg, argc);
glutInitWindowSize (kWindowWidth, kWindowHeight);
glutInitWindowPosition (192,144);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("");

glutDisplayFunc(DrawGLScene);

glMatrixMode(GL_PROJECTION);
gluPerspective(45, 1.3, 0.1, 200.0);
glMatrixMode(GL_MODELVIEW);

glutMainLoop();
glutKeyboardFunc(clavfunc);

return 0;
}

void DrawGLScene(void)
{

//glutFullScreen();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glTranslatef(0.0f, 0.0f, -5.0f);
glRotatef(rtri,1.0f,1.0f,1.0f);

glBegin(GL_TRIANGLES);

glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(-1.0f, -1.0f, 0.0f);

glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);

glColor3f(0.0f, 0.0f, 1.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);

glEnd();

rtri+=3D2.0f;
glutSwapBuffers(); // Call this to swap buffers
(swap frames).
glutPostRedisplay(); // This tell glut to redraw the
window.
}

void clavfunc(unsigned char key,int x, int y)
{
if(key=3D=3D27) {
exit(0);
}
}



C'est un programme tout b=EAte a part que xcode 2.2 ne comprend pas le
'exit(0);'

Il me sort une erreur : error: 'exit' was not declared in this scope

Si l'un de vous a une solution, je suis preneur...

Merci d'avance


Eddywards

1 réponse

Avatar
Joe Cool
C'est un programme tout bête a part que xcode 2.2 ne comprend pas le
'exit(0);'


#include <stdlib.h>

--
Joe Cool