Skip navigation

Success! I have **FINALLY** gotten point sprites working correctly. After much struggling, frustration, and a slew of websites that offered little to no help whatsoever here is my answer:

To use textures with point sprites you need to do the following:

  1. Find out the limits of your point sprite implementation by using the glGetFloatv( GL_ALIASED_POINT_SIZE_RANGE, <float[2]>) call. This will populate your <float[2]> with the upper and lower limits for your texture sizes (generally, but not always, 1 and 64).
  2. Load in your texture, enable it’s type (I believe that it MUST be GL_TEXTURE_2D), and bind the texture.
  3. Enable GL_POINT_SPRITE_ARB and set attenuation, fade thresholds, and pass in the min and max sizes.
  4. Set texture coordinate replacement parameters using glTexEnvi( GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE).
  5. Specify your point size, using glPointSize(<float>) and (optionally, mostly for particle systems) turn off the depth mask.
  6. Call glBegin( GL_POINTS ), specify 3d vertices, and then glEnd.

Here is the exact code I am using. The loadPoTTextureFromImageNamed: call returns a texture containing GLuint data and a GL_TEXTURE_2D type. Other than that, it’s all pretty self explanatory. Let me know if you find something out of whack. Hope it helps!


//Make space for particle limits and fill it from OGL call.

GLfloat sizes[2];


//Create the texture we want to use.

BBSTexture* t = [BBSTexture loadPoTTextureFromImageNamed:@”Particle1.png”];

//Enable our texture type (in this case, it must be GL_TEXTURE_2D)

glEnable([t type]);

//Bind the texture data.

glBindTexture([t type], [t data]);

//Enable blending and set for particles


glBlendFunc(GL_SRC_ALPHA, GL_ONE);

//Enable point sprites and set params for points.


float quadratic[] =  { 1.0f, 0.0f, 0.01f };

glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, quadratic );

glPointParameterfARB( GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60.0f );

//Tell it the max and min sizes we can use using our pre-filled array.

glPointParameterfARB( GL_POINT_SIZE_MIN_ARB, sizes[0] );

glPointParameterfARB( GL_POINT_SIZE_MAX_ARB, sizes[1] );

//Tell OGL to replace the coordinates upon drawing.


//Set the size of the points.


//Turn off depth masking so particles in front will not occlude particles behind them.


//Save the current transform.


//Begin drawing points.


//Iterate through our particles, setting the color and specifying their position.

for (Particle* p in particles)


glColor4f([[p color] magnitudeX], [[p color] magnitudeY] – [p lifespan], [[p color] magnitudeZ] – ([p lifespan] * 2), [[p color] magnitudeW]);

glVertex3f([p x], [p y], [p z]);


glEnd(); //Stop drawing points.

//Return to the previous matrix.



You are free to use this code in any manner you see fit.  Have fun with it!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: