Code example for ByteBuffer

Methods: asFloatBuffer, order

0
        // initialize vertex byte buffer for shape coordinates 
        bb = ByteBuffer.allocateDirect(
                // (number of coordinate values * 4 bytes per float) 
        		particleVBO.length * 4);
        // use the device hardware's native byte order 
        bb.order(ByteOrder.nativeOrder());
 
        // create a floating point buffer from the ByteBuffer 
        vertexBuffer = bb.asFloatBuffer();
        // add the coordinates to the FloatBuffer 
        vertexBuffer.put(particleVBO);
        // set the buffer to read the first coordinate 
        vertexBuffer.position(0);
         
        /* 
        bb2 = ByteBuffer.allocateDirect( 
                // (number of coordinate values * 4 bytes per float) 
        		particleInits.length * 4); 
        // use the device hardware's native byte order 
        bb2.order(ByteOrder.nativeOrder()); 
        // create a floating point buffer from the ByteBuffer