Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 protected void MakeCurrent(IntPtr draw, IntPtr read)
 {
     if (NativeEgl.eglMakeCurrent(this.displayPointer, draw, read, this.ContextPointer) == NativeEgl.EGL_FALSE)
     {
         throw new PlatformGraphicsException(
                   "Could not set rendering context to current.", NativeEgl.eglGetError());
     }
 }
Ejemplo n.º 3
0
        protected override void Dispose(bool disposing)
        {
            if (this.isInitialized)
            {
                NativeEgl.eglDestroyContext(this.displayPointer, this.ContextPointer);
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 4
0
        protected void Initialize()
        {
            // get display
            this.DisplayPointer = NativeEgl.eglGetDisplay(this.DeviceContext);

            if (this.DisplayPointer == IntPtr.Zero)
            {
                throw new PlatformGraphicsException("Could not get display", NativeEgl.eglGetError());
            }
        }
Ejemplo n.º 5
0
        protected override void Dispose(bool disposing)
        {
            if (this.isInitialized)
            {
                if (NativeEgl.eglDestroySurface(this.displayPointer, this.SurfacePointer) == NativeEgl.EGL_FALSE)
                {
                    var errorCode = NativeEgl.eglGetError();
                    throw new PlatformGraphicsException("Could not destroy surface.", errorCode);
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 6
0
        protected void Initialize()
        {
            int major, minor;

            if (NativeEgl.eglInitialize(this.display.DisplayPointer, out major, out minor) == NativeEgl.EGL_FALSE)
            {
                var errorCode = NativeEgl.eglGetError();
                throw new PlatformGraphicsException("Could not intitialize egl display connection.", errorCode);
            }

            this.Version       = new Version(major, minor);
            this.isInitialized = true;
        }
Ejemplo n.º 7
0
        protected override void Dispose(bool disposing)
        {
            if (this.isInitialized)
            {
                NativeEgl.eglMakeCurrent(this.display.DisplayPointer, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);

                if (NativeEgl.eglTerminate(this.display.DisplayPointer) == NativeEgl.EGL_FALSE)
                {
                    throw new PlatformGraphicsException(
                              "Failed to terminate egl display connection", NativeEgl.eglGetError());
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 8
0
        protected void Initialize()
        {
            this.SurfacePointer = NativeEgl.eglCreateWindowSurface(
                this.displayPointer, this.configPointer, this.WindowHandle, null);

            if (this.SurfacePointer == IntPtr.Zero)
            {
                var errorCode = NativeEgl.eglGetError();

                var errorMessage = string.Format(
                    "Could not create window surface. Error code {0}", errorCode.ToString("X"));
                throw new PlatformGraphicsException(errorMessage, errorCode);
            }

            this.isInitialized = true;
        }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
0
 public void SwapBuffers()
 {
     NativeEgl.eglSwapBuffers(this.displayPointer, this.SurfacePointer);
 }
Ejemplo n.º 11
0
 public void BindApi(Api api)
 {
     NativeEgl.eglBindAPI((uint)api);
 }