Code example for FloatBuffer

Methods: position, put

0
		 * to be multiplied with 4: 
		 */ 
		ByteBuffer byteBuffer = ByteBuffer.allocateDirect(source.length * 4);
		byteBuffer.order(ByteOrder.nativeOrder());
		FloatBuffer targetBuffer = byteBuffer.asFloatBuffer();
		targetBuffer.put(source);
		targetBuffer.position(0);
		return targetBuffer;
	} 
 
	public static ShortBuffer createAndInitShortBuffer(short[] source) {
		if (source == null)
			return null; 
		// short is 2 bytes, therefore we multiply the number if 
		// vertices with 2. 
		ByteBuffer indiceBiteBuffer = ByteBuffer
				.allocateDirect(source.length * 2);
		indiceBiteBuffer.order(ByteOrder.nativeOrder());
		ShortBuffer targetBuffer = indiceBiteBuffer.asShortBuffer();
		targetBuffer.put(source);
		targetBuffer.position(0);