VBO's use of java buffers

Started by mireazma, March 17, 2014, 17:26:06

Previous topic - Next topic

mireazma

In all tutorials I've seen the vertex arrays to be used in VBO's are in the form of a FloatBuffer. But the power of B (buffer) in VBO comes from the buffer in GPU. And IIRC in C++ you pass in a simple array into glBufferData(), not a buffer.
So, with java and lwjgl, is the FloatBuffer mandatory or a simple array would do?

And please, can somebody give me a link to learn the methods and their order on how to create and update a VBO at the change of a small part of it? Just the basic skeleton structure to build on. I have already struggled with "The Quad updating a VBO with BufferSubData" in the wiki for like 2 hours but I'm too idiot to understand that, too cluttery for my head.

Cornix

You have to use buffers, you can not use arrays.
The problem is that with C++ you dont give the entire array as an argument but rather a pointer to the first element of the array as well as the length of the array as an additional argument.
The Buffers are used to simulate this construct. They have a position (pointer to the first element) and a limit (size of the array) as well as a backing array of elements.

For updating the contents of a VBO all you need to do is:
1) Bind the vbo
2) Have the data to update ready in a FloatBuffer
3) call glBufferSubData with the correct arguments

If you need to resize the VBO you have to call glBufferData instead.

mireazma

Thank you very much, many things are clear now.