[PyOpenGL] How do I save runtime on drawing HUGE polylines (120 000vertices)?

F

F. GEIGER

Posted to comp.graphics.api.opengl and comp.lang.python.

Hi all,

I have to draw huge polylines.

The OpenGL Canvas' OnPaint method calls

Engine().drawShapes()


which is code of mine and looks like this:

def drawShapes(self):
print "# shapes =", len(self._shapes)
for S in self._shapes:
S.draw()
return


self._shapes isn't large, because I've stuffed all the vertices into an
array, which then is displayed by _ShapePolyline::draw():

def draw(self):
t = time.time()
glBegin(GL_LINE_STRIP)
apply(glColor3f, self._colorRGB)
for loc in self._locs:
x, y, z = loc[0]
glVertex3f(x, y, z)
# map(lambda x: glVertex3f(*x[0]), self._locs)
##### Doesn't perform much better
glEnd()
print "_ShapePolyline::draw(): Drawing of %d points took %s s" %
(self._numLocs, time.time() - t)


The above print statement shows, that 5 secs are consumed for about 120
000 (hundred-twenty-thousand) vertices. You guess, the whole GUI becomes
unusable.

I am forced to redraw the polyline, because of a glClear call in
OnPaint(). W/o such a call the canvas would fill until nothing is
recognized anymore when I rotate it with the mouse, i.e. it's filled
with the shape's colors.

Yes, it's Python code, but I guess that's not the problem here. It seems
to be a fundamental problem, I'm doing something fundamentally wrong.

So I wonder, do I really need to draw those 120000 vertices over and
over again? Would glArrays perform much better? Or is this a case for
Display Lists? Any other idea?

Many thanks in advance and kind regards
Franz GEIGER
 
M

Mike C. Fletcher

F. GEIGER wrote:
....
The above print statement shows, that 5 secs are consumed for about
120 000 (hundred-twenty-thousand) vertices. You guess, the whole GUI
becomes unusable.
....

So I wonder, do I really need to draw those 120000 vertices over and
over again?

Yes, that's the nature of OpenGL.
Would glArrays perform much better?

Certainly. The array-drawing functionality is always going to be faster
than writing loops in Python. You'll notice that OpenGLContext goes to
great lengths to push almost all of its rendering into array-based
operations.
Or is this a case for Display Lists? Any other idea?

Display lists should be fine too, though you'd still have a 5 second
delay waiting for them to compile.

HTH,
Mike

________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/
blog: http://zope.vex.net/~mcfletch/plumbing/
 
P

Philipp Klaus Krause

Would glArrays perform much better?
Yes.
Or is this a case for
Display Lists?
Might be even faster, depending on your driver.

Any other idea?
Use vertex buffer objects. These should be fastest.


Philipp Klaus Krause
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top