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
|
void remplir_tbleau1D () {
int i,j,k;
for(k=0; k<dim_z; k++)
{
for(i = 0; i < dim_y; i++)
{
for(j = 0; j < dim_x; j++)
{
if( matrice_pixel[i][j][k] != 0 )
{ // Matrice_pixel est la matrice qui contient les valeurs pixels
tableau1D.push_back( element(j,i,k) );
// element c'est une struct : x,y,z
}
}
}
}
}
Puis je l'affiche :
void Reshape(int width, int height)
{
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(180,float(width)/float(height),0.1,1000);
glMatrixMode(GL_MODELVIEW);
}
void Draw()
{
glClear( GL_COLOR_BUFFER_BIT );
//Efface le framebuffer et le depthbuffer
glLoadIdentity();
// La camera est a la position (0,0,0), le point de vue est vers (256,256,123).
gluLookAt(0,0,0,256,256,123,0,1,0);
glColor3f(255,255,255);
glBegin(GL_POINTS);
for ( unsigned i = 0 ; i< tableau1D.size() ; i++)
{
glVertex3f(tableau1D[i].x, tableau1D[i].y, tableau1D[i].z);
}
glEnd();
glutSwapBuffers();
glutPostRedisplay();
}
|