Esempio n. 1
0
 private void CreateEffect(GraphicsDevice graphicsDevice)
 {
     _effect?.Dispose();
     _effect = new BasicEffect(graphicsDevice)
     {
         VertexColorEnabled = true,
         TextureEnabled     = true,
     };
 }
Esempio n. 2
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         BasicEffect?.Dispose();
         Graphics?.Dispose();
     }
 }
Esempio n. 3
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing && !_isDisposed)
     {
         _basicEffect?.Dispose();
         _isDisposed = true;
     }
 }
Esempio n. 4
0
 void Dispose(bool isDisposing)
 {
     if (isDisposing && !IsDisposed)
     {
         _basicEffect?.Dispose();
         IsDisposed = true;
     }
 }
Esempio n. 5
0
        /// <summary>
        ///     Frees resources used by this object.
        /// </summary>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            _vertexBuffer?.Dispose();
            _indexBuffer?.Dispose();
            _basicEffect?.Dispose();
        }
Esempio n. 6
0
        public void EffectPassShouldSetTextureEvenIfNull()
        {
            var texture = new Texture2D(game.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);

            game.GraphicsDevice.Textures[0] = texture;

            var effect = new BasicEffect(game.GraphicsDevice);

            effect.TextureEnabled = true;
            effect.Texture        = null;

            Assert.That(game.GraphicsDevice.Textures[0], Is.SameAs(texture));

            var effectPass = effect.CurrentTechnique.Passes[0];

            effectPass.Apply();

            Assert.That(game.GraphicsDevice.Textures[0], Is.Null);

            texture.Dispose();
            effect.Dispose();
        }
        public void TestDrawTextWithCustomEffect()
        {
            TestText    test   = new TestText();
            BasicEffect effect = new BasicEffect(
                this.mockedGraphicsDeviceService.GraphicsDevice
#if XNA_3
                , null
#endif
                );

            try {
                this.textBatch.Begin();
                try {
                    this.textBatch.DrawText(test, effect);
                }
                finally {
                    this.textBatch.End();
                }
            }
            finally {
                effect.Dispose();
            }
        }
Esempio n. 8
0
        void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                UnloadContent();

                if (BasicEffect != null)
                {
                    BasicEffect.Dispose();
                }

                foreach (var sound in soundMap.Values)
                {
                    sound.Dispose();
                }
            }

            disposed = true;
        }
Esempio n. 9
0
File: Game.cs Progetto: tuxPM/FNA
        protected virtual void EndRun()
        {
#if BASIC_PROFILER
            profileEffect.Dispose();
#endif
        }
Esempio n. 10
0
 public void Dispose()
 {
     _basicEffect?.Dispose();
 }
Esempio n. 11
0
 public void Dispose()
 {
     _effect?.Dispose();
     GC.SuppressFinalize(this);
 }
Esempio n. 12
0
        public void DrawUserIndexedPrimitivesParameterValidation()
        {
            var vertexDataNonEmpty = new[]
            {
                new VertexPositionColorTexture(Vector3.Zero, Color.White, Vector2.Zero),
                new VertexPositionColorTexture(Vector3.Zero, Color.White, Vector2.Zero),
                new VertexPositionColorTexture(Vector3.Zero, Color.White, Vector2.Zero)
            };
            var vertexDataEmpty = new VertexPositionColorTexture[0];

            var indexDataNonEmpty = new short[] { 0, 1, 2 };
            var indexDataEmpty    = new short[0];

            // No vertex shader or pixel shader.
            Assert.Throws <InvalidOperationException>(() => gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexDataNonEmpty, 0, 3, indexDataNonEmpty, 0, 1));

            var effect = new BasicEffect(gd);

            effect.CurrentTechnique.Passes[0].Apply();

            // Success - "normal" usage.
            Assert.DoesNotThrow(() => gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexDataNonEmpty, 0, 3, indexDataNonEmpty, 0, 1));

            // Failure cases.

            // Null vertexData.
            DoDrawUserIndexedPrimitivesAsserts(null, 0, 3, indexDataNonEmpty, 0, 1, d => Assert.Throws <ArgumentNullException>(d));

            // Empty vertexData.
            DoDrawUserIndexedPrimitivesAsserts(vertexDataEmpty, 0, 3, indexDataNonEmpty, 0, 1, d => Assert.Throws <ArgumentNullException>(d));

            // vertexOffset too small / large.
            DoDrawUserIndexedPrimitivesAsserts(vertexDataNonEmpty, -1, 3, indexDataNonEmpty, 0, 1, d => Assert.Throws <ArgumentOutOfRangeException>(d));
            DoDrawUserIndexedPrimitivesAsserts(vertexDataNonEmpty, 3, 3, indexDataNonEmpty, 0, 1, d => Assert.Throws <ArgumentOutOfRangeException>(d));

            // numVertices too small / large.
            DoDrawUserIndexedPrimitivesAsserts(vertexDataNonEmpty, 0, 0, indexDataNonEmpty, 0, 1, d => Assert.Throws <ArgumentOutOfRangeException>(d));
            DoDrawUserIndexedPrimitivesAsserts(vertexDataNonEmpty, 0, 4, indexDataNonEmpty, 0, 1, d => Assert.Throws <ArgumentOutOfRangeException>(d));

            // vertexOffset + numVertices too large.
            DoDrawUserIndexedPrimitivesAsserts(vertexDataNonEmpty, 1, 3, indexDataNonEmpty, 0, 1, d => Assert.Throws <ArgumentOutOfRangeException>(d));

            // Null indexData.
            DoDrawUserIndexedPrimitivesAsserts(vertexDataNonEmpty, 0, 3, null, 0, 1, d => Assert.Throws <ArgumentNullException>(d));

            // Empty indexData.
            DoDrawUserIndexedPrimitivesAsserts(vertexDataNonEmpty, 0, 3, indexDataEmpty, 0, 1, d => Assert.Throws <ArgumentNullException>(d));

            // indexOffset too small / large.
            DoDrawUserIndexedPrimitivesAsserts(vertexDataNonEmpty, 0, 3, indexDataNonEmpty, -1, 1, d => Assert.Throws <ArgumentOutOfRangeException>(d));
            DoDrawUserIndexedPrimitivesAsserts(vertexDataNonEmpty, 0, 3, indexDataNonEmpty, 1, 1, d => Assert.Throws <ArgumentOutOfRangeException>(d));

            // primitiveCount too small / large.
            DoDrawUserIndexedPrimitivesAsserts(vertexDataNonEmpty, 0, 3, indexDataNonEmpty, 0, -1, d => Assert.Throws <ArgumentOutOfRangeException>(d));
            DoDrawUserIndexedPrimitivesAsserts(vertexDataNonEmpty, 0, 3, indexDataNonEmpty, 0, 0, d => Assert.Throws <ArgumentOutOfRangeException>(d));
            DoDrawUserIndexedPrimitivesAsserts(vertexDataNonEmpty, 0, 3, indexDataNonEmpty, 0, 2, d => Assert.Throws <ArgumentOutOfRangeException>(d));

            // indexOffset + primitiveCount too large.
            DoDrawUserIndexedPrimitivesAsserts(vertexDataNonEmpty, 0, 3, indexDataNonEmpty, 1, 1, d => Assert.Throws <ArgumentOutOfRangeException>(d));

            // Null vertexDeclaration.
            Assert.Throws <ArgumentNullException>(() => gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexDataNonEmpty, 0, 3, indexDataNonEmpty, 0, 1, null));

            // Smaller vertex stride in VertexDeclaration than in actual vertices.

            // XNA is inconsistent; in DrawUserIndexedPrimitives, it allows vertexStride to be less than the actual size of the data,
            // but in VertexBuffer.SetData, XNA requires vertexStride to greater than or equal to the actual size of the data.
            // Since we use a DynamicVertexBuffer to implement DrawUserIndexedPrimitives, we use the same validation in both places.
            // The same applies to DrawUserPrimitives.
