Cleaned the code.

This commit is contained in:
Maxime Gimeno 2015-02-20 12:31:55 +01:00 committed by Laurent Rineau
parent 39811801e4
commit a5a5c74464
1 changed files with 34 additions and 42 deletions

View File

@ -526,35 +526,12 @@ Scene_polygon_soup_item::toolTip() const
void void
Scene_polygon_soup_item::draw() const { Scene_polygon_soup_item::draw() const {
// tells the GPU to use the program just created
glUseProgram(rendering_program);
uniform_attrib();
//draw the polygons
// the third argument is the number of vec4 that will be entered
glDrawArrays(GL_TRIANGLES, 0, positions_poly.size()/4);
//Tells OpenGL not to use the program anymore
glUseProgram(0);
}
void
Scene_polygon_soup_item::draw(Viewer_interface* viewer) const {
/* typedef Polygon_soup::Polygons::const_iterator Polygons_iterator;
typedef Polygon_soup::Polygons::size_type size_type;
*/
//Remplit la matrice MVP
GLdouble d_mat[16];
viewer->camera()->getModelViewProjectionMatrix(d_mat);
//Convert the GLdoubles matrix in GLfloats
for (int i=0; i<16; ++i)
mvp_mat[i] = GLfloat(d_mat[i]);
viewer->camera()->getModelViewMatrix(d_mat);
for (int i=0; i<16; ++i)
mv_mat[i] = GLfloat(d_mat[i]);
//fills the arraw of colors with the current color
glGetFloatv(GL_CURRENT_COLOR, colors ); glGetFloatv(GL_CURRENT_COLOR, colors );
//Gets lighting info :
//position //position
glGetLightfv(GL_LIGHT0, GL_POSITION, light.position); glGetLightfv(GL_LIGHT0, GL_POSITION, light.position);
@ -574,6 +551,33 @@ Scene_polygon_soup_item::draw(Viewer_interface* viewer) const {
light.diffuse[1]*=colors[1]; light.diffuse[1]*=colors[1];
light.diffuse[2]*=colors[2]; light.diffuse[2]*=colors[2];
// tells the GPU to use the program just created
glUseProgram(rendering_program);
uniform_attrib();
//draw the polygons
// the third argument is the number of vec4 that will be entered
glDrawArrays(GL_TRIANGLES, 0, positions_poly.size()/4);
//Tells OpenGL not to use the program anymore
glUseProgram(0);
}
void
Scene_polygon_soup_item::draw(Viewer_interface* viewer) const {
//fills the MVP and MV matrices.
GLdouble d_mat[16];
viewer->camera()->getModelViewProjectionMatrix(d_mat);
//Convert the GLdoubles matrix in GLfloats
for (int i=0; i<16; ++i)
mvp_mat[i] = GLfloat(d_mat[i]);
viewer->camera()->getModelViewMatrix(d_mat);
for (int i=0; i<16; ++i)
mv_mat[i] = GLfloat(d_mat[i]);
draw(); draw();
} }
@ -582,33 +586,21 @@ Scene_polygon_soup_item::draw_points() const {
if(soup == 0) return; if(soup == 0) return;
//::glBegin(GL_POINTS);
/* for(Polygon_soup::Points::const_iterator pit = soup->points.begin(),
end = soup->points.end();
pit != end; ++pit)
{
::glVertex3d(pit->x(), pit->y(), pit->z());
positions_points.push_back(pit->x());
positions_points.push_back(pit->y());
positions_points.push_back(pit->z());
}
//::glEnd();*/
// tells the GPU to use the program just created // tells the GPU to use the program just created
glUseProgram(rendering_program); glUseProgram(rendering_program);
uniform_attrib(); uniform_attrib();
//draw the polygons //draw the points
// the third argument is the number of vec4 that will be entered glDrawArrays(GL_POINTS, 0, positions_poly.size());
glDrawArrays(GL_POINTS, 0, positions_poly.size()/4);
//Tells OpenGL not to use the program anymore //Tells OpenGL not to use the program anymore
glUseProgram(0); glUseProgram(0);
} }
void void
Scene_polygon_soup_item::draw_points(Viewer_interface* viewer) const { Scene_polygon_soup_item::draw_points(Viewer_interface* viewer) const {
//Remplit la matrice MVP //fills the MVP Matrix
GLdouble d_mat[16]; GLdouble d_mat[16];
viewer->camera()->getModelViewProjectionMatrix(d_mat); viewer->camera()->getModelViewProjectionMatrix(d_mat);
//Convert the GLdoubles matrix in GLfloats //Convert the GLdoubles matrix in GLfloats