예제 #1
0
        protected virtual void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                if (disposing)
                {
                    // We're about to dispose, notify the application.
                    if (Disposing != null)
                    {
                        Disposing(this, EventArgs.Empty);
                    }

                    /* Dispose of all remaining graphics resources before
                     * disposing of the GraphicsDevice.
                     */
                    lock (resourcesLock)
                    {
                        foreach (WeakReference resource in resources.ToArray())
                        {
                            object target = resource.Target;
                            if (target != null)
                            {
                                (target as IDisposable).Dispose();
                            }
                        }
                        resources.Clear();
                    }

                    // Dispose of the GL Device/Context
                    GLDevice.Dispose();

#if WIIU_GAMEPAD
                    if (wiiuStream != IntPtr.Zero)
                    {
                        DRC.drc_stop_streamer(wiiuStream);
                        DRC.drc_delete_streamer(wiiuStream);
                        wiiuStream = IntPtr.Zero;
                    }
#endif
                }

                IsDisposed = true;
            }
        }
예제 #2
0
        protected override void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                if (Window != null)
                {
                    /* Some window managers might try to minimize the window as we're
                     * destroying it. This looks pretty stupid and could cause problems,
                     * so set this hint right before we destroy everything.
                     * -flibit
                     */
                    SDL.SDL_SetHintWithPriority(
                        SDL.SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS,
                        "0",
                        SDL.SDL_HintPriority.SDL_HINT_OVERRIDE
                        );

                    SDL.SDL_DestroyWindow(Window.Handle);

                    Window = null;
                }

                if (OpenALDevice.Instance != null)
                {
                    OpenALDevice.Instance.Dispose();
                }

#if WIIU_GAMEPAD
                if (wiiuStream != IntPtr.Zero)
                {
                    DRC.drc_stop_streamer(wiiuStream);
                    DRC.drc_delete_streamer(wiiuStream);
                    wiiuStream = IntPtr.Zero;
                }
#endif

                // This _should_ be the last SDL call we make...
                SDL.SDL_Quit();
            }

            base.Dispose(disposing);
        }