Code example for FloatBuffer

Methods: flip, put

0
 
        int VERTEX_SIZE = (2+4)*4;
        byteBuffer = ByteBuffer.allocateDirect(3*VERTEX_SIZE);
        byteBuffer.order(ByteOrder.nativeOrder());
        vertices = byteBuffer.asFloatBuffer();
        vertices.put(new float[] { 0.0f, 0.0f, 1, 0, 0, 1,
                                   319.0f, 0.0f, 1, 1, 0, 1, 
                                   160.0f, 479.0f, 1, 0, 1, 1 }); 
        vertices.flip();
 
        glView = new GLSurfaceView(this);
        glView.setRenderer(new Render());
        setContentView(glView);
    } 
 
    class Render implements Renderer {
 
        @Override 
        public void onDrawFrame(GL10 gl) {
 
            int VERTEX_SIZE = (2+4)*4;