public void TestBeginEnd()
        {
            Matrix matrix = Matrix.Identity;

#if XNA_3
            TextDrawContext context = new TextDrawContext(this.effect, matrix, Color.Red);
            context.Begin();
            try {
                for (int pass = 0; pass < context.Passes; ++pass)
                {
                    context.BeginPass(pass);
                    context.EndPass();
                }
            }
            finally {
                context.End();
            }
#else
            TextDrawContext context = new TextDrawContext(this.effect, matrix, Color.Red);
            for (int pass = 0; pass < context.Passes; ++pass)
            {
                context.Apply(pass);
            }
#endif
        }
Пример #2
0
        /// <summary>Tests whether another draw context is identical to this one</summary>
        /// <param name="otherContext">Other context to check for equality</param>
        /// <returns>True if the other context is identical to this one</returns>
        public override bool Equals(DrawContext otherContext)
        {
            TextDrawContext other = otherContext as TextDrawContext;

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

            Effect thisEffect  = this.effect;
            Effect otherEffect = other.effect;

            // If the same effect instances are different, we stop comparing right here.
            // This context is specialized to run the same effect in multiple configurations,
            // different effects with identical settings will not happen due to its usage.
            if (!ReferenceEquals(thisEffect, otherEffect))
            {
                return(false);
            }

            // It's the same effect instance, so compare the configuration we're assigning
            // to the effect before each drawing cycle
            return
                ((this.textColor == other.textColor) &&
                 (this.transform == other.transform));
        }
    public void TestDifferentColors() {
      Matrix matrix = Matrix.Identity;

      TextDrawContext context1 = new TextDrawContext(this.effect, matrix, Color.Red);
      TextDrawContext context2 = new TextDrawContext(this.effect, matrix, Color.Black);

      Assert.IsFalse(context1.Equals(context2));
    }
        public void TestDifferentContexts()
        {
            Matrix            matrix   = Matrix.Identity;
            TextDrawContext   context1 = new TextDrawContext(this.effect, matrix, Color.White);
            EffectDrawContext context2 = new EffectDrawContext(this.effect);

            Assert.IsFalse(context1.Equals(context2));
        }
    public void TestIdenticalEffectParameters() {
      Matrix matrix = Matrix.Identity;

      TextDrawContext context1 = new TextDrawContext(this.effect, matrix, Color.White);
      TextDrawContext context2 = new TextDrawContext(this.effect, matrix, Color.White);

      Assert.IsTrue(context1.Equals(context2));
    }
        public void TestDifferentColors()
        {
            Matrix matrix = Matrix.Identity;

            TextDrawContext context1 = new TextDrawContext(this.effect, matrix, Color.Red);
            TextDrawContext context2 = new TextDrawContext(this.effect, matrix, Color.Black);

            Assert.IsFalse(context1.Equals(context2));
        }
        public void TestIdenticalEffectParameters()
        {
            Matrix matrix = Matrix.Identity;

            TextDrawContext context1 = new TextDrawContext(this.effect, matrix, Color.White);
            TextDrawContext context2 = new TextDrawContext(this.effect, matrix, Color.White);

            Assert.IsTrue(context1.Equals(context2));
        }
    public void TestDifferentMatrices() {
      Matrix matrix1 = Matrix.Identity;
      Matrix matrix2 = new Matrix(
        1.1f, 1.2f, 1.3f, 1.4f,
        2.1f, 2.2f, 2.3f, 2.4f,
        3.1f, 3.2f, 3.3f, 3.4f,
        4.1f, 4.2f, 4.3f, 4.4f
      );

      TextDrawContext context1 = new TextDrawContext(this.effect, matrix1, Color.White);
      TextDrawContext context2 = new TextDrawContext(this.effect, matrix2, Color.White);

      Assert.IsFalse(context1.Equals(context2));
    }
        public void TestDifferentMatrices()
        {
            Matrix matrix1 = Matrix.Identity;
            Matrix matrix2 = new Matrix(
                1.1f, 1.2f, 1.3f, 1.4f,
                2.1f, 2.2f, 2.3f, 2.4f,
                3.1f, 3.2f, 3.3f, 3.4f,
                4.1f, 4.2f, 4.3f, 4.4f
                );

            TextDrawContext context1 = new TextDrawContext(this.effect, matrix1, Color.White);
            TextDrawContext context2 = new TextDrawContext(this.effect, matrix2, Color.White);

            Assert.IsFalse(context1.Equals(context2));
        }
        public void TestDifferentEffects()
        {
            Matrix          matrix   = Matrix.Identity;
            TextDrawContext context1 = new TextDrawContext(this.effect, matrix, Color.White);

            using (
                BasicEffect effect2 = new BasicEffect(
                    this.mockedGraphicsDeviceService.GraphicsDevice
#if XNA_3
                    , null
#endif
                    )
                ) {
                TextDrawContext context2 = new TextDrawContext(effect2, matrix, Color.White);
                Assert.IsFalse(context1.Equals(context2));
            }
        }
Пример #11
0
    public void TestDifferentEffects() {
      Matrix matrix = Matrix.Identity;
      TextDrawContext context1 = new TextDrawContext(this.effect, matrix, Color.White);
      using(
        BasicEffect effect2 = new BasicEffect(
          this.mockedGraphicsDeviceService.GraphicsDevice
#if !XNA_4
          , null
#endif
        )
      ) {
        TextDrawContext context2 = new TextDrawContext(effect2, matrix, Color.White);
        Assert.IsFalse(context1.Equals(context2));
      }
    }
Пример #12
0
    public void TestBeginEnd() {
      Matrix matrix = Matrix.Identity;
#if XNA_4
      TextDrawContext context = new TextDrawContext(this.effect, matrix, Color.Red);
      for(int pass = 0; pass < context.Passes; ++pass) {
        context.Apply(pass);
      }
#else
      TextDrawContext context = new TextDrawContext(this.effect, matrix, Color.Red);
      context.Begin();
      try {
        for(int pass = 0; pass < context.Passes; ++pass) {
          context.BeginPass(pass);
          context.EndPass();
        }
      }
      finally {
        context.End();
      }
#endif
    }
Пример #13
0
    public void TestDifferentContexts() {
      Matrix matrix = Matrix.Identity;
      TextDrawContext context1 = new TextDrawContext(this.effect, matrix, Color.White);
      EffectDrawContext context2 = new EffectDrawContext(this.effect);

      Assert.IsFalse(context1.Equals(context2));
    }