Subject: CGAL users discussion list
List archive
- From: "alvaro cuno" <>
- To:
- Subject: Re: [cgal-discuss] Render a Polyhedron_3 using OpenGL vertex arrays
- Date: Thu, 8 Nov 2007 00:29:53 -0200
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ZDAXUFww2+f4T12aW75+WAsb4PM60FbXroiKK4G48f7NkmeiwVu2lvf41GSvo0xpVoeBsdDoTf2k4NIGqMNCCLguW5Q5KPPNvrKZfCbQg6aFEPUX50aF0QA2sQc3OAEDtggaK7sSCEQpiaH6PPpr4LSMhwiZXYLV4+T9fG3rBvw=
Hi Andreas,
At the moment, I am using this alternative:
- I have derived a SurfaceMesh class from
CGAL::HalfedgeDS_vector<Kernel, HDSItems>. As a member of this class I
have a linear array storing the vertex positions.
- For my Vertex structure I avoid to instance a position (without
Point). With this I avoid wasting memory.
- I send the array of positions to the OpenGL as the third parameter
of the function glVertexPointer.
- As you can see, I am using the HDS only for the connectivity information.
This option works very good. However, I don't like because is not
elegant. Requires some additional tricks. For example, It is necessary
to code I/O operators, etc.
For my case (the number (2)), I think there is a more elegant solution
using the Polyhedron_3 directly. But I have some doubts:
- Using the HalfedgeDS_vector it is possible to assert that the
structures will be in consecutive order in the memory?
- The coordinates of a Point_3 are in consecutive order?
- For computing the STRIDE value I have to use "sizeof(Vertex)" or
"sizeof(PolyhedronItems_3)" or ... ?
I think that for fast rendering of Polyhedron_3 using opengl we need only:
1- a pointer to the first position of vertex positions
2- these positions must be in consecutive order in the system memory, and
3- a STRIDE value
What do you think? Could you give more suggestions, please?
Alvaro Cuno
COPPE-UFRJ
PD: I have the same question of Laurent Rineau. For example, the
rendering of sharp features requires normals per vertex. Anyone know
to do this for OpenGL efficiently?
On 07/11/2007, Andreas Fabri
<>
wrote:
>
> 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
> --
> You are currently subscribed to cgal-discuss.
> To unsubscribe or access the archives, go to
> https://lists-sop.inria.fr/wws/info/cgal-discuss
>
- 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.