// ===========================================================
        // Methods
        // ===========================================================

        private int findConfigAttrib(EGL10 pEGL, EGLDisplay pEGLDisplay, EGLConfig pEGLConfig, int pAttribute, int pDefaultValue)
        {
            if (pEGL.EglGetConfigAttrib(pEGLDisplay, pEGLConfig, pAttribute, this.mValue))
            {
                return this.mValue[0];
            }
            return pDefaultValue;
        }
        public EGLConfig chooseConfig(EGL10 pEGL, EGLDisplay pEGLDisplay)
        {
            int[] num_config = new int[1];
            pEGL.EglChooseConfig(pEGLDisplay, this.mConfigSpec, null, 0, num_config);

            int numConfigs = num_config[0];

            if (numConfigs <= 0)
            {
                throw new IllegalArgumentException("No configs match configSpec");
            }

            EGLConfig[] configs = new EGLConfig[numConfigs];
            pEGL.EglChooseConfig(pEGLDisplay, this.mConfigSpec, configs, numConfigs, num_config);
            EGLConfig config = this.chooseConfig(pEGL, pEGLDisplay, configs);
            if (config == null)
            {
                throw new IllegalArgumentException("No config chosen");
            }
            return config;
        }
        // ===========================================================
        // Getter & Setter
        // ===========================================================

        // ===========================================================
        // Methods for/from SuperClass/Interfaces
        // ===========================================================

        public override EGLConfig chooseConfig(EGL10 pEGL, EGLDisplay pEGLDisplay, EGLConfig[] pEGLConfigs)
        {
            EGLConfig closestConfig = null;
            int closestDistance = 1000;
            //for(final EGLConfig config : pEGLConfigs) {
            foreach (EGLConfig config in pEGLConfigs)
            {
                int r = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglRedSize, 0);
                int g = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglGreenSize, 0);
                int b = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglBlueSize, 0);
                int a = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglAlphaSize, 0);
                int d = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglDepthSize, 0);
                int s = this.findConfigAttrib(pEGL, pEGLDisplay, config, EGL10Consts.EglStencilSize, 0);
                int distance = Math.Abs(r - this.mRedSize) + Math.Abs(g - this.mGreenSize) + Math.Abs(b - this.mBlueSize) + Math.Abs(a - this.mAlphaSize) + Math.Abs(d - this.mDepthSize) + Math.Abs(s - this.mStencilSize);
                if (distance < closestDistance)
                {
                    closestDistance = distance;
                    closestConfig = config;
                }
            }
            return closestConfig;
        }
        // ===========================================================
        // Getter & Setter
        // ===========================================================

        // ===========================================================
        // Methods for/from SuperClass/Interfaces
        // ===========================================================

        public abstract EGLConfig chooseConfig(EGL10 pEGL, EGLDisplay pEGLDisplay, EGLConfig[] pEGLConfigs);