We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi,
has anyone tried using VAOs in Processing?
I'm attempting to add a VAO to the Advanced OpenGL example from the Wiki, but I can't work out how to set it up.
My plan is to create and populate the VBOs and bind them to a VAO in setup(), then I just need to bind and draw the VAO in draw(), rather than having to bind the 3 VBOs individually before drawing. That's the plan, anyway.
So far, I've changed 'gl' to be an instance of the 'GL3', rather than 'GL2ES2' JOGL objects, as I think VAOs aren't part of the GL2ES2 spec.
I've changed
gl = pgl.gl.getGL2ES2();
to
gl = pgl.gl.getGL3();
to match.
I've also generated an extra IntBuffer in setup()
gl.glGenBuffers(4, intBuffer);
vaoId = intBuffer.get(0);
posVboId = intBuffer.get(1);
colorVboId = intBuffer.get(2);
indexVboId = intBuffer.get(3);
as according to the the jogamp docs for GL3, the glGenVertexArrays() function requires an IntBuffer as its 2nd argument.
What I can't work out is what should be in the IntBuffer that's passed in, and how to get the data into it.
Apologies if this is a stupid question. I have a basic concept of what VAOs are for, but have never tried implementing them before.
Any tips or pointers gratefully accepted.
a|x
Answers
@toneburst
IntBuffer vao = GLBuffers.newDirectIntBuffer(1); gl3.glGenVertexArrays(1, vao); gl3.glBindVertexArray(vao.get(0));
https://github.com/tolkanabroski/pshader-processing/blob/master/basics/iknowopengl.pde
Hi @nabr sorry for the late reply. I'll try that, thanks very much, once again!
a|x
Unless I'm missing something, he doesn't seem to be using the VAO he created, in the draw method.
Maybe I'm wrong, though...
a|x
@toneburst yes. becourse the example use drawelements https://www.google.de/search?q=gldrawelements+vs+gldrawarrays
you have to figure out, what works best in your project.
Ah, I see. Thanks @nabr.
a|x