Login  Register

Re: How do you create a VAO object in JOGL (java) to use with shaders

Posted by elect on Feb 11, 2016; 7:59am
URL: https://forum.jogamp.org/How-do-you-create-a-VAO-object-in-JOGL-java-to-use-with-shaders-tp4036166p4036172.html

In jogl, you usually have two possibilities:

- use int/float/long arrays
- use int/float/double buffers

You can see it <a href="http:// http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/GL2ES3.html#glGenVertexArrays(int,%20int[],%20int)">here

where for the C function

glGenVertexArrays(1, &vao);

you have

void glGenVertexArrays(int n, IntBuffer arrays)

or

void glGenVertexArrays(int n, int[] arrays, int arrays_offset)

I'd suggest you to always go with the arrays, they are faster and easier to manipulate

the sample you saw

private int[] VAOs = new int[1];

it's a simple sample allocating an int array with just one dimension for tutorial purpouses, nothing else

you should, instead, allocating an int as big as all your objects, like here and then you manage it via final variables

In this way you decrease the possibility to have errors regarding binding illegal objects, since you when you use them, you can't confuse one with another, because it is clear by its name what you are using, like here

        gl4.glGenVertexArrays(1, objects, Semantic.Object.VAO);
        gl4.glBindVertexArray(objects[Semantic.Object.VAO]);

Where you generate one VAO and you bind it

In general, when you have a complex program, every mesh having geometry should have an array like this