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
| #define FREEGLUT_STATIC
#include <GL/freeglut.h>
#include <list>
#include <cstdlib>
#include "Coordinate.hh"
static void resize(int width, int height)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity() ;
glOrtho(0.0f, (GLfloat) width, 0.0f,
(GLfloat) height, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity() ;
glViewport(0, 0, width, height);
}
static void display(void)
{
glutMainLoopEvent();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3d(1,0,0);
for (std::list<Coordinate *>::iterator it = Positions.begin(); it != Positions.end(); ++it)
{
// Coordinate est une classe contenant deux floats
//(x et y, accessibles publiquement, et deux trois bricoles).
glColor3f(0.60f,0.80f,0.90f);
glPushMatrix();
glTranslatef((**it).x, (**it).y, -20.0f);
glRotatef(100.0, 10.0, 0, 0);
glutSolidSphere(30, 18 , 36);
glPopMatrix();
}
glutSwapBuffers();
}
void init_window(const unsigned int &size_x, const unsigned int &size_y)
{
int init_glut = 0;
glutInit(&init_glut, NULL);
glutInitWindowSize(size_x, size_y);
glutInitWindowPosition(10,10);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("sphere");
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, (GLfloat) size_x, 0.0f,
(GLfloat) size_y, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glutReshapeFunc(resize);
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutSpecialFunc(SpecialKeys);
glutIdleFunc(idle);
} |
Partager