简体   繁体   English

GLES2.0 - glDrawElements不起作用

[英]GLES2.0 - glDrawElements not working

I am currently working on my first project using OpenGL ES 2.0 on Android. 我目前正在使用Android上的OpenGL ES 2.0开发我的第一个项目。

I am parsing an object file (.obj) and want to render the resulting mesh. 我正在解析一个目标文件(.obj),并希望渲染生成的网格。 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". 问题是它在我的“Galaxy Nexus”上运行得非常好,但是当我尝试在“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. 因为它在Nexus上正确呈现,我认为.obj被正确解析 - 但如果不是,我认为我应该在平板电脑上看到任何东西 - 即使它不正确。

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?? Nexus设备和其他设备上的GLES 2.0之间是否存在不匹配?

Edit: There are no errors in the LogCat 编辑:LogCat中没有错误

I would bet the issue is the use of GL_UNSIGNED_INT . 我敢打赌问题是使用GL_UNSIGNED_INT
Some GPU's only support GL_UNSIGNED_SHORT . 有些GPU仅支持GL_UNSIGNED_SHORT

This page may be useful for helping you determine exactly what features your devices support. 此页面可能有助于您确切了解设备支持的功能。
Android Developer: OpenGL Compatibility Android开发人员:OpenGL兼容性

OpenGL ES and EGL drivers are often buggy on Android. OpenGL ES和EGL驱动程序在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. 我建议您尝试使用Nvidia Tegra,PowerVR或Adreno GPU的设备并尝试AVD仿真。 If those work, then your problem is probably with Samsung's drivers. 如果这些工作,那么你的问题可能是三星的驱动程序。

Do you check for OpenGL ES errors after every call? 您是否在每次通话后检查OpenGL ES错误? That can help narrow down the problem. 这可以帮助缩小问题的范围。 Errors during compiling and linking the shaders and glUseProgram() are particularly common. 编译和链接着色器和glUseProgram()期间的错误特别常见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM