robot_rover
robot_rover

Reputation: 130

glGenVertexArrays() should not have any arguments

I am trying to get basic custom shaders working on a LibGDX project. When I try to generate the VAO it says that glGenVertexArrays() requires an int (n) and an IntBuffer (buffer). I know the IntBuffer is how you access the allocated buffer space, but I honestly have no idea what is supposed to go into n. In every example I have found while searching around, glGenVertexArrays() is a method with no arguments and just returns the int index for the VAO, which you can use to set it up, bind to it, etc.

How am I supposed to use this to set up a VAO and why is my method signature different than all the other LWJGL examples I have looked at?

Upvotes: 2

Views: 324

Answers (1)

sorifiend
sorifiend

Reputation: 6307

According to the source for libgdx you can only call it in one of these 3 ways depending on the object:

//Normal methods
.glGenVertexArrays(int n, int[] arrays, int offset);
.glGenVertexArrays(int n, IntBuffer arrays);

//Method specifically for AndroidGL30.glGenVertexArrays(...
.glGenVertexArrays (int n, java.nio.IntBuffer arrays);

In most cases the n is ignored or just used as an array size. The below is copied from the LwjglGL30 class:

@Override
public void glGenVertexArrays (int n, int[] arrays, int offset) {
    for(int i = offset; i < offset + n; i++) {
        arrays[i] = GL30.glGenVertexArrays();
    }
}

@Override
public void glGenVertexArrays (int n, IntBuffer arrays) {
    GL30.glGenVertexArrays(arrays);
}

So from that we can see that for the IntBuffer method you can simply use the following in your code: .glGenVertexArrays(1, myIntBuffer);

Reference:

https://github.com/libgdx/libgdx/search?utf8=%E2%9C%93&q=glGenVertexArrays&type=

For more help you should show us a bit more of your code, and what objects you are using to call glGenVertexArrays().

Upvotes: 2

Related Questions