Code example for FloatBuffer

Methods: flip, put

0
        glGraphics = ((GLGame) game).getGLGraphics();
                     
        ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4 * VERTEX_SIZE);
        byteBuffer.order(ByteOrder.nativeOrder());
        vertices = byteBuffer.asFloatBuffer();
        vertices.put(new float[] {  100.0f, 100.0f, 0.0f, 1.0f,
                                    228.0f, 100.0f, 1.0f, 1.0f, 
                                    228.0f, 228.0f, 1.0f, 0.0f, 
                                    100.0f, 228.0f, 0.0f, 0.0f }); 
        vertices.flip();
         
        byteBuffer = ByteBuffer.allocateDirect(6 * 2);
        byteBuffer.order(ByteOrder.nativeOrder());
        indices = byteBuffer.asShortBuffer();
        indices.put(new short[] { 0, 1, 2,
                                  2, 3, 0 }); 
        indices.flip();
         
        texture = new Texture((GLGame)game, "bobrgb888.png");
    }