Hello all,
Hopefully I can reply in this thread and get some eyes! I am using point sprites after very excitedly finding out about them from this thread and others. I have run into a bit of a snag. Looking at ness's example above, it seems that you should be able to change the size of individual sprites within the same gl.glBegin(GL.GL_POINTS) --> gl.glEnd() sequence. Unfortunately, I could never get it to work, and ended up calling a new glBegin upon every iteration in my array of points, in order to get them to be different sizes.
Now, in the hopes of improving real time performance, I'd like to revisit this problem and see if anyone knows what's up. Firstly, if I could change the point size within the glBegin command, would this improve my performance? And secondly, if I can do this, what am I doing wrong?
When I put the gl.glPointSize command within the points iteration, it reduces all of the sprites' size to tiny specks. Here is the offending code:
Quote:void renderSprites(){
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glBindTexture(GL.GL_TEXTURE_2D,mapPointTexture1.getTextureID());
gl.glEnable(GL.GL_POINT_SPRITE);
gl.glTexEnvi(GL.GL_POINT_SPRITE, GL.GL_COORD_REPLACE, GL.GL_TRUE);
gl.glEnable(GL.GL_POINT_SMOOTH);
gl.glBegin(GL.GL_POINTS);
for(int a = 0; a < numA; a ++){
for(int b = 0; b < numB;b++){
gl.glPointSize(grid[a][b][3]);
gl.glPointParameteri(GL.GL_POINT_SIZE_MAX, 400);
gl.glVertex3f(grid[a][b][0],grid[a][b][1],grid[a][b][2]);
}
}
gl.glEnd();
gl.glDisable(GL.GL_POINT_SPRITE);
gl.glDisable(GL.GL_POINT_SMOOTH);
gl.glDisable(GL.GL_TEXTURE_2D);
}
and here is what I have had to do to make it work (including colorizing the sprites):
Quote: void renderSprites(){
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glBindTexture(GL.GL_TEXTURE_2D,mapPointTexture1.getTextureID());
gl.glEnable(GL.GL_POINT_SPRITE);
gl.glTexEnvi(GL.GL_POINT_SPRITE, GL.GL_COORD_REPLACE, GL.GL_TRUE);
gl.glEnable(GL.GL_POINT_SMOOTH);
for(int a = 0; a < numA; a ++){
for(int b = 0; b < numB;b++){
gl.glPointSize(grid[a][b][3]);
gl.glPointParameteri(GL.GL_POINT_SIZE_MAX, 400);
gl.glBegin(GL.GL_POINTS);
color _col = cm.getColFade1(gCol[0].getColPrime(a,b), gCol[0].getColSecon(a,b),grid[a][b][6]);
gl.glColor4f(red(_col), green(_col), blue(_col), alpha(_col));
gl.glVertex3f(grid[a][b][0],grid[a][b][1],grid[a][b][2]);
gl.glEnd();
}
}
gl.glDisable(GL.GL_POINT_SPRITE);
gl.glDisable(GL.GL_POINT_SMOOTH);
gl.glDisable(GL.GL_TEXTURE_2D);
}
Any help would be greatly appreciated, thank you!