OpenGL ES 2.0 with iPhone: GL_POINT_SMOOTH draws squares with ES 2.0, but works in ES 1.0

I am trying to draw circles using Vertex Buffer Object to draw points with GL_POINT_SMOOTH enabled in OpenGL ES 2.0 on iPhone.

I used the following ES 1.0 rendering code to draw circles on the iPhone 4:

glVertexPointer(2, GL_FLOAT, 0, circleVertices); glEnableClientState(GL_VERTEX_ARRAY); glEnable(GL_POINT_SMOOTH); glPointSize(radius*2); glDrawArrays(GL_POINTS, 0, 1); 

Now I'm trying to achieve the same effect using the VBO setting, 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 peaks are very clearly square, not circular.

I tried reducing the "glEnable" and related calls in the above example to emulate the first working version, but no visible changes in the output occur; the shapes are still square. I also tried replacing the glDrawElements call with the following:

  glDrawArrays(GL_POINTS,0,numPoints); 

.. but again there is no change.

The point size is set in the vertex shader , and the shader was successfully compiled and launched:

 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 are not drawn with the glDrawElements VBO version?

+3
source share
1 answer

This means that you have included GL_POINT_SPRITE_OES, it is used to draw rectangles with dots, which is useful for billboards (easier and faster than using 4 vertices to draw a rectangle).

Try to remove glEnable (GL_POINT_SPRITE_OES); and it should work.

+1
source

Source: https://habr.com/ru/post/1369585/


All Articles