在glDrawElements上获取错误“在绘图调用中没有启用顶点属性”

时间:2017-01-12 16:42:30

标签: android opengl-es android-ndk opengl-es-2.0

我正在开发一款使用OpenGL ES 2.0的Android应用。当我尝试使用以下行从数组数据中渲染我的基元时...

// primitiveType is a GLenum with a value of 1
// batch->GetIndexCount() returns a size_t with a value of 65528
// indexType is a GLenum with a value of 5123
// Passing 0 as the indices parameter since an ELEMENT_ARRAY_BUFFER is bound (0 will be treated as an offset within the buffer)
GL_CHECK(glDrawElements(primitiveType, static_cast<GLsizei>(batch->GetIndexCount()), indexType, 0));

我收到以下错误:

I/Adreno-ES20: <validate_vertex_attrib_state:55>: validate_vertex_attrib_state: No vertex attrib is enabled in a draw call!
W/Adreno-ES20: <core_glDrawElementsInstancedXXX:1014>: GL_INVALID_VALUE
D/libEGL: [glDrawElements] 0x501
D/glGetError:glDrawElements: #00 pc 00002a31  /system/lib/libbacktrace.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
D/glGetError:glDrawElements: #01 pc 0000ba41  /system/lib/libutils.so (android::CallStack::update(int, int)+52)
D/glGetError:glDrawElements: #02 pc 00025ff5  /system/lib/libEGL.so
D/glGetError:glDrawElements: #03 pc 000cea14  /data/app/com.sample.openglesapp/lib/arm/libgl_code.so (OpenGLESHelper::DrawBatch(OpenGLESApp::Graphics::PrimitiveBatch*)+720)
D/glGetError:glDrawElements: #04 pc 00129038  /data/app/com.sample.openglesapp/lib/arm/libgl_code.so (RendererOpenGLES::Render_DrawBatch(OpenGLESApp::Graphics::PrimitiveBatch*)+52)
D/glGetError:glDrawElements: #05 pc 000d4b80  /data/app/com.sample.openglesapp/lib/arm/libgl_code.so (OpenGLESApp::Graphics::RendererBase<OpenGLESApp::Graphics::Rendering3D::Camera>::Render()+532)
D/glGetError:glDrawElements: #06 pc 00161bd8  /data/app/com.sample.openglesapp/lib/arm/libgl_code.so (RenderFrame()+344)
D/glGetError:glDrawElements: #07 pc 00161cc0  /data/app/com.sample.openglesapp/lib/arm/libgl_code.so (Java_com_sample_openglesapp_GL2JNILib_step+20)
D/glGetError:glDrawElements: #08 pc 000db0e1  /data/dalvik-cache/arm/data@app@com.sample.openglesapp@base.apk@classes.dex

根据OpenGL ES 2.0文档,glDrawElements returns a GL_INVALID_VALUE error code当计数(第二个参数)为负时,这不是这里的情况。此外,启用顶点属性。 还有什么可能导致这个问题?

1 个答案:

答案 0 :(得分:0)

浏览顶点着色器。

如果顶点着色器中的语法或计算错误,您可以看到消息“绘制调用中未启用顶点属性”

如果你的一个指数指的是错误的数字,它就会发生。