Posted by
PedDavid on
May 29, 2015; 8:52am
URL: https://forum.jogamp.org/VAO-and-VBO-creation-tp4034542.html
First post here. I just started using jogl and I have a lot of questions, but right now I'm adressing the ones about VAOs and VBOs.
I'm trying to follow and tutorial on youtube but the guy is using lwjgl and it seems they're very different.
His code can be found here:
https://www.dropbox.com/sh/sqqfm1s0vxcqf8u/AACkLQP2v_e-oDt_PaTKapoza/Loader.java?dl=0So, from what I've understood until now (or at least I think I did), lwjgl uses static methods to create/bind/changeAtributes etc... VAOs and VBOs and JOGL uses instance methods that need to be refered from a context, so instead of calling the "GL'X'"."method()" (If I wanted to do this in a separate class like this guy) I would need a contructor that would be called in the "public void init(GLAutoDrawable drawable)" and would pass drawable so these class would have a field "GL2 gl = drawable.getGL().getGL2();" right? And after this I would call gl."methods"?.
The next question is about this method:
private int createVAO() {
int vaoID = GL30.glGenVertexArrays();
vaos.add(vaoID);
GL30.glBindVertexArray(vaoID);
return vaoID;
}
So, i try to call gl.glGenVertexArrays()... It needs two parameters (or three), a size (of what?), a buffer(which buffer?) or an array plus offset(which array and offset?) and it doesn't return a int so I can't reference it later
(so I can't use:
public void cleanUp() {
for (int vao : vaos) {
GL30.glDeleteVertexArrays(vao);
}
for (int vbo : vbos) {
GL15.glDeleteBuffers(vbo);
}
for (int texture : textures) {
GL11.glDeleteTextures(texture);
}
}
)
Same with VBOs:
private void storeDataInAttributeList(int attributeNumber, int coordinateSize, float[] data) {
int vboID = GL15.glGenBuffers();
vbos.add(vboID);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
FloatBuffer buffer = storeDataInFloatBuffer(data);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
GL20.glVertexAttribPointer(attributeNumber, coordinateSize, GL11.GL_FLOAT, false, 0, 0);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
Once again I don't get a reference so same poblem as before
Sorry about my english (not native speaker) and if this is a noob question or as been adressed before. I tried to research a lot before posting it but a lot of stuff is in c++ (what I don't know) and I don't really know what glGenVertexArrays(int, &?) mean...
Edit: Wait! Don't tell me those parameters are filled "as I wish" to give "specific references" instead of "generating random ones and saving them" in lwjgl
I mean: gl.glGenVertexArrays("put here the int I was asking for", my "array" of VAO's? )