Subject: CGAL users discussion list
List archive
- From: Pierre Alliez <>
- To:
- Subject: Re: [cgal-discuss] On rendering of Polyhedron in CGAL 3.3
- Date: Sun, 26 Sep 2010 23:04:54 +0800
- Organization: INRIA Sophia Antipolis - Mediterranee
dear Kyewong,
if your mesh is static you should clearly use VBOs (vertex buffer objects) - this can be at least 10 times faster.
in a first preprocessing step you can create the VBOs - something like
glGenBuffers(...);
// for each VBO...
float *pData = new float[...];
// fill data here
// load data to the graphics card
glBindBuffer(GL_ARRAY_BUFFER, ...);
glBufferData(GL_ARRAY_BUFFER, size, pData, GL_STATIC_DRAW);
delete [] pData;
then in the rendering loop call something like
for(i=0;i<nb_vbos;i++)
{
::glEnableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, ... vbo ids);
glVertexPointer(3, GL_FLOAT, 0, 0); // adjust to triangle mesh
glDrawArrays(GL_POINTS, begin, count);
::glDisableClientState(GL_VERTEX_ARRAY);
}
we let you check a tutorial on VBOs.
Pierre
Pierre Alliez
INRIA Sophia Antipolis - Mediterranee
Project-team GEOMETRICA
http://www-sop.inria.fr/members/Pierre.Alliez/
Tel: +33 4 92 38 76 77
Fax: +33 4 97 15 53 95
Le 26/09/2010 17:42, kyewong a écrit :
Hi all
I've found a problem when rendering Polyhedron in opengl environment:
When the number of vertices of the mesh rendered is big, then it'll be very
slow when manipulating it (translate, rotation or scale) in the window,
wheras i've found that the manipulation in other software(eg. meshlab) for
the same mesh is much faster.
Has anyone else found the same problem?
I attached my code of rendering as follows, could anyone give me some
suggestions on speeding it up pls?
void render(Polyhedron * pmesh)
{
for ( Facet_iterator i = pmesh->facets_begin(); i != pmesh->facets_end();
i++)
{
glBegin(GL_POLYGON);
Halfedge_around_facet_circulator j = i->facet_begin();
do
{
glNormal3f(j->vertex()->normal().x(),
j->vertex()->normal().y(),
j->vertex()->normal().z());
glVertex3f(j->vertex()->point().x(),
j->vertex()->point().y(),
j->vertex()->point().z());
} while(++j != i->facet_begin());
glEnd();
}
}
- [cgal-discuss] On rendering of Polyhedron in CGAL 3.3, kyewong, 09/26/2010
- Re: [cgal-discuss] On rendering of Polyhedron in CGAL 3.3, Joachim Reichel, 09/26/2010
- Re: [cgal-discuss] On rendering of Polyhedron in CGAL 3.3, Laurent Rineau (GeometryFactory), 09/26/2010
- Re: [cgal-discuss] On rendering of Polyhedron in CGAL 3.3, Bo Zhou, 09/26/2010
- <Possible follow-up(s)>
- Re: [cgal-discuss] On rendering of Polyhedron in CGAL 3.3, Pierre Alliez, 09/26/2010
- Re: [cgal-discuss] On rendering of Polyhedron in CGAL 3.3, Kye Wong, 09/27/2010
Archive powered by MHonArc 2.6.16.