GLES2.0 - glDrawElements not working

I am currently working on my first project using OpenGL ES 2.0 on Android.

I am parsing an object file (.obj) and want to display the resulting set. The problem is that it works very well on my “Galaxy Nexus”, but with the same code, nothing appears on the screen when I try to run the application on my “Samsung Galaxy Note 10.1”.

Since it displays Nexus correctly, I assume .obj is being parsed correctly. But if it is not, I think I should see something on the tablet, even if it is not true.

Here is my code that I use for rendering.

GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, triangleBuffer); GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, indexBuffer); //System.out.println(("MESH: " + GLES20.glGetAttribLocation(shaderProgram, "vertex") + " " + GLES20.glGetAttribLocation(shaderProgram, "vertex"))); GLES20.glVertexAttribPointer(GLES20.glGetAttribLocation(shaderProgram, "vertex"), 3, GLES20.GL_FLOAT, false, floatPerVertex*mBytesPerFloat, 0); GLES20.glEnableVertexAttribArray(GLES20.glGetAttribLocation(shaderProgram, "vertex")); GLES20.glVertexAttribPointer(GLES20.glGetAttribLocation(shaderProgram, "normal"), 3, GLES20.GL_FLOAT, false, floatPerVertex*mBytesPerFloat, 3*mBytesPerFloat); GLES20.glEnableVertexAttribArray(GLES20.glGetAttribLocation(shaderProgram, "normal")); GLES20.glDrawElements(GLES20.GL_TRIANGLE_STRIP, faceCount , GLES20.GL_UNSIGNED_INT, 0); 

Is there a mismatch between GLES 2.0 on Nexus devices and other devices?

Edit: Errors in LogCat

not.
+4
source share
2 answers

I would argue that the problem is using GL_UNSIGNED_INT .
Some GPUs only support GL_UNSIGNED_SHORT .

This page may be useful to help you determine exactly what features your devices support.
Android Developer: OpenGL Compatible

+11
source

OpenGL ES and EGL drivers often do not work on Android. I noticed that many people have problems with Samsung drivers in particular. I recommend that you try the Nvidia Tegra, PowerVR or Adreno GPU device and try AVD emulation. If this works, then your problem is probably related to Samsung drivers.

Do you check OpenGL ES errors after every call? This can help reduce the problem. Errors in compiling and linking shaders and glUseProgram () are especially common.

+1
source

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


All Articles