Datasource:
float[] v = { ... };
Working example:
FloatBuffer buf = BufferUtils.createFloatBuffer(v.length);
buf.put(v);
buf.flip(); // or buf.rewind()
The buffer can now be uploaded to opengl and works fine:
...
glBufferData(..., buf, ...);
...
Why do the following examples of the buffer creation not also work?
Not working 1:
FloatBuffer buf = FloatBuffer.wrap(v);
Not working 2:
FloatBuffer buf = FloatBuffer.allocate(v.length);
buf.put(v);
buf.flip(); // or buf.rewind()
Edit:
After browsing the API code, I found out:
In case of the working example memAddress(buf) returns a valid address, but in the other cases it returns just 0.
Additional infos:
why am i getting a FloatBuffer is not direct error?