因此,在普通的openGL中,您可以像这样创建一个VAO
glGenVetrexArray();
 
并期望此函数为您创建一个VAO,并为您提供一个VAO ID的整数。
问题
在android中,功能如下:
glGenVetrexArray(int n , int[] array, int offset);
 
我不知道这些参数是什么,也不知道如何使用上述方法创建VAO并获取ID?
问题来源:Stack Overflow
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
n-要返回的VAO数量(数量);
数组-具有已创建对象标识符的n个元素的数组;
偏移量= 0。
创建VAO时,使用以下功能将其设为最新:GLES30.glBindVertexArray(VAO [0])。绑定VAO后,所有调用(例如glBindBuffer,glEnableVertexAttribArray,glVertexAttribPointer)都会影响当前的VAO。
public class Renderer implements GLSurfaceView.Renderer {
    private int[] VBOIds = new int[2]; // VertexBufferObject Ids
    private int[] VAOId = new int[1]; // VertexArrayObject Id
    public Renderer(...) {
        // create vertex buffer objects
        VBOIds[0] = 0;
        VBOIds[1] = 0;
        GLES30.glGenBuffers(2, VBO, 0);
        ...
        GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, VBO[0]);
        GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, verticesData.length * 4,
                    vertices, GLES30.GL_STATIC_DRAW);
        ...
        GLES30.glBindBuffer(GLES30.GL_ELEMENT_ARRAY_BUFFER, VBO[1]);
        GLES30.glBufferData(GLES30.GL_ELEMENT_ARRAY_BUFFER, indicesData.length * 2, indices, GLES30.GL_STATIC_DRAW);
        ...
    }
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
        GLES30.glGenVertexArrays(1, VAOId, 0); // Generate VAO Id
        GLES30.glBindVertexArray(VAOId[0]); // Bind the VAO
        // invokes commands glBindBuffer, glEnableVertexAttribArray, 
        // glVertexAttribPointer for VBOs
        ...
        // Reset to the default VAO (default VAO always is 0)
        GLES30.glBindVertexArray(0);
    }
    public void onDrawFrame() {
        ...
        GLES30.glBindVertexArray(VAOId[0]); // active VAO
        // Draw on base the VAO settings
        GLES30.glDrawElements(GLES30.GL_TRIANGLES, indicesData.length,
                      GLES30.GL_UNSIGNED_SHORT, 0);
        // Return to the default VAO
        GLES30.glBindVertexArray(0);
    }
}```
您可以在[此处](https://github.com/danginsburg/opengles3-book/blob/master/Android_Java/Chapter_6/VertexArrayObjects/src/com/openglesbook/VertexArrayObjects/VAORenderer.java)看到使用VAO的一个很好的例子
[适用于Android的Project VertexArrayObjects](https://github.com/danginsburg/opengles3-book/tree/master/Android_Java/Chapter_6/VertexArrayObjects)
回答来源:Stack Overflow