Re: [PyOpenGL-Users] Fastest way to draw lots of points
Brought to you by:
mcfletch
|
From: Mike C. F. <mcf...@vr...> - 2012-10-22 19:41:52
|
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
|