Re: Fastest way to draw lots of points

"Mike C. Fletcher" <[email protected]> Mon, 22 Oct 2012 15:41:44 -0400
Newsgroups gmane.comp.python.opengl.user
Message-ID <[email protected]>
On 12-10-19 12:52 PM, Ryan Hope wrote:
> I am working on a pygame app that I recently converted to using opegl
> for the backend. The game has a parallax star field in the background
> so I have been looking for the most efficient way of drawing multiple
> points. My game updates the display every 33ms. Bellow are the draw
> points methods I have tried.
VBO approach on my machine fullscreen at 1920x1200 shows around 280 fps 
(no actually change with resolution change, btw).  I'm just rendering a 
random starfield of the same size as the Bright Star Catalog (9,100 
stars).  That looks good if you wander around near the center, but if 
you make it small enough to see changes you rapidly run out of stars.  
I'm guessing you want to update the stars so that you see more stars as 
you move out of the central star-field?  That is, as you move positions 
you want to add another "slice" of stars off to the side toward which 
you are walking? Unless you are travelling faster than light (or dealing 
with extremely long time-scales) you don't actually see any significant 
parallax with a star-field AFAIK.

VBO approach looks like this:

     from numpy import random
     numpy_pointset = random.rand( 9110, 3 )
     points = vbo.VBO( numpy_pointset )

then, during render:

     glVertexPointerf(points)
     glEnableClientState( GL_VERTEX_ARRAY )
     glDrawArrays( GL_POINTS, 0, len(points))
     glDisableClientState( GL_VERTEX_ARRAY )

I'm guessing that each update will wind up scatter-shot across your VBO 
so you'll likely want to re-upload the whole thing each time you change 
the star-field.

Code I'm using to test is here:

http://bazaar.launchpad.net/~mcfletch/openglcontext/trunk/view/head:/tests/starfield.py 
<http://bazaar.launchpad.net/%7Emcfletch/openglcontext/trunk/view/head:/tests/starfield.py>

Hope that helps,
Mike

-- 
________________________________________________
   Mike C. Fletcher
   Designer, VR Plumber, Coder
   http://www.vrplumber.com
   http://blog.vrplumber.com


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net