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 render the resulting mesh. The problem is that it runs very well on my "Galaxy Nexus" but with the same code there is nothing on the screen when I try to run the app on my "Samsung Galaxy Note 10.1".
As it renders correctly on the Nexus, I assume that the .obj is parsed correctly - But still if it isn't I think I should see anything on the tablet - even if it is not correct.
Here is my code I am using 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: There are no errors in the LogCat
I would bet the issue is the use of GL_UNSIGNED_INT
.
Some GPU's only support GL_UNSIGNED_SHORT
.
This page may be useful for helping you determine exactly what features your devices support.
Android Developer: OpenGL Compatibility
OpenGL ES and EGL drivers are often buggy on Android. I have noticed that many people have problems with the Samsung drivers in particular. I recommend you try a device with an Nvidia Tegra, PowerVR or Adreno GPU and try the AVD emulation. If those work, then your problem is probably with Samsung's drivers.
Do you check for OpenGL ES errors after every call? That can help narrow down the problem. Errors during compiling and linking the shaders and glUseProgram() are particularly common.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With