Code example for ByteBuffer

Methods: glReadPixelsget

        // Read the RGBA color at the specified point as a 4-component tuple of unsigned bytes. OpenGL ES does not 
        // support reading only the RGB values, so we read the RGBA value and ignore the alpha component. We convert the 
        // y coordinate from Android UI coordinates to GL coordinates. 
        int yInGLCoords = this.viewportHeight - point.y;
        GLES20.glReadPixels(point.x, yInGLCoords, 1, 1, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, this.pickColor);
        // GL places the value RGBA in the first 4 bytes of the buffer, in that order. We ignore the alpha component and 
        // compose an integer equivalent to those returned by getUniquePickColor. 
        return ((0xFF & this.pickColor.get(0)) << 16)
            | ((0xFF & this.pickColor.get(1)) << 8)
            | (0xFF & this.pickColor.get(2));
    /** {@inheritDoc} */ 
    public Point getPickPoint()
        return pickPoint;