Exemplo n.º 1
0
 public void TestSimpleConstructor() {
   using(
     WaterSurface surface = new WaterSurface(
       this.mockedGraphicsDeviceService.GraphicsDevice,
       new Vector2(-10.0f, -10.0f), new Vector2(10.0f, 10.0f)
     )
   ) {
     Assert.IsNotNull(surface); // Nonsense; avoids compiler warning
   }
 }
Exemplo n.º 2
0
    public void TestDrawWaterPlane() {
      Effect waterSurfaceEffect = this.contentManager.Load<Effect>(
        "WaterSurfaceEffect"
      );

      using(
        WaterSurface surface = new WaterSurface(
          this.mockedGraphicsDeviceService.GraphicsDevice,
          new Vector2(-10.0f, -10.0f), new Vector2(10.0f, 10.0f),
          4, 4
        )
      ) {
        surface.SelectVertexAndIndexBuffer();
#if XNA_4
        EffectTechnique technique = waterSurfaceEffect.CurrentTechnique;
        for(int pass = 0; pass < technique.Passes.Count; ++pass) {
          technique.Passes[pass].Apply();

          surface.DrawWaterPlane(new GameTime(), Camera.DefaultOrthographic);
        }
#else
        waterSurfaceEffect.Begin();
        try {
          EffectTechnique technique = waterSurfaceEffect.CurrentTechnique;
          for(int pass = 0; pass < technique.Passes.Count; ++pass) {
            technique.Passes[pass].Begin();
            try {
              surface.DrawWaterPlane(new GameTime(), Camera.DefaultOrthographic);
            }
            finally {
              technique.Passes[pass].End();
            }
          }
        }
        finally {
          waterSurfaceEffect.End();
        }
#endif
      }
    }
Exemplo n.º 3
0
    public void TestGraphicsDeviceReset() {
      using(
        WaterSurface surface = new WaterSurface(
          this.mockedGraphicsDeviceService.GraphicsDevice,
          new Vector2(-10.0f, -10.0f), new Vector2(10.0f, 10.0f),
          4, 4
        )
      ) {
        this.mockedGraphicsDeviceService.ResetDevice();

        surface.UpdateReflection(
          new GameTime(), Camera.DefaultOrthographic,
          new WaterSurface.SceneDrawDelegate(drawReflection)
        );

        Assert.IsNotNull(surface.ReflectionCamera);
        Assert.IsNotNull(surface.ReflectionTexture);
      }
    }
Exemplo n.º 4
0
    public void TestSelectIndexAndVertexBuffer() {
      using(
        WaterSurface surface = new WaterSurface(
          this.mockedGraphicsDeviceService.GraphicsDevice,
          new Vector2(-10.0f, -10.0f), new Vector2(10.0f, 10.0f),
          4, 4
        )
      ) {
        GraphicsDevice graphicsDevice = this.mockedGraphicsDeviceService.GraphicsDevice;
        graphicsDevice.Indices = null;
#if XNA_4
        graphicsDevice.SetVertexBuffer(null);
#else
        graphicsDevice.Vertices[0].SetSource(
          null, 0, 0
        );
#endif
        Assert.IsNull(graphicsDevice.Indices);
#if XNA_4
        Assert.AreEqual(0, graphicsDevice.GetVertexBuffers().Length);
#else
        Assert.IsNull(graphicsDevice.Vertices[0].VertexBuffer);
#endif
        surface.SelectVertexAndIndexBuffer();

        Assert.IsNotNull(graphicsDevice.Indices);
#if XNA_4
        Assert.IsNotNull(graphicsDevice.GetVertexBuffers()[0].VertexBuffer);
#else
        Assert.IsNotNull(graphicsDevice.Vertices[0].VertexBuffer);
#endif
      }
    }