1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#include <GL/glut.h>
/* variables pour les translations du vaisseau */
float tx = 0.;
float tx1 = 0.5;
/* taille de l'ecran */
float t = 10.;
static void reshape(int width, int height)
{
glViewport(0, 0, (GLint)width, (GLint)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-t, t, -t, t);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
static void display(void)
{
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glPushMatrix(); /* debut mouvements du vaisseau */
glTranslatef(0, -5, 0);
glTranslatef(tx, 0, 0);
glPushMatrix();
/* un cone */
glColor3f(1, 0, 0);
glutSolidCone(1.5, 1, 3, 1);
/* une sphere juste en dessous */
glColor3f(0, 0, 1);
glTranslatef(0, -1, 0);
glutWireSphere(0.3, 20, 20);
glPopMatrix();
glPopMatrix(); /* fin mouvements du vaisseau */
glFlush();
glutSwapBuffers();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
glutCreateWindow("TEST");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
} |
Partager