2
votes

I am converting an iPhone application from OpenGL ES 1.1 to ES 2.0. The application draws to an EAGLView as this is defined in the standard OpenGL ES application template as it is provided by Apple.

The ES 1.1 code was working fine on both the simulator and on the iPhone. The new ES 2.0 code is working fine on the simulator but on an iPhone 3GS I get artifacts (e.g. scaled fragments of views from other applications) that as far as I can understand show that my program gets confused about the framebuffer. I find this strange since I haven't made any changes to the framebuffer handling logic compared to the ES 1.1.

I include below the part of the code that does the drawing, although I don't see the point since it works fine in the simulator:

GLfloat data[600000];

// initialize data

glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT); 

glUseProgram(program);
glUniformMatrix4fv(uniforms[UNIFORM_PROJECTION_MATRIX], 1, GL_FALSE, projection_matrix);
glUniformMatrix4fv(uniforms[UNIFORM_MODELVIEW_MATRIX], 1, GL_FALSE, modelview_matrix);

glVertexAttribPointer(ATTRIBUTE_POSITION, 3, GL_FLOAT, GL_FALSE, 0, data);
glEnableVertexAttribArray(ATTRIBUTE_POSITION);
glDrawArrays(GL_POINTS, 0, 200000);
glFlush();
1

1 Answers

6
votes

It looks like there is a bug in the OpenGL ES 2 implementation. The hint was that when I changed glDrawArrays(GL_POINTS, 0, 200000); to glDrawArrays(GL_LINES, 0, 200000); there is no display problem on the device. The solution (found here) for using GL_POINTS is to set gl_PointSize = 1.0; in the vertex shader.

EDIT: It's probably not a bug, see here:

The value of gl_PointSize (or the gl_PointSize member of the gl_out[] array, in the case of the tessellation control shader) is undefined after the vertex, tessellation control, and tessellation evaluation shading stages if the corresponding shader executable does not write to gl_PointSize.