I am using libgdx and have following code
float[] x;
...
Buffer vVertices=x;//what to do here?
gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vVertices);
But I am not sure how I can pass array x to Buffer? Any idea?
ByteBuffer byteBuf = ByteBuffer.allocateDirect(x.length * Float.BYTES); //4 bytes per float
byteBuf.order(ByteOrder.nativeOrder());
FloatBuffer buffer = byteBuf.asFloatBuffer();
buffer.put(x);
buffer.position(0);
Both ByteBuffer and FloatBuffer inherit from Buffer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With