Hi,
I am using PointSprites for Particle Systems. Now, I am trying to put the texture to be drawn in a TextureAtlas. (So far, each PointSprite consumes its own Texture)
Here are my questions:
-
Is storing point sprites in individual Textures suboptimal from a performance perspective, i.e. should I worry about it at all? I want to eliminate glBindTexture commands when switching to another particle system.
-
I tried to set texture coordinates when having GL_POINT_SPRITE_OES activated. Below is the code I am using. The glEnableClientState(GL_TEXTURE_COORD_ARRAY);glTexCoordPointer… commands dont seem to have any effect. Is there a way to set the 2D texture coordinates (i.e. the origin in the texture atlas) for point sprites?
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture.name);
glEnable(GL_POINT_SPRITE_OES);
glTexEnvi( GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_TRUE );
glBindBuffer(GL_ARRAY_BUFFER, verticesID);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2,GL_FLOAT,sizeof(vertices[0]),0);
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4, GL_FLOAT, sizeof(vertices[0]),(GLvoid*) offsetof(ccPointSprite_T2F, colors) );
glEnableClientState(GL_POINT_SIZE_ARRAY_OES);
glPointSizePointerOES(GL_FLOAT,sizeof(vertices[0]),(GLvoid*) offsetof(ccPointSprite_T2F, size) );
**glEnableClientState(GL_TEXTURE_COORD_ARRAY);
*glTexCoordPointer(2, GL_FLOAT, sizeof(vertices[0]),(GLvoid) offsetof(ccPointSprite_T2F, texCoords) );
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glDrawArrays(GL_POINTS, 0, particleIdx);
Basically it does not matter if I have the lines marked with (**) included or not.
Does someone know more about drawing PointSprites from a TextureAtlas? Thanks!