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 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
#include <stdlib.h>
#include <glut.h>
#include <vector>
#include <iostream>
using namespace std;
void DrawPoints (std::vector Xvect, std::vector Yvect, std::vector Zvect)
{
glPointSize(5.0);
glColor3f(1.0,1.0,0.0);
glBegin(GL_POINTS);
for( i = 0 ; i < taille ; i++ )
glVertex3fv(Xvect [i], Yvect [i], Zvect [i]);
glEnd();
}
void Display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
////////glLoadIdentity();
DrawPoints();
drawAxesIcon();
glutSwapBuffers();
}
//int x, y;
void Reshape(int x, int y)
{
new_x = x;
new_y = y;
glViewport (0, 0, (GLsizei) new_x, (GLsizei) new_y); // Set the viewport
glMatrixMode (GL_PROJECTION); // Set the Matrix mode
glLoadIdentity ();
glOrtho(xMin, xMax, yMin,yMax,zMin, zMax);
glMatrixMode(GL_MODELVIEW);
}
int main (int argc, char **argv)
{
cout << "Reading file..." << endl;
RetrieveData(vX, vY, vZ);//récupérer tes points dans une fonction que tu lappelle RetrieveData
cout << "Viewing points..." << endl;
//Initialize GLUT
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(600,600);
//Create a window with rendering context and everything else we need
main_window = glutCreateWindow("Nuage de points");
glClearColor(0.0,0.0,0.0,0.0);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity ();
glRotated(90,-1,0,0);
glRotated(90,0,0,-1);
glRotated(45,0,1,0);
glRotated(45,0,0,-1);
glutDisplayFunc(Display);
glutReshapeFunc(Reshape);
glutMainLoop();
return 0;
} |