Hello again,
I’m currently trying to learn Point Sprites, and having a difficult time understanding them. I’m following a tutorial here. I have a good looking particle engine, but it doesn’t cover rotate. I’ve tried playing with glRotatef, but can’t get the results I want. Here is the render function as it is: (ParticleEmitter.m)
- (void)renderParticles {
glEnable(GL_TEXTURE_2D);
// Enable texturing and bind the texture to be used as the point sprite
if(texture && [sharedGameState currentlyBoundTexture] != [[texture texture] name]) {
glBindTexture(GL_TEXTURE_2D, [[texture texture] name]);
[sharedGameState setCurrentlyBoundTexture:[[texture texture] name]];
}
// Enable and configure blending
glEnable(GL_BLEND);
// Change the blend function used if blendAdditive has been set
if(blendAdditive) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
} else {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
// Enable and configure point sprites which we are going to use for our particles
glEnable(GL_POINT_SPRITE_OES);
glTexEnvi( GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_TRUE );
// Enable vertex arrays and bind to the vertices VBO which has been created
glEnableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, verticesID);
// Configure the vertex pointer which will use the vertices VBO
glVertexPointer(2, GL_FLOAT, sizeof(PointSprite), 0);
// Enable the point size array
glEnableClientState(GL_POINT_SIZE_ARRAY_OES);
// Configure the point size pointer which will use the currently bound VBO. PointSprite contains
// both the location of the point as well as its size, so the config below tells the point size
// pointer where in the currently bound VBO it can find the size for each point
glPointSizePointerOES(GL_FLOAT,sizeof(PointSprite),(GLvoid*) (sizeof(GL_FLOAT)*2));
// Enable the use of the color array
glEnableClientState(GL_COLOR_ARRAY);
// Bind to the color VBO which has been created
glBindBuffer(GL_ARRAY_BUFFER, colorsID);
// Configure the color pointer specifying how many values there are for each color and their type
glColorPointer(4,GL_FLOAT,0,0);
// Now that all of the VBOs have been used to configure the vertices, pointer size and color
// use glDrawArrays to draw the points
glDrawArrays(GL_POINTS, 0, particleIndex);
// Unbind the current VBO
glBindBuffer(GL_ARRAY_BUFFER, 0);
// Disable the client states which have been used incase the next draw function does
// not need or use them
glDisableClientState(GL_POINT_SPRITE_OES);
glDisableClientState(GL_POINT_SIZE_ARRAY_OES);
glDisableClientState(GL_COLOR_ARRAY);
glDisable(GL_TEXTURE_2D);
glDisable(GL_POINT_SPRITE_OES);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
Do you guys have any wisdom for me on how I could add rotation to each particle?
Thanks,
Craig