Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Renderer"/> class.
 /// </summary>
 public Renderer()
 {
     Contract.Ensures(dx != null);
     dx = new D3DHelper(640, 480);
     LoadShaders();
     LoadMeshes();
     Sound.Audio sound = new Sound.Audio();
     Wave wave = new Wave("Sound/Music/M.wav");
     sound.AddSound(wave);
     CreateMatrices();
     fontEngine = new FontEngine(dx.D3DDevice, "font.fnt", "font.png", dx.WindowWidth, dx.WindowHeight);
     input = new Pigment.Engine.Input.Input();
     dx.Context.Flush();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            //Contract.Ensures(bumpShader == null, "lightShader must be disposed by this function.");
            Contract.Ensures(colourTextureShader == null, "colourTextureShader must be disposed by this function.");
            Contract.Ensures(bitmap == null, "bitmap must be disposed by this function.");
            Contract.Ensures(fontEngine == null, "fontEngine must be disposed by this function.");
            Contract.Ensures(dx == null, "dx must be disposed by this function.");

            if (disposing)
            {
                if (fogShader != null)
                {
                    fogShader.Dispose();
                    fogShader = null;
                }
                if (colourTextureShader != null)
                {
                    colourTextureShader.Dispose();
                    colourTextureShader = null;
                }
                if(bitmap != null)
                {
                    bitmap.Dispose();
                    bitmap = null;
                }
                if(fontEngine != null)
                {
                    fontEngine.Dispose();
                    fontEngine = null;
                }
                if (dx != null)
                {
                    dx.Dispose();
                    dx = null;
                }
            }
        }