Exemple #1
0
 // (Re)initializes the TextureShader and compiles the shader files
 protected void InitializeAndCompileTextureShader()
 {
     // Dispose the old shader resources if we want to reload the shader
     if (TextureShader != null)
     {
         TextureShader.Dispose();
         TextureShader = null; // Needed
     }
     TextureShader = new TextureShader();
     // Compile the texture shader
     using (var vertexShaderByteCode = ShaderBytecode.CompileFromFile(UISettings.TextureVertexShader, "TextureVertexShader", "vs_4_0"))
         using (var pixelShaderByteCode = ShaderBytecode.CompileFromFile(UISettings.TexturePixelShader, "TexturePixelShader", "ps_4_0"))
             TextureShader.Initialize(GraphicsDevice, vertexShaderByteCode, pixelShaderByteCode);
 }
Exemple #2
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                SaveUserSettings();
                foreach (var e in CameraHandler.Where(e => e != null))
                {
                    e.Stop();
                }
                foreach (var e in ImagePlane.Where(e => e != null))
                {
                    e.Dispose();
                }
                if (Keyboard != null)
                {
                    Keyboard.Dispose();
                }
                if (Renderer != null)
                {
                    Renderer.Dispose();
                }
                if (GraphicsDeviceManager != null)
                {
                    GraphicsDeviceManager.Dispose();
                }
                if (TextureShader != null)
                {
                    TextureShader.Dispose();
                }
            }
            _disposed = true;
            base.Dispose(disposing);
        }