Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在禁用VERTEX_数组客户端状态的情况下调用GLDraweElements_Android_Opengl Es_Opengl Es 2.0 - Fatal编程技术网

Android 在禁用VERTEX_数组客户端状态的情况下调用GLDraweElements

Android 在禁用VERTEX_数组客户端状态的情况下调用GLDraweElements,android,opengl-es,opengl-es-2.0,Android,Opengl Es,Opengl Es 2.0,我试图在Android上的OpenGL ES 2.0+中绘制一个球体,我在Logcat中看到以下错误: 在禁用VERTEX_数组客户端状态的情况下调用GLDraweElements 我查看了这个电话的文档,没有发现我可能做错了什么。从这个错误听起来好像我在什么地方错过了一些设置 下面是我正在进行设置的VertexBuffer类: public class VertexBuffer { private final int mBufferId; public VertexBuff

我试图在Android上的OpenGL ES 2.0+中绘制一个球体,我在Logcat中看到以下错误:

在禁用VERTEX_数组客户端状态的情况下调用GLDraweElements

我查看了这个电话的文档,没有发现我可能做错了什么。从这个错误听起来好像我在什么地方错过了一些设置

下面是我正在进行设置的VertexBuffer类:

public class VertexBuffer {

    private final int mBufferId;

    public VertexBuffer(float[] vertexData) {
        // Allocate a buffer
        final int[] buffers = new int[1];
        glGenBuffers(buffers.length, buffers, 0);
        if (buffers[0] == 0) {
            throw new RuntimeException("Could not create a new VBO");
        }
        mBufferId = buffers[0];

        // Bind to the buffer
        glBindBuffer(GL_ARRAY_BUFFER, mBufferId);

        // Transfer data to native memory
        FloatBuffer vertexArray = ByteBuffer
            .allocateDirect(vertexData.length * BYTES_PER_FLOAT)
            .order(ByteOrder.nativeOrder())
            .asFloatBuffer()
            .put(vertexData);
        vertexArray.position(0);

        // Transfer data from native memory to the GPU buffer
        glBufferData(GL_ARRAY_BUFFER, vertexArray.capacity() * BYTES_PER_FLOAT, vertexArray, GL_STATIC_DRAW);

        // IMPORTANT: Unbind from the buffer when we are done with it
        glBindBuffer(GL_ARRAY_BUFFER, 0);
    }

    public void setVertexAttribPointer(int dataOffset, int attributeLocation, int componentCount, int stride) {
        glBindBuffer(GL_ARRAY_BUFFER, mBufferId);
        glVertexAttribPointer(attributeLocation, componentCount, GL_FLOAT, false, stride, dataOffset);
        glEnableVertexAttribArray(attributeLocation);
        glBindBuffer(GL_ARRAY_BUFFER, 0);
    }
}
加:


您能显示您绘制的代码吗?
GL\u VERTEX\u ARRAY
客户端状态甚至不是GLES 2.0的一部分,它仅存在于GLES 1.x的固定功能管道中。如果您使用的是ES 2.0上下文,则此错误毫无意义-您的驱动程序可能会感到困惑。您完全正确。我忘记在曲面上将上下文设置为ES 2.0。我设置了它,现在错误消失了。
setEGLContextClientVersion(2);