OpenGL ES 2.0和glError 0x502? (使用Vuforia)

时间:2015-06-06 08:15:46

标签: opengl-es opengl-es-2.0 vuforia

有人可以告知以下OpenGL ES 2.0代码有什么问题吗?我正在使用Vuforia增强现实SDK,我想用一端颜色绘制线条,然后淡入另一端的颜色。

startX

不显示渐变。 Ubuntu Eclipse LogCat声明了以下错误,该错误与代码末尾附近的 GLES20.glUseProgram(shaderProgramID); GLES20.glVertexAttribPointer(vertexHandle, 3, GLES20.GL_FLOAT, false, 0, line_vertices_buffer); GLES20.glEnableVertexAttribArray(vertexHandle); GLES20.glVertexAttribPointer(colorHandle, 3, GLES20.GL_FLOAT, false, 0, line_colours_buffer); GLES20.glEnableVertexAttribArray(colorHandle); GLES20.glBindAttribLocation(shaderProgramID, colorHandle, "color"); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextures.get(2).mTextureID[0]); Matrix.multiplyMM(modelViewProjection, 0, vuforiaAppSession.getProjectionMatrix().getData(), 0, modelViewMatrix, 0); GLES20.glEnable(GLES20.GL_BLEND); GLES20.glUniformMatrix4fv(mvpMatrixHandle, 1, false, modelViewProjection, 0); GLES20.glUniform1i(colorHandle, 0); GLES20.glLineWidth(30); GLES20.glDrawArrays(GLES20.GL_LINES, 0, 2 + line_vertices_array.size()); GLES20.glDisable(GLES20.GL_BLEND); GLES20.glDisableVertexAttribArray(vertexHandle); GLES20.glDisableVertexAttribArray(colorHandle); 命令有关。

glUniform1i(colorHandle, 0)

有谁知道如何修复此错误?

着色器由:

给出
06-06 09:13:57.340: E/Vuforia_Sample_Applications(14175): After operation UserDefinedTargets renderFrame got glError 0x502
06-06 09:13:57.390: W/Adreno-ES20(14175): <__load_uniform_int:351>: GL_INVALID_OPERATION

我在主代码中尝试将“color”更改为“keyColor”,但仍然出现错误,即

String frameVertexShader = " \n" + "attribute vec4 vertexPosition; \n"
    + "attribute vec2 vertexTexCoord; \n" + "\n"
    + "varying vec2 texCoord; \n" + "\n"
    + "uniform mat4 modelViewProjectionMatrix; \n" + "\n"
    + "void main() \n" + "{ \n"
    + "gl_Position = modelViewProjectionMatrix * vertexPosition; \n"
    + "texCoord = vertexTexCoord; \n" + "} \n";

String frameFragmentShader = " \n" + "precision mediump float; \n" + "\n"
    + "varying vec2 texCoord; \n" + "\n"
    + "uniform sampler2D texSampler2D; \n" + "uniform vec4 keyColor; \n"
    + "\n" + "void main() \n" + "{ \n"
    + "vec4 texColor = texture2D(texSampler2D, texCoord); \n"
    + "gl_FragColor = keyColor * texColor; \n" + "} \n" + "";

GLES20.glBindAttribLocation(shaderProgramID, colorHandle, "color");

我还确保我的缓冲区有4个RGBA浮点数,因为片段着色器似乎在GLES20.glBindAttribLocation(shaderProgramID, colorHandle, "keyColor"); 期望这个。

NB Vuforia似乎确实使用ByteBuffer,即使对于float数组,然后我们将putFloat用于ByteBuffer,例如。

keyColor

0 个答案:

没有答案