Example #1
0
        public static EglConfig[] ChooseConfigs(EglDisplay display, EglConfigAttributes attr)
        {
            var attribs = new[]
            {
                (int)EglConfigAttribute.RedSize, attr.RedBits,
                (int)EglConfigAttribute.GreenSize, attr.GreenBits,
                (int)EglConfigAttribute.BlueSize, attr.BlueBits,
                (int)EglConfigAttribute.AlphaSize, attr.AlphaBits,
                //
                (int)EglConfigAttribute.DepthSize, attr.DepthBits,
                (int)EglConfigAttribute.StencilSize, attr.StencilBits,
                //
                (int)EglConfigAttribute.Samples, attr.Samples,
                //
                (int)EglConfigAttribute.RenderableType, (int)attr.RenderableType,
                //
                (int)EglConfigAttribute.SurfaceType, (int)attr.SurfaceType,
                EGL_NONE
            };

            var configAddrs = new IntPtr[64];

            if (eglChooseConfig(display.Address, attribs, configAddrs, configAddrs.Length, out var numConfigs))
            {
                var configs = new EglConfig[numConfigs];
                for (var i = 0; i < numConfigs; i++)
                {
                    var address = configAddrs[i];
                    if (_configs.ContainsKey(address))
                    {
                        configs[i] = _configs[address];
                    }
                    else
                    {
                        configs[i]        = new EglConfig(display, address);
                        _configs[address] = configs[i];
                    }
                }

                return(configs);
            }
            else
            {
                throw new EglException("Unable to choose EGL configurations");
            }
        }
Example #2
0
        internal EglConfig(EglDisplay display, IntPtr address)
        {
            Address = address;
            Display = display;

            //
            Attributes = new EglConfigAttributes
            {
                //
                RedBits   = GetAttribute(EglConfigAttribute.RedSize),
                BlueBits  = GetAttribute(EglConfigAttribute.BlueSize),
                GreenBits = GetAttribute(EglConfigAttribute.GreenSize),
                AlphaBits = GetAttribute(EglConfigAttribute.AlphaSize),
                //
                DepthBits   = GetAttribute(EglConfigAttribute.DepthSize),
                StencilBits = GetAttribute(EglConfigAttribute.StencilSize),
                //
                Samples = GetAttribute(EglConfigAttribute.Samples),
                //
                RenderableType = (EglRenderableType)GetAttribute(EglConfigAttribute.RenderableType),
            };
        }
Example #3
0
 public static EglConfig ChooseConfig(EglDisplay display, EglConfigAttributes attr)
 {
     return(ChooseConfigs(display, attr).FirstOrDefault());
 }
Example #4
0
 public static EglConfig[] ChooseConfigs(EglConfigAttributes attr)
 {
     return(ChooseConfigs(GetDisplay(IntPtr.Zero), attr));
 }
Example #5
0
 public static EglContext CreateContext(EglConfigAttributes attr, int contextVersion = 3, EglContext shareContext = null)
 {
     return(CreateContext(GetDisplay(IntPtr.Zero), ChooseConfig(attr), contextVersion, shareContext));
 }