Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Hi,
since I am using a textbook that is written in C and/or C++, I cannot visualize how the create this lines: glGenVertexArrays(1, &vao); glBindVertexArray(vao); So where does the vao come from. I found an Example online showing how to create the VAO in JOGL: http://stackoverflow.com/questions/17450373/jogl-simple-example-with-shaders-vao-and-index-array But my question is, in JOGL, is VAOs as in the example shader program in the link above, is always dimension 1 like so: private int[] VAOs = new int[1]; So is there different representation of VAOs depending on the type of shader that will use it? Can someone elaborate on this please? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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 |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Thank you, that is so much clearer now.
and very interesting. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
In reply to this post by elect
Rather always use direct NIO buffers because JOGL is forced to create them under the hood when you pass arrays or indirected NIO buffers and using NIO buffers isn't very difficult. Java arrays aren't faster than NIO buffers but the creation of a direct NIO buffer takes much time than the creation of an array. The methods accepting arrays are there only for compatibility, it's just some syntactic sugar.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I didn't know that.. Well, I had a lot of trouble with positions, view buffer and so on.. I am gonna write a wiki about it |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
In reply to this post by gouessej
This includes also all the glGet*, right?
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
Yes but take care of reusing direct NIO buffers as much as possible.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
What about this? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
GlueGen has evolved a lot in ten years. What Kenneth wrote was right in 2006.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Ok, thanks
|
Free forum by Nabble | Edit this page |