Java: FloatBuffer to OpenGL - wrap() vs. allocate() vs. BufferUtils.createBuffer()
问题 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