Ejemplo n.º 1
0
        public static EglConfig[] GetConfigs(EglDisplay display)
        {
            var configAddrs = new IntPtr[64];

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

                return(configs);
            }
            else
            {
                throw new EglException("Unable to get all EGL configurations");
            }
        }
Ejemplo n.º 2
0
        public static EglContext CreateContext(EglDisplay display, EglConfig config, int contextVersion = 3, EglContext shareContext = null)
        {
            var attribs        = new[] { EGL_CONTEXT_CLIENT_VERSION, contextVersion, EGL_NONE };
            var contextAddress = eglCreateContext(display.Address, config.Address, shareContext?.Address ?? IntPtr.Zero, attribs);

            if (contextAddress == NO_CONTEXT)
            {
                throw new EglException("Unable to create EGL context");
            }

            var context = new EglContext(config, contextAddress);

            return(_contexts[contextAddress] = context);
        }
Ejemplo n.º 3
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");
            }
        }
Ejemplo n.º 4
0
 public static EglContext CreateContext(EglConfig config, int contextVersion = 3, EglContext shareContext = null)
 {
     return(CreateContext(GetDisplay(IntPtr.Zero), config, contextVersion, shareContext));
 }
Ejemplo n.º 5
0
 internal static bool GetConfigAttrib(EglDisplay display, EglConfig config, EglConfigAttribute attribute, out int value)
 {
     return(eglGetConfigAttrib(display.Address, config.Address, attribute, out value));
 }
Ejemplo n.º 6
0
 internal EglContext(EglConfig config, IntPtr address)
 {
     Config  = config;
     Address = address;
 }