Code example for ShortBuffer

Methods: flip, put

0
	public static ShortBuffer createShortBuffer(short [] data) {
		ShortBuffer shortBuffer;		
		ByteBuffer byteBuffer = ByteBuffer.allocateDirect(data.length * 2);
		byteBuffer.order(ByteOrder.nativeOrder());
		shortBuffer = byteBuffer.asShortBuffer();		
		shortBuffer.put(data);
		shortBuffer.flip();
		return shortBuffer;		
	} 
	 
	private static FloatBuffer cubeVertices = Util.createFloatBuffer(new float[] {
		// FRONT 
		-0.5f, -0.5f,  0.5f, 
		0.5f, -0.5f,  0.5f, 
		-0.5f,  0.5f,  0.5f, 
		0.5f,  0.5f,  0.5f, 
		// BACK 
		-0.5f, -0.5f, -0.5f, 
		-0.5f,  0.5f, -0.5f, 
		0.5f, -0.5f, -0.5f, 
		0.5f,  0.5f, -0.5f,