Beispiel #1
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>
        /// <remarks>
        ///   Classes deriving from the EffectDrawContext should override this method
        ///   and do their own comparison - for example, two drawing contexts might
        ///   use the same effect instance, but apply different effect parameters before
        ///   rendering - in that case, an additional comparison of the draw context's
        ///   own settings needs to be performed here.
        /// </remarks>
        public override bool Equals(DrawContext otherContext)
        {
            EffectDrawContext other = otherContext as EffectDrawContext;

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

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

            // If the same effect instance is behind the other class, we can be sure that
            // the effects are identical. Derived clases should override this method,
            // otherwise, instance using the same effect but with different effect parameters
            // would be compared as equal in this line. If on the other hand, the effect
            // draw context is used directly, this comparison is what we want!
            if (ReferenceEquals(thisEffect, otherEffect))
            {
                return(true);
            }

            // Short cut didn't work, compare the effects member by member
            return(CompareEffectParameters(otherEffect));
        }
    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));
    }
Beispiel #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // TODO: use Content to load your game content here
            GenerateTerrain(20);

            triplanarEffect = contentManager.Load<Effect>("Triplanar");
            terrainDrawContext = new EffectDrawContext(triplanarEffect);
            terrainDrawContext.Effect.Parameters["ColorMap"].SetValue(contentManager.Load<Texture2D>("paved"));
            SetTextureScale();
            //terrainDrawContext.BasicEffect.Texture = contentManager.Load<Texture2D>("paved"); ;
        }