View Full Version : GL_LINE_LOOP ordering
08-19-2002, 02:29 AM
anyone know of a quicky way to reorder a list of triangles so that i can put the begin and end statements outside of the loop? the triangles are in no particular order at the moment and this causes a big mess when the line loop is allowed to run through the whole list. <code below>
having a list of length 3 is not very efficient. and i assume that using triangles would be even slower.
any help appreciated
p.s. this is stored in a display list.
t = m_TriangleList.GetNext(pos);
glVertex3d((t->Node1).x, (t->Node1).y, (t->Node1).z); glVertex3d((t->Node2).x, (t->Node2).y, (t->Node2).z);
glVertex3d((t->Node3).x, (t->Node3).y, (t->Node3).z);
[This message has been edited by cunny (edited 08-19-2002).]
08-22-2002, 08:16 AM
If there's no special reason for doing the the line loops yourself, I would use glPolygonMode(GL_FRONT_AND_BACK, GL_LINE), which should do almost the same.
"Almost" because you still draw triangles and some OpenGL state don't apply to non-faced primitives like lines.
(edit) Some performance notes:
- Check if you can use glVertex3dv().
- Even faster would be to use single precision floats in the node struct, and calling glVertex3fv.
[This message has been edited by Relic (edited 08-22-2002).]
Either way -- the line-loops or the GL_POLYGON_MODE hack -- has the same problem: edges that are shared between two triangles (almost a certainty) will be drawn twice. If you have a non-manifold surface and can have even more than two triangles per edge. To solve this problem, you need a boundary representation such as a half-edge or winged-edge data structure (czech it out on Flipcode, or Google-it).
If you have an entire mesh (that is, at least a dozen tris or so) with each triangle outlined in it's own Begin/End all contained in a single display list, I'll bet that you're not going to pay for the overhead of having all those "redundant" calls except when you GL_COMPILE them. Watch out for GL_COMPILE_AND_EXECUTE, it doesn't necessarily do what you think.
But really, you should solve the problem at a representational level, and everyone knows that you should be using indexed vertex arrays, anyway! http://www.opengl.org/discussion_boards/ubb/wink.gif
08-23-2002, 09:09 AM
the problem here is that i have 100,000 triangles, and nothing special by means of gfx card. i also have to draw the points and the filled triangles simultaneously. sounds wierd but i do!!
i know that having the begin/end within the loop is slow, but triangles for wireframe is also slower than line loops.. will try the the other vertex commands though.
any other suggestions?
08-27-2002, 12:24 AM
Maybe you misunderstood my first suggestion. It should move the glBegin(GL_TRIANGLES) out of the loop, of course.
The complete begin-end overhead for line loops is saved like this:
t = m_TriangleList.GetNext(pos);
glVertex3dv((GLdouble *) t->Node1);
glVertex3dv((GLdouble *) t->Node2);
glVertex3dv((GLdouble *) t->Node3);
Don't know if the (GLdouble *) cast will work for your struct.
If that's not fast enough you could convert the data into an edge representation only drawing each shared edge once with glBegin(GL_LINES) around the whole loop, like Won suggested.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.