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
| void afficherRectangle(float posCentraleX, float posCentraleY, float tailleX, float tailleY)
{
float x1 = posCentraleX;
float y1 = posCentraleY;
float x2 = posCentraleX + tailleX;
float y2 = posCentraleY + tailleY;
glLineWidth (10);
glBegin(GL_LINE_LOOP);
glVertex2f(x1, y1);
glVertex2f(x2, y1);
glVertex2f(x2, y2);
glVertex2f(x1, y2);
glEnd();
}
void Affichage(void)
{
glViewport (0, 0, 1024, 768);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho(0, 1024, 768, 0, -1, 1);
glMatrixMode (GL_TEXTURE);
glLoadIdentity ();
glOrtho(0, 2.0f, 2.0f, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
afficherRectangle(0.f, 0.f, 100.f, 100.f); // ca marche pas
glutSwapBuffers();
glutPostRedisplay();
}
void Init()
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glEnable(GL_DEPTH_TEST | GL_TEXTURE_2D);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0,1.0,0.1,20.0);
glMatrixMode(GL_MODELVIEW);
} |
Partager