I'm trying to draw circles by using a Vertex Buffer Object to draw points with GL_POINT_SMOOTH enabled in OpenGL ES 2.0 on iPhone.
I've used the following ES 1.0 rendering code to draw circles successfully on iPhone 4:
glVertexPointer(2, GL_FLOAT, 0, circleVertices);
glEnableClientState(GL_VERTEX_ARRAY);
glEnable(GL_POINT_SMOOTH);
glPointSize(radius*2);
glDrawArrays(GL_POINTS, 0, 1);
I'm now trying to achieve the same effect using a set-up VBO followed by this ES 2.0 rendering code:
glEnable(GL_BLEND);
glEnable(GL_POINT_SPRITE_OES);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_POINT_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glDrawElements(GL_POINTS, numPoints, GL_UNSIGNED_SHORT, BUFFER_OFFSET(0));
However the output vertices are very clearly square, not circular.
I've tried reducing the 'glEnable' and related calls in the above to emulate the first, working version but no visible change in output occurs; the shapes are still square. I've also tried replacing the 'glDrawElements' call with:
glDrawArrays(GL_POINTS,0,numPoints);
..but again there's no change.
The point size is set in the vertex shader, and the shader is successfully compiled and run:
uniform mediump mat4 projMx;
attribute vec2 a_position;
attribute vec4 a_color;
attribute float a_radius;
varying vec4 v_color;
void main()
{
vec4 position = vec4(a_position.x,a_position.y,1.0,1.0);
gl_Position = projMx * position;
gl_PointSize = a_radius*2.0;
v_color = a_color;
}
Does anyone know why circles aren't drawn with the glDrawElements VBO version?