我正在尝试让基本的自定义着色器在 LibGDX 项目上工作。当我尝试生成 VAO 时,它说 glGenVertexArrays()
需要一个 int (n) 和一个 IntBuffer(缓冲区)。我知道 IntBuffer 是访问分配的缓冲区空间的方式,但老实说我不知道 n 应该包含什么。在我在搜索过程中发现的每个示例中,glGenVertexArrays()
是一个没有参数的方法,仅返回 VAO 的 int 索引,您可以使用它来设置它、绑定(bind)到它等.
我应该如何使用它来设置 VAO?为什么我的方法签名与我看过的所有其他 LWJGL 示例不同?
最佳答案
根据 libgdx 的源代码,您只能根据对象以以下 3 种方式之一调用它:
//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);
在大多数情况下,n
会被忽略或仅用作数组大小。以下内容是从 LwjglGL30
类复制的:
@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);
}
由此我们可以看出,对于 IntBuffer
方法,您只需在代码中使用以下内容:.glGenVertexArrays(1, myIntBuffer);
引用:
https://github.com/libgdx/libgdx/search?utf8=%E2%9C%93&q=glGenVertexArrays&type=
要获得更多帮助,您应该向我们展示更多代码,以及您使用哪些对象来调用 glGenVertexArrays()
。
关于java - glGenVertexArrays() 不应有任何参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45202284/