#if XNA
            Assert.DoesNotThrow(() => gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexDataNonEmpty, 0, 3, indexDataNonEmpty, 0, 1, VertexPositionColor.VertexDeclaration));
            Assert.DoesNotThrow(() => gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexDataNonEmpty, 0, 3, indexDataNonEmpty.Select(x => (int)x).ToArray(), 0, 1, VertexPositionColor.VertexDeclaration));
#else
            Assert.Throws <ArgumentOutOfRangeException>(() => gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexDataNonEmpty, 0, 3, indexDataNonEmpty, 0, 1, VertexPositionColor.VertexDeclaration));
            Assert.Throws <ArgumentOutOfRangeException>(() => gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertexDataNonEmpty, 0, 3, indexDataNonEmpty.Select(x => (int)x).ToArray(), 0, 1, VertexPositionColor.VertexDeclaration));
#endif
            effect.Dispose();
        }
Esempio n. 13
0
 public void Dispose()
 {
     _iBuffer.Dispose();
     _vBuffer.Dispose();
     _groundEffect.Dispose();
 }
Esempio n. 14
0
 public void Dispose()
 {
     _effect.Dispose();
 }
Esempio n. 15
0
 public void Dispose()
 {
     texture.Dispose();
     quadEffect.Dispose();
 }
Esempio n. 16
0
 public void Dispose()
 {
     BasicEffect.Dispose();
 }
Esempio n. 17
0
 public void Dispose()
 {
     _spriteBatch.Dispose();
     _lineEffect.Dispose();
     _meshEffect.Dispose();
 }
Esempio n. 18
0
 public void UnloadContent()
 {
     effect.Dispose();
 }
 public override void Cleanup(GraphicFactory factory)
 {
     effect.Dispose();
     base.Cleanup(factory);
 }
Esempio n. 20
0
 /// <summary>
 /// Eliminate any resources that prevent garbage collection.
 /// </summary>
 public void Dispose()
 {
     graphics = null;
     window   = null;
     effect.Dispose();
 }
Esempio n. 21
0
 /// <summary>
 /// Immediately releases unmanaged resources.
 /// </summary>
 /// <param name="disposing">False if managed resources should not be disposed.</param>
 protected override void Dispose(bool disposing)
 {
     effect.Dispose();
     base.Dispose(disposing);
 }
Esempio n. 22
0
 public void Dispose()
 {
     vbuffer.Dispose();
     ibuffer.Dispose();
     effect.Dispose();
 }
Esempio n. 23
0
 /// <summary>
 /// Immediately releases unmanaged resources.
 /// </summary>
 /// <param name="disposing">False if managed resources should not be disposed.</param>
 protected override void Dispose(bool disposing)
 {
     vertexDeclaration.Dispose();
     effect.Dispose();
     base.Dispose(disposing);
 }
Esempio n. 24
0
 public override void Dispose()
 {
     _defaultEffect?.Dispose();
     base.Dispose();
 }