示例#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");
            }
        }
示例#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),
            };
        }
示例#3
0
 public static EglConfig ChooseConfig(EglDisplay display, EglConfigAttributes attr)
 {
     return(ChooseConfigs(display, attr).FirstOrDefault());
 }
示例#4
0
 public static EglConfig[] ChooseConfigs(EglConfigAttributes attr)
 {
     return(ChooseConfigs(GetDisplay(IntPtr.Zero), attr));
 }
示例#5
0
 public static EglContext CreateContext(EglConfigAttributes attr, int contextVersion = 3, EglContext shareContext = null)
 {
     return(CreateContext(GetDisplay(IntPtr.Zero), ChooseConfig(attr), contextVersion, shareContext));
 }