In my Android application, I am using OpenGL ES 2.0, and I need to show the grid in the center of the scene. I have a camera that can rotate around the center of the scene.
I am creating a grid using GL_LINES and a simple shader program.
On some devices that I have, everything works fine, but on one device (in particular, in the version of Galaxy Note 10.1 2014) I have a problem with the disappearance / blinking of the grid lines when the camera is rotated, that is, at some angles of the camera angle .
This is what the problem looks like:

And here is how it should work:

, , , , , ( , ) (.. ). , , , .
, . , . , . , - OpenGL , .
, , , , ..? . Android, , , , .
Galaxy Tab 10.1 Lenovo P780.
Galaxy Note 10.1 (2560 x 1600),
, , , , / , , , , ?
( , ) .
.
DrawFrame /:
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
GLES20.glLineWidth(1f);
float screenRatio = (float)viewportWidth / (float)viewportHeight;
Matrix.setIdentityM(matrixProjection, 0);
MatrixHelper.perspectiveM(matrixProjection, 0, 90, screenRatio, 0.1f, 1000f);
Matrix.setIdentityM(matrixView, 0);
Matrix.translateM(matrixView, 0, 0f, 0f, -10f);
rotationAngle = rotationAngle + (10f * deltaSec);
Matrix.rotateM(matrixView, 0, 45f, 1f, 0f, 0f);
Matrix.rotateM(matrixView, 0, rotationAngle, 0f, 1f, 0f);
GLES20.glUseProgram(shaderGrid.ShaderProgramId);
GLES20.glUniformMatrix4fv(shaderGrid.vProjection, 1, false, matrixProjection, 0);
GLES20.glUniformMatrix4fv(shaderGrid.vView, 1, false, matrixView, 0);
renderGrid.Draw(shaderGrid, origin);
:
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, bufferIds[0]);
GLES20.glVertexAttribPointer(shader.aPosition, 3, GLES20.GL_FLOAT, false, 0, 0);
GLES20.glEnableVertexAttribArray(shader.aPosition);
float [] m = new float[16];
Matrix.setIdentityM(m, 0);
GLES20.glUniformMatrix4fv(shader.vModel, 1, false, m, 0);
GLES20.glDrawArrays(GLES20.GL_LINES, 0, 10 * 2 * 4);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
GLES20.glDisableVertexAttribArray(shader.aPosition);
( =)):
public String GetShaderFragmentCode()
{
return
"precision mediump float;" +
"void main() " +
"{" +
" gl_FragColor = vec4(0.7, 0.7, 0.7, 1.0);" +
"}";
}
public String GetShaderVertexCode()
{
return
"uniform mat4 vProjection;" +
"uniform mat4 vModel;" +
"uniform mat4 vView;" +
"attribute vec3 aPosition;" +
"void main() " +
"{" +
" gl_Position = (vProjection * vView * vModel) * vec4(aPosition.xyz, 1.0);" +
"}";
}
(, ):
APK
, , , , . , .
, , ( , ):
- / GL_CULL_FACE
- glLineWidth 1f
- glDrawElements glDrawArrays
- frustum zNear ( 0.1f 100f)
- frustum zFar ( 10f )
- vec3 vec4 aPosition ( .xyz)
- GL_LINE_STRIP - , , .
- GL_TRIANGLE_STRIP .. - , ,
, :

, , .