Example #1
0
        public bool Parse()
        {
            Exception e    = null;
            Thread    thrd = new Thread(new ThreadStart(delegate
            {
                try{
                    CreateContext();

                    CreateProgram();

                    if (Compile())
                    {
                        Attach();
                        if (Link())
                        {
                            LoadAttributes();
                            LoadUniforms();
                        }
                    }
                }catch (Exception ex)
                {
                    e = ex;
                }
            }));

            thrd.Start();
            thrd.Join();
            window.Dispose();
            context.Dispose();
            if (e != null)
            {
                throw e;
            }
            return(true);
        }
Example #2
0
        public void Dispose()
        {
            if (!disposed)
            {
                //Wait for all rendering to stop before we start disposing of resources
                logicalDevice.WaitIdle();

                //Dispose of the synchronization objects
                imageAvailableSemaphore.Dispose();
                renderFinishedSemaphore.Dispose();
                waitFences.DisposeAll();

                //Dispose of the scene resources
                scene?.Dispose();

                //Dispose of the swapchain
                swapchainTextures.DisposeAll();
                swapchain.Dispose();

                //Dispose of command-pool (will automatically also dispose of the commandbuffers that
                //where recreated from it)
                commandPool.Dispose();

                //Dispose the Vulkan device and dispose of the os window
                logicalDevice.Dispose();
                nativeWindow.Dispose();
                disposed = true;
            }
        }
Example #3
0
        public void AfterTest(ITest details)
        {
            Console.WriteLine("----- Beginning Duality environment teardown -----");

            // Remove NUnit Console logs
            Log.RemoveGlobalOutput(_consoleLogOutput);
            _consoleLogOutput = null;

            if (_dummyWindow != null)
            {
                ContentProvider.ClearContent();
                ContentProvider.DisposeDefaultContent();
                _dummyWindow.Dispose();
                _dummyWindow = null;
            }

            /*// Save local testing memory. As this uses Duality serializers,
             * // it needs to be done before terminating Duality.
             * if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Passed && !System.Diagnostics.Debugger.IsAttached)
             * {
             *      Serializer.WriteObject(TestHelper.LocalTestMemory, TestHelper.LocalTestMemoryFilePath, typeof(XmlSerializer));
             * }*/

            try
            {
                DualityApp.Terminate();
            }
            catch (BackendException)
            {
            }

            Environment.CurrentDirectory = _oldEnvDir;

            Console.WriteLine("----- Duality environment teardown complete -----");
        }
Example #4
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    // Dispose/release managed objects
                    window.Dispose();
                }
                // The window handle no longer exists
                _windowHandle = IntPtr.Zero;

                disposed = true;
            }
        }
Example #5
0
        /// <summary>
        /// Releases all non-managed resources belonging to this NativeWindow.
        /// </summary>
        public virtual void Dispose()
        {
            if (!IsDisposed)
            {
                if ((options & GameWindowFlags.Fullscreen) != 0)
                {
                    if (device != null)
                    {
                        device.RestoreResolution();
                    }
                }
                implementation.Dispose();
                GC.SuppressFinalize(this);

                IsDisposed = true;
            }
        }
Example #6
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_config != null)
                {
                    Toml.WriteFile(_config, "config.toml", _tomlSettings);
                    _config = null;
                }

                _waveIn?.StopRecording();
                _waveIn?.Dispose();
                _waveIn = null;

                _speechRecognizer?.Dispose();
                _speechRecognizer = null;

                _skFont?.Dispose();
                _skFont = null;

                _skStrokePaint?.Dispose();
                _skStrokePaint = null;

                _skFillPaint?.Dispose();
                _skFillPaint = null;

                _skScreenSurface?.Dispose();
                _skScreenSurface = null;

                _skScreenRenderTarget?.Dispose();
                _skScreenRenderTarget = null;

                _skContext?.Dispose();
                _skContext = null;

                _skInterface?.Dispose();
                _skInterface = null;

                _tkContext?.Dispose();
                _tkContext = null;

                _tkWindow?.Dispose();
                _tkWindow = null;
            }
        }
Example #7
0
 /// <summary>
 ///     Destroys the hosted window. Derived classes should override
 ///     this method to destroy the hosted window.
 /// </summary>
 /// <param name="child">
 ///     The platform handle of the child.
 /// </param>
 protected override void Destroy(Avalonia.Platform.IPlatformHandle child)
 {
     _window.Dispose();
 }
Example #8
0
            internal void Dispose()
            {
                if (m_window == null)
                {
                    return;
                }

                try
                {
                    if (!m_context.IsDisposed && !m_context.IsCurrent && !m_window.Exists)
                    {
                        return;
                    }

                    m_context.MakeCurrent(m_window.WindowInfo);

                    ErrorCode err = GL.GetError();
                    if (err != ErrorCode.NoError)
                    {
                        MyLog.WARNING.WriteLine(Owner.Name + ": OpenGL error detected when disposing stuff, code: " + err);
                    }

                    // delete textures
                    if (m_textureHandles != null)
                    {
                        foreach (int handle in m_textureHandles.Values)
                        {
                            int h = handle;
                            GL.DeleteTextures(1, ref h);
                        }

                        m_textureHandles.Clear();
                    }

                    if (m_renderTextureHandle != 0)
                    {
                        GL.DeleteTextures(1, ref m_renderTextureHandle);
                        m_renderTextureHandle = 0;
                    }
                    if (m_scoreTextHandle != 0)
                    {
                        GL.DeleteTextures(1, ref m_scoreTextHandle);
                        m_scoreTextHandle = 0;
                    }

                    // delete FBO
                    if (m_fboHandle != 0)
                    {
                        GL.DeleteFramebuffers(1, ref m_fboHandle);
                        m_fboHandle = 0;
                    }

                    // delete PBO
                    if (m_sharedBufferHandle != 0)
                    {
                        GL.DeleteBuffers(1, ref m_sharedBufferHandle);
                        m_sharedBufferHandle = 0;
                    }

                    // delete CUDA <-> GL interop
                    if (m_renderResource != null)
                    {
                        m_renderResource.Dispose();
                        m_renderResource = null;
                    }

                    if (m_context != null)
                    {
                        m_context.Dispose();
                        m_context = null;
                    }
                    if (m_window != null)
                    {
                        m_window.Dispose();
                        m_window = null;
                    }
                }
                catch (AccessViolationException e)
                {
                    MyLog.WARNING.WriteLine(Owner.Name + ": Failed when disposing OpenGL stuff. Cautious progress advised. Error: " + e.Message);
                }
                catch (Exception e)
                {
                    MyLog.WARNING.WriteLine(Owner.Name + ": Failed when disposing OpenGL. Error: " + e.Message);
                }
            }
 public override void Dispose()
 {
     GraphicsDevice.Dispose();
     window.Dispose();
 }
Example #10
0
 public void Cleanup()
 {
     _rtt.Dispose();
     _context.Dispose();
     _window.Dispose();
 }