views:

40

answers:

1

I am using point sprites to display a few ten thousand points, each with a different size. It works well, looks great and is quite fast. I'm using a VBO with the coordinates and the sizes in it (4 floats per point).

Here is my display code

glEnable(GL_POINT_SPRITE_OES);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, pointTexture);
glTexEnvi( GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_TRUE );
glEnableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, pointVertices);
glVertexPointer(3, GL_FLOAT, 4*sizeof(float), 0);
glEnableClientState(GL_POINT_SIZE_ARRAY_OES);
glPointSizePointerOES(GL_FLOAT,4*sizeof(float),(GLvoid*) (sizeof(GL_FLOAT)*3));
glDrawArrays(GL_POINTS, 0, pointNum);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisableClientState(GL_POINT_SIZE_ARRAY_OES);
glDisableClientState(GL_VERTEX_ARRAY);
glDisable(GL_TEXTURE_2D);
glDisable(GL_POINT_SPRITE_OES);

Now, I would also like to be able to zoom in, i.e. use glScalef. Is it possible to change the size of the points accordingly without updating the VBO? glPointSize doesn't have any effect, as I'm using GL_POINT_SIZE_ARRAY_OES.

+2  A: 

Yes, use glPointParameter with the GL_POINT_DISTANCE_ATTENUATION parameter.

http://www.khronos.org/opengles/sdk/1.1/docs/man/glPointParameter.xml

It's quite tricky to get right, though.

Calvin1602
Works great! Thanks!
hanno
hanno
Hey, that's really nice ! Where did you get this data from , btw ?
Calvin1602
Thanks ;-). I came up with an heuristic algorithm for the Milky Way stars that creates the data (arms, bulge, distribution of spectral types, etc) on the fly for a given number of points. That's because we don't have a very good idea about the global structure of the Mily way yet. But all main features should be kind of realistic. The data for the extrasolar planets is real. There are several sites that offer the data, for example my own one: http://exoplanet.hanno-rein.de/.
hanno