public IEnumerable <Config> ChooseConfigs(Attribs <ConfigAttributes> attribs, int numberOfConfigsToReturn)
        {
            var configs = new IntPtr[numberOfConfigsToReturn];

            int numberOfConfigsFound;

            if (NativeEgl.eglChooseConfig(
                    this.display.DisplayPointer,
                    attribs.ToIntArray(),
                    configs,
                    configs.Length,
                    out numberOfConfigsFound) == NativeEgl.EGL_FALSE)
            {
                throw new PlatformGraphicsException("Could not choose configurations.", NativeEgl.eglGetError());
            }

            var result = new List <Config>();

            for (int i = 0; i < numberOfConfigsFound; i++)
            {
                result.Add(new Config(configs[i]));
            }

            return(result);
        }
Esempio n. 2
0
        public static int[] ToIntArray <TAttributeEnum>(this Attribs <TAttributeEnum> list)
        {
            if (list == null || list.Attributes.Count == 0)
            {
                return(null);
            }

            return(list.Attributes.ToArray());
        }
Esempio n. 3
0
        protected void Initialize()
        {
            var contextAttribs = new Attribs <int>();

            contextAttribs.Add(NativeEgl.EGL_CONTEXT_CLIENT_VERSION, (int)this.clientVersion);
            contextAttribs.AddEnd();

            this.ContextPointer = NativeEgl.eglCreateContext(
                this.displayPointer, this.configPointer, IntPtr.Zero, contextAttribs.ToIntArray());

            if (this.ContextPointer == IntPtr.Zero)
            {
                throw new PlatformGraphicsException("Failed to create context.", NativeEgl.eglGetError());
            }

            this.isInitialized = true;
        }