Subject: CGAL users discussion list
List archive
- From: Andreas Fabri <>
- To:
- Subject: Re: [cgal-discuss] Render a Polyhedron_3 using OpenGL vertex arrays
- Date: Wed, 07 Nov 2007 09:11:58 +0100
Hello,
I see two options. By default the polyhedron uses a halfedge data structure
where the vertices, halfedges, and faces are stored in a list. For a list
of vertices a stride will not do it, as the list elements can be anywhere
in memory. But you could have your own Vertex class, and an array for your
points coordinates, and you let your vertex have a pointer in the array
instead of directly storing the point.
The second option is to use the fact that the halfedge data structure
is a template parameter of the Polyhedron, and there is a class
HalfedgeDS_vector.
It stores the vertices, halfedges, and faces in std::vectors. The limitation
is that you cannot delete vertices, but you should be able to compute the
stride
even if this is not offered by the API. For more information on
HalfedgeDS_vector:
http://www.cgal.org/Manual/3.3/doc_html/cgal_manual/Polyhedron/Chapter_main.html#Subsection_12.3.5
I would be glad to get your feedback once it works.
andreas
wrote:
Dear all,
I would like to render a Polyhedron_3 mesh with +100K vertices in interactive
FPS using OpenGL.
(1) If the mesh is static, there is not problem:
- I can use a display list, build vertex arrays or use VBO (looping on the
Vertex_iterator, Facet_iterator). This is not my case.
(2) If the mesh geometry is dynamic (but the connectivity is static)
- It is possible to build a vertex array or VBO each time the geometry is
modified. However, I wouldn't like to loop on the iterators to build the new
opengl vertex array every time because is not efficient. I would like to pass
the pointer to the mesh geometry directly to OpenGL. I would like something
similar to (mesh is a pointer to a Polyhedron_3 object):
###############################
typedef Polyhedron_3::Point_iterator Point_iterator;
Point_iterator pi = mesh->points_begin();
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(SOMESTRIDEVALUE), &(*pi)[0]);
glDrawElements(GL_TRIANGLES, 3*mesh->nfaces(), GL_UNSIGNED_INT, &faces[0]);
###############################
..... It is possible to do this? how to determine the STRIDE value?
(3) If the geometry and the connectivity is dynamic
- This is not my case
Thanks in advance,
Alvaro Cuno
COPPE-UFRJ
- Render a Polyhedron_3 using OpenGL vertex arrays, alvaroecp, 11/07/2007
- Re: [cgal-discuss] Render a Polyhedron_3 using OpenGL vertex arrays, Andreas Fabri, 11/07/2007
- Re: [cgal-discuss] Render a Polyhedron_3 using OpenGL vertex arrays, Laurent Rineau, 11/07/2007
- Re: [cgal-discuss] Render a Polyhedron_3 using OpenGL vertex arrays, alvaro cuno, 11/08/2007
- Re: [cgal-discuss] Render a Polyhedron_3 using OpenGL vertex arrays, Andreas Fabri, 11/08/2007
- Re: [cgal-discuss] Render a Polyhedron_3 using OpenGL vertex arrays, Andreas Fabri, 11/07/2007
Archive powered by MHonArc 2.6.16.