Beispiel #1
0
        /// <summary>
        /// This method runs on every frame
        /// </summary>
        private void GameLoop()
        {
            // Close program with esc
            if (InputDevice.Keyboard.IsKeyDown(VirtualKeyCode.ESCAPE))
            {
                renderForm.Dispose();
            }

            stopwatch.Restart();

            // Execute all Update methods
            StaticUpdater.ExecuteUpdateActions(lastDeltaTime);

            // Render on each frame
            renderDevice.Draw();

            foreach (GameObject gameObject in Scene.CurrentScene.GameObjects)
            {
                // Execute updates per-object
                foreach (IComponent component in gameObject.Components)
                {
                    component.Update(lastDeltaTime);
                }
            }

            // TODO create separate physics loop
            PhysicsHandler.Simulation.Timestep(lastDeltaTime);

            stopwatch.Stop();
            lastDeltaTime = (float)stopwatch.Elapsed.TotalSeconds;
            elapsedTime  += lastDeltaTime;
        }
Beispiel #2
0
        public void Dispose()
        {
            renderForm.Dispose();
            swapChain.Dispose();
            device.Dispose();
            renderer.Dispose();

            Console.Write(SharpDX.Diagnostics.ObjectTracker.ReportActiveObjects());
        }
Beispiel #3
0
 /// <summary>
 /// Dispose of the window and other things once the app is closing to prevent memory leaks.
 /// </summary>
 public static void Dispose()
 {
     RenderTarget.Dispose();
     SwapChain.Dispose();
     Device.Dispose();
     Form.Dispose();
 }
Beispiel #4
0
        private static bool InitializeSwapChain(out SwapChain swapChain)
        {
            var renderForm = new RenderForm();

            var swapChainDescription = new SwapChainDescription
            {
                BufferCount       = 1,
                Flags             = SwapChainFlags.None,
                IsWindowed        = true,
                ModeDescription   = new ModeDescription(100, 100, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                OutputHandle      = renderForm.Handle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput
            };

            Device.CreateWithSwapChain(
                DriverType.Hardware,
                DeviceCreationFlags.BgraSupport,
                swapChainDescription,
                out var device,
                out swapChain
                );

            if (swapChain == null)
            {
                return(false);
            }

            renderForm.Dispose();
            device?.Dispose(); // We don't need or want this
            return(true);
        }
 protected override void Shutdown()
 {
     sound.Shutdown();
     graphics.Shutdown();
     input.Shutdown();
     renderForm.Dispose();
 }
Beispiel #6
0
        //private void RenderFS()
        //{
        //    DeviceContext.InputAssembler.SetVertexBuffers(0, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
        //    DeviceContext.InputAssembler.SetIndexBuffer(null, (Format)0, 0);

        //    DeviceContext.VertexShader.Set(fsVertexShader);
        //    DeviceContext.PixelShader.Set(fishGlowPixelShader);

        //    DeviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

        //    DeviceContext.Draw(3, 0);
        //}

        public void Dispose()
        {
            swapChain.SetFullscreenState(false, null);

            //inputLayout.Dispose();
            //inputSignature.Dispose();

            WVP.Dispose();
            Sun.Dispose();

            decorRenderer.Dispose();

            fishGlow.Dispose();
            fishRenderer.Dispose();
            foodRenderer.Dispose();
            raysRenderer.Dispose();

            RasterizerStates.Dispose();
            DepthStencilStates.Dispose();
            BlendStates.Dispose();

            triangleVertexBuffer.Dispose();
            vertexShader.Dispose();
            pixelShader.Dispose();

            colorTarget.Dispose();

            renderTargetView.Dispose();
            swapChain.Dispose();
            Device.Dispose();
            DeviceContext.Dispose();
            renderForm.Dispose();
        }
Beispiel #7
0
 //IDisposable, mustn't forgot
 public void Dispose()
 {
     renderTargetView.Dispose();
     swapChain.Dispose();
     d3dDevice.Dispose();
     d3dDeviceContext.Dispose();
     renderForm.Dispose();
 }
        private void ShutdownWindows()
        {
            if (RenderForm != null)
            {
                RenderForm.Dispose();
            }

            RenderForm = null;
        }
 public void Dispose()
 {
     overlay.Dispose();
     aspectRatiosBufferManager.Dispose();
     uiBlendState.Dispose();
     backBufferView.Dispose();
     swapChain.Dispose();
     form.Dispose();
 }
 public void Dispose()
 {
     Keyboard.Unacquire();
     Mouse.Unacquire();
     graphicsContext.Dispose();
     graphicsDevice.Dispose();
     swapChain.Dispose();
     window.Dispose();
     factory.Dispose();
 }
Beispiel #11
0
 public void DisposeBase()
 {
     BackBufer.Dispose();
     RenderForm.Dispose();
     RenderTargetView.Dispose();
     GameDevice.Dispose();
     SwapChain.Dispose();
     DeviceContext.Dispose();
     //InputLayoutMain.Dispose();
     // InputSignature.Dispose();
 }
Beispiel #12
0
        private void Stop()
        {
            _renderForm?.Dispose();
            _renderForm = null;

            Window.Dispose();
            Window = null;

            Input         = null;
            Configuration = null;
        }
Beispiel #13
0
 /// <summary>
 ///     Performs application-defined tasks associated with freeing, releasing, or resetting
 ///     unmanaged resources.
 /// </summary>
 /// <param name="disposing">
 ///     True to release both managed and unmanaged resources; false to
 ///     release only unmanaged resources.
 /// </param>
 private void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             _renderForm.Dispose();
         }
         _disposed = true;
     }
 }
Beispiel #14
0
 public void Dispose()
 {
     renderForm.Dispose();
     swapChain.Dispose();
     d3dDevice.Dispose();
     d3dDeviceContext.Dispose();
     renderTargetView.Dispose();
     blendState.Dispose();
     depthStencilView.Dispose();
     depthStencilState.Dispose();
 }
Beispiel #15
0
 /// <summary>
 /// Dispose anything to do with the overlay form
 /// </summary>
 private static void DisposeOverlayComponents()
 {
     _renderTarget.Dispose();
     _renderForm.Dispose();
     _newDevice.ImmediateContext.ClearState();
     _newDevice.ImmediateContext.Flush();
     _newDevice.Dispose();
     _newSwapChain.Dispose();
     _fontFactory.Dispose();
     _font.Dispose();
 }
Beispiel #16
0
        public void Dispose()
        {
            renderView.Dispose();
            backBuffer.Dispose();
            device.ImmediateContext.ClearState();
            device.ImmediateContext.Flush();
            device.Dispose();
            swapChain.Dispose();
            factory.Dispose();

            form.Dispose();
        }
Beispiel #17
0
 // Clean up DX
 public void CleanUpDX()
 {
     renderView.Dispose();
     backBuffer.Dispose();
     devCon.ClearState();
     devCon.Flush();
     dev.Dispose();
     devCon.Dispose();
     swapChain.Dispose();
     factory.Dispose();
     form.Dispose();
 }
Beispiel #18
0
 public void Dispose()
 {
     RenderForm.Dispose();
     RenderTarget2D.Dispose();
     Factory2D.Dispose();
     Surface.Dispose();
     SwapChain.Dispose();
     Device.ImmediateContext.ClearState();
     Device.ImmediateContext.Flush();
     Device.Dispose();
     _gameRender.Dispose();
 }
Beispiel #19
0
 private void OnClosing(object sender, CancelEventArgs e)
 {
     this.Dispose();
     _renderForm.Dispose();
     _d2DRenderTarget.Dispose();
     _d2DFactory.Dispose();
     _textFormat.Dispose();
     _swapChain.Dispose();
     _target.Dispose();
     _targetView.Dispose();
     _device.Dispose();
 }
Beispiel #20
0
 public void Dispose()
 {
     inputLayout.Dispose();
     inputSignature.Dispose();
     triangleVertexBuffer.Dispose();
     vertexShader.Dispose();
     pixelShader.Dispose();
     renderTargetView.Dispose();
     swapChain.Dispose();
     d3dDevice.Dispose();
     d3dDeviceContext.Dispose();
     renderForm.Dispose();
 }
Beispiel #21
0
 public void Dispose()
 {
     _inputLayout.Dispose();
     _inputSignature.Dispose();
     _triangleVertexBuffer.Dispose();
     _vertexShader.Dispose();
     _pixelShader.Dispose();
     _renderTargetView.Dispose();
     _swapChain.Dispose();
     _d3DDevice.Dispose();
     _d3DDeviceContext.Dispose();
     _renderForm.Dispose();
 }
 public void Dispose()
 {
     mainCharacterService.Dispose();
     levelService.Dispose();
     audioDevice.Dispose();
     textures.Dispose();
     samplerStates.Dispose();
     inputController.Dispose();
     directX2DGraphics.Dispose();
     renderer.Dispose();
     directX3DGraphics.Dispose();
     renderForm.Dispose();
 }
Beispiel #23
0
 public void Dispose()
 {
     _renderForm?.Dispose();
     _swapChain?.Dispose();
     _device?.Dispose();
     _deviceContext?.Dispose();
     _renderTargetView?.Dispose();
     _triangleVertexBuffer?.Dispose();
     _vertexShader?.Dispose();
     _pixelShader?.Dispose();
     _inputSignature?.Dispose();
     _inputLayout?.Dispose();
 }
Beispiel #24
0
 /// <summary>
 /// Called on program close.
 /// Disposes of variables taking up resources.
 /// </summary>
 public void Dispose()
 {
     swapChain.Dispose();
     device.Dispose();
     deviceContext.Dispose();
     renderForm.Dispose();
     raymarchShaderBuffer.Dispose();
     noiseTextureBuffer.Dispose();
     foreach (var buffer in primitivesBuffer)
     {
         buffer.Dispose();
     }
 }
Beispiel #25
0
        protected virtual void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                    _dxForm.Dispose();
                }

                _graphics.Dispose();
                IsDisposed = true;
            }
        }
Beispiel #26
0
        public void Dispose()
        {
            inputLayout.Dispose();
            inputSignature.Dispose();
            screenVertexBuffer.Dispose();
            vertexShader.Dispose();
            pixelShader.Dispose();

            renderTargetView.Dispose();
            swapChain.Dispose();
            d3dDevice.Dispose();
            d3dDeviceContext.Dispose();
            renderForm.Dispose();

            UnhookWindowsHookEx(_hookID);
        }
Beispiel #27
0
        public void EnterRunloop()
        {
            RenderLoop.Run(m_windowForm, () =>
            {
                EditorModuleManager.Instance.Update();

                EditorGraphicsManager.Instance.Render(() =>
                {
                });
            });

            EditorModuleManager.Instance.Dispose();
            EditorGraphicsManager.Instance.Dispose();

            m_windowForm.Dispose();
        }
Beispiel #28
0
        public void Dispose()
        {
            d2dContext.Target = null;
            bitmap.Dispose();
            d2dContext.Dispose();
            d2dDevice.Dispose();
            d2dFactory.Dispose();

            dxgiSurface.Dispose();
            swapChain.Dispose();
            dxgiFactory.Dispose();
            dxgiDevice.Dispose();

            d3dDevice.Dispose();

            form.Dispose();
        }
Beispiel #29
0
        public void Dispose()
        {
            // scene stuff
            StarSystem.ActiveSystem.Dispose();
            skybox.Dispose();
            ControlPanel.Dispose();

            Shaders.Dispose();
            Resources.Dispose();

            // other stuff
            keyboard.Dispose();
            mouse.Dispose();

            renderer.Dispose();
            renderForm.Dispose();
        }
        public void Dispose()
        {
            WaitForPrevFrame();

            swapChain.SetFullscreenState(false, null);

            eventHandle.Close();

            Utilities.Dispose(ref commandList);

            Utilities.Dispose(ref descriptorHeap);
            Utilities.Dispose(ref renderTarget);
            Utilities.Dispose(ref commandListAllocator);
            Utilities.Dispose(ref commandQueue);
            Utilities.Dispose(ref device);
            Utilities.Dispose(ref swapChain);

            window?.Dispose();
        }