Example #1
0
        public void Present()
        {
                        #if WIN32
            WGL.SwapBuffers(dc);
                        #endif

                        #if RPI
            EGL.SwapBuffers(dc, surface);
                        #elif LINUX
            /*unsafe
             * {
             *      if (vSync)
             *      {
             *              uint retraceCount = 0;
             *              GLX.GetVideoSyncSGI(&retraceCount);
             *              GLX.WaitVideoSyncSGI(2, ((int)retraceCount+1)%2, &retraceCount);
             *      }
             * }*/
            GLX.SwapBuffers(dc, handle);
                        #endif

                        #if OSX
            CGL.FlushDrawable(ctx);
                        #endif

                        #if NaCl
            GL.ColorMask(false, false, false, true);
            ClearColor(0, 0, 0, 1);
            GL.ColorMask(true, true, true, true);
                        #endif
        }
Example #2
0
        public void Update()
        {
                        #if !RPI
            var frame = application.FrameSize;
            if (frame.Width != 0 && frame.Height != 0)
            {
                BackBufferSize = frame;
            }
                        #endif

                        #if WIN32
            WGL.MakeCurrent(dc, ctx);
                        #endif

                        #if RPI
            EGL.MakeCurrent(dc, surface, surface, ctx);
                        #elif LINUX
            GLX.MakeCurrent(dc, handle, ctx);
                        #endif

                        #if OSX
            CGL.SetCurrentContext(ctx);
                        #endif

                        #if NaCl
            PPAPI.SetCurrentContextPPAPI(context);
                        #endif

                        #if DEBUG
                        #if RPI
            checkForEGLError();
                        #endif
            checkForError();
                        #endif
        }
Example #3
0
        public void DisableContext()
        {
                        #if WIN32
            WGL.MakeCurrent(dc, IntPtr.Zero);
                        #endif

                        #if RPI
            EGL.MakeCurrent(dc, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
                        #elif LINUX
            GLX.MakeCurrent(dc, IntPtr.Zero, IntPtr.Zero);
                        #endif

                        #if OSX
            CGL.SetCurrentContext(IntPtr.Zero);
                        #endif
        }
Example #4
0
        public unsafe override void Dispose()
        {
            if (disposed)
            {
                return;
            }
            disposed = true;
            disposeChilderen();

                        #if NaCl
            PPAPI.StopSwapBufferLoop();
                        #endif

            if (dc != IntPtr.Zero)
            {
                DisableContext();
            }

                        #if WIN32
            if (dc != IntPtr.Zero)
            {
                if (ctx != IntPtr.Zero)
                {
                    WGL.DeleteContext(ctx);
                    ctx = IntPtr.Zero;
                }

                if (handle != IntPtr.Zero)
                {
                    WGL.ReleaseDC(handle, dc);
                    handle = IntPtr.Zero;
                }

                dc = IntPtr.Zero;
            }
                        #endif

                        #if RPI
            if (dc != IntPtr.Zero)
            {
                if (surface != IntPtr.Zero)
                {
                    EGL.DestroySurface(dc, surface);
                }
                if (ctx != IntPtr.Zero)
                {
                    EGL.DestroyContext(dc, ctx);
                }
                EGL.Terminate(dc);
                dc = IntPtr.Zero;
            }

            RaspberryPi.bcm_host_deinit();
            windowHandle.Free();
                        #elif LINUX
            if (dc != IntPtr.Zero)
            {
                if (ctx != IntPtr.Zero)
                {
                    GLX.DestroyContext(dc, ctx);
                    ctx = IntPtr.Zero;
                }

                X11.XCloseDisplay(dc);
                dc = IntPtr.Zero;
            }
                        #endif

                        #if OSX
            if (dc != IntPtr.Zero)
            {
                if (ctx != IntPtr.Zero)
                {
                    CGL.DestroyContext(ctx);
                    ctx = IntPtr.Zero;
                }

                CGL.ReleaseAllDisplays();
                dc = IntPtr.Zero;
            }
                        #endif
            base.Dispose();
        }