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 77 78 79 80 81 82
| #include <iostream>
// Glut
#include <GL/glut.h>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>
#include "Read_files.h"
using namespace std;
Point3D S; // une variable de type la structure Point3D,
float w, h;
void reshape (int nw, int nh)
{
w = nw;
h = nh;
}
//
///////////////////////////
void DrawPoints (void)
{
glPointSize(5.0);
//traçage des points que je recupere de mon fichier text: x,y,z
glBegin(GL_POINTS);
for( int i = 0 ; i < S.Numb_point3D ; i++ )
glVertex3f(S.x[i][0], S.y[i][1], S.z[i][2]); //affichage de x,y,z
glEnd();
}
void display (void)
{
glViewport (0, 0, w, h);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
DrawPoints ();
glutSwapBuffers ();
}
//////////////////////////
int main(int argc, char **argv)
{
S=Read_file("test.txt");
glutInitWindowSize (600, 400);
glutInitWindowPosition (400, 300);
glutInitDisplayMode (GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);
glutCreateWindow ("3D points");
glutDisplayFunc (display);
glutIdleFunc (display);
glutReshapeFunc (reshape);
glutSpecialFunc (Turn);
glClearColor (0.1, 0.2, 0.1, 1.0);
glEnable (GL_DEPTH_TEST);
glMatrixMode (GL_PROJECTION);
gluPerspective (40.0, 1.5, 1.0, 10.0);
glMatrixMode (GL_MODELVIEW);
glutMainLoop ();
return 0;
} |
Partager