On rendering of Polyhedron in CGAL 3.3

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

On rendering of Polyhedron in CGAL 3.3

kyewong
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();
 }
}
Reply | Threaded
Open this post in threaded view
|

Re: On rendering of Polyhedron in CGAL 3.3

Joachim Reichel
Hi,

> 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

what is "big"? 10000? 100000? 1 million?

> 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();
>  }
> }

it might help if you bind repeated expressions like j->vertex()->normal() to a
const reference.

But I guess you get the most benefit by using OpenGL display lists and/or
vertex arrays. See http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=12
and http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=45 for examples.

Joachim


--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss

Reply | Threaded
Open this post in threaded view
|

Re: On rendering of Polyhedron in CGAL 3.3

Laurent Rineau (GeometryFactory)
In reply to this post by kyewong
Le dimanche 26 septembre 2010 11:42:00, 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.

You probably did not use OpenGL display lists. You need to, if you want good
performances.

--
Laurent Rineau, PhD
Release Manager of the CGAL Project       http://www.cgal.org/
R&D Engineer at GeometryFactory           http://www.geometryfactory.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss

Reply | Threaded
Open this post in threaded view
|

Re: On rendering of Polyhedron in CGAL 3.3

Bo Schwarzstein
 Or take an example about OpenGL VBO or glEnableClientState and some
similar methods which is used to render massive primitives at once.
glBegin()/glEnd() are immediate mode APIs which would change GPU
pipeline too often, make everything less efficient.

On 2010/9/26 18:43, Laurent Rineau (GeometryFactory) wrote:

> Le dimanche 26 septembre 2010 11:42:00, 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.
> You probably did not use OpenGL display lists. You need to, if you want good
> performances.
>
--
BR,
BZ


--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss


Bo_Schwarzstein.vcf (444 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: On rendering of Polyhedron in CGAL 3.3

Pierre Alliez-2
In reply to this post by kyewong
  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();
>   }
> }

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss

Reply | Threaded
Open this post in threaded view
|

Re: On rendering of Polyhedron in CGAL 3.3

kyewong
Hi all,

Thank you very much for your kindly instructions.
In fact, I can update my question like this:

How to render a Polyhedron_3 using opengl vertex arrays

I google it and have found the following existing topics:

https://lists-sop.inria.fr/sympa/arc/cgal-discuss/2007-11/msg00028.html

and Alvaro has uploaded his solution:

https://lists-sop.inria.fr/sympa/arc/cgal-discuss/2007-12/msg00053.html

I'm wondering if there are any more convenient methods for solving this problem, if both the geometry and topology of the mesh are not static?

Thanks very much!

Regards,
Wang Kai

On Sun, Sep 26, 2010 at 11:04 PM, Pierre Alliez <[hidden email]> wrote:
 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();
 }
}

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss




--
Kye Wong
Reply | Threaded
Open this post in threaded view
|

Re: On rendering of Polyhedron in CGAL 3.3

sean
I have met an identical problem as you. I can't open the website you refferd, namely
"I google it and have found the following existing topics:

https://lists-sop.inria.fr/sympa/arc/cgal-discuss/2007-11/msg00028.html

and Alvaro has uploaded his solution:

https://lists-sop.inria.fr/sympa/arc/cgal-discuss/2007-12/msg00053.html"
What was the solution and how did you solve it finally?
Thank you!
Reply | Threaded
Open this post in threaded view
|

Re: On rendering of Polyhedron in CGAL 3.3

kyewong
Hi sean, I solved it by using the opengl list functions, including
glgenlist... u can easily find how to use it on google

On 7/24/14, sean [via cgal-discuss]
<[hidden email]> wrote:

>
>
> I have met an identical problem as you. I can't open the website you
> refferd,
> namely
> "I google it and have found the following existing topics:
>
> https://lists-sop.inria.fr/sympa/arc/cgal-discuss/2007-11/msg00028.html
>
> and Alvaro has uploaded his solution:
>
> https://lists-sop.inria.fr/sympa/arc/cgal-discuss/2007-12/msg00053.html"
> What was the solution and how did you solve it finally?
> Thank you!
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://cgal-discuss.949826.n4.nabble.com/On-rendering-of-Polyhedron-in-CGAL-3-3-tp2714204p4659601.html
>
> To unsubscribe from On rendering of Polyhedron in CGAL 3.3, visit
>
Kai WANG
Reply | Threaded
Open this post in threaded view
|

Re: Re: On rendering of Polyhedron in CGAL 3.3

sean
Hello, Wang Kai, if you are Chinese too.
Thank you for helping.
I will make a try. And if I meet difficulties, I want to discuss them with you if you don't mind.
Sean
 
2014-07-24
 
Date: 2014-07-24 21:33
Subject: Re: On rendering of Polyhedron in CGAL 3.3
Hi sean, I solved it by using the opengl list functions, including
glgenlist... u can easily find how to use it on google

On 7/24/14, sean [via cgal-discuss]
<[hidden email]> wrote:

>
>
> I have met an identical problem as you. I can't open the website you
> refferd,
> namely
> "I google it and have found the following existing topics:
>
> https://lists-sop.inria.fr/sympa/arc/cgal-discuss/2007-11/msg00028.html
>
> and Alvaro has uploaded his solution:
>
> https://lists-sop.inria.fr/sympa/arc/cgal-discuss/2007-12/msg00053.html"
> What was the solution and how did you solve it finally?
> Thank you!
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://cgal-discuss.949826.n4.nabble.com/On-rendering-of-Polyhedron-in-CGAL-3-3-tp2714204p4659601.html
>
> To unsubscribe from On rendering of Polyhedron in CGAL 3.3, visit
>
Kai WANG



To unsubscribe from On rendering of Polyhedron in CGAL 3.3, click here.
NAML