Пример #1
0
 /// <summary>
 /// Load in case the device got lost.
 /// </summary>
 public override void Load()
 {
     base.Load();
     // Ok, time to create the shadow map render target
     if (shadowMapTexture == null)
         shadowMapTexture = new RenderToTexture(
             RenderToTexture.SizeType.ShadowMap);
 }
Пример #2
0
        /// <summary>
        /// Load in case the device got lost.
        /// </summary>
        public override void Load()
        {
            base.Load();
            // Scene map texture
            if (sceneMapTexture == null)
                sceneMapTexture = new RenderToTexture(
                    RenderToTexture.SizeType.FullScreenWithZBuffer);
            // Downsample map texture (to 1/4 of the screen)
            if (downsampleMapTexture == null)
                downsampleMapTexture = new RenderToTexture(
                    RenderToTexture.SizeType.QuarterScreen);

            // Blur map texture
            if (blurMap1Texture == null)
                blurMap1Texture = new RenderToTexture(
                    RenderToTexture.SizeType.QuarterScreen);
            // Blur map texture
            if (blurMap2Texture == null)
                blurMap2Texture = new RenderToTexture(
                    RenderToTexture.SizeType.QuarterScreen);
        }
Пример #3
0
 /// <summary>
 /// Dispose
 /// </summary>
 public override void Dispose()
 {
     base.Dispose();
     if (shadowMapTexture != null)
         shadowMapTexture.Dispose();
     shadowMapTexture = null;
 }
Пример #4
0
 /// <summary>
 /// Dispose
 /// </summary>
 public override void Dispose()
 {
     base.Dispose();
     if (sceneMapTexture != null)
         sceneMapTexture.Dispose();
     sceneMapTexture = null;
     if (downsampleMapTexture != null)
         downsampleMapTexture.Dispose();
     downsampleMapTexture = null;
     if (blurMap1Texture != null)
         blurMap1Texture.Dispose();
     blurMap1Texture = null;
     if (blurMap2Texture != null)
         blurMap2Texture.Dispose();
     blurMap2Texture = null;
 }
Пример #5
0
 /// <summary>
 /// Load in case the device got lost.
 /// </summary>
 public override void Load()
 {
     base.Load();
     // Scene map texture
     sceneMapTexture = new RenderToTexture(
         RenderToTexture.SizeType.FullScreen);
 }
Пример #6
0
 /// <summary>
 /// Dispose
 /// </summary>
 public override void Dispose()
 {
     base.Dispose();
     if (sceneMapTexture != null)
         sceneMapTexture.Dispose();
     sceneMapTexture = null;
 }
Пример #7
0
        //*/

        /// <summary>
        /// Test create render to texture
        /// </summary>
        public static void TestCreateRenderToTexture()
        {
            Model testModel = null;
            RenderToTexture renderToTexture = null;

            TestGame.Start(
                "TestCreateRenderToTexture",
                delegate
                {
                    testModel = new Model("apple");
                    renderToTexture = new RenderToTexture(
                        //SizeType.QuarterScreen);
                        SizeType.HalfScreen);
                        //SizeType.HalfScreenWithZBuffer);
                        //SizeType.FullScreen);
                        //SizeType.ShadowMap);
                },
                delegate
                {
                    bool renderToTextureWay =
                        Input.Keyboard.IsKeyUp(Keys.Space) &&
                        Input.GamePadAPressed == false;
                    BaseGame.Device.RenderState.DepthBufferEnable = true;

                    if (renderToTextureWay)
                    {
                        // Set render target to our texture
                        renderToTexture.SetRenderTarget();

                        // Clear background
                        renderToTexture.Clear(Color.Blue);

                        // Draw background lines
                        //Line.DrawGrid();
                        //Ui.LineManager.RenderAll3DLines();

                        // And draw object
                        testModel.Render(Matrix.CreateScale(7.5f));
                        //BaseGame.RenderManager.RenderAllMeshes();

                        // Do we need to resolve?
                        renderToTexture.Resolve(true);
                        //BaseGame.Device.ResolveRenderTarget(0);

                        // Reset background buffer
                        //not longer required, done in Resolve now:
                        //RenderToTexture.ResetRenderTarget(true);
                    } // if (renderToTextureWay)
                    else
                    {
                        // Copy backbuffer way, render stuff normally first
                        // Clear background
                        BaseGame.Device.Clear(Color.Blue);

                        // Draw background lines
                        //Line.DrawGrid();
                        //Ui.LineManager.RenderAll3DLines();

                        // And draw object
                        testModel.Render(Matrix.CreateScale(7.5f));
                        //BaseGame.RenderManager.RenderAllMeshes();
                    } // else

                    // Show render target in a rectangle on our screen
                    renderToTexture.RenderOnScreen(
                        //tst:
                        new Rectangle(100, 100, 256, 256));
                    //BaseGame.ScreenRectangle);
                    //no need: BaseGame.UI.FlushUI();

                    TextureFont.WriteText(2, 0,
                        "               Press Space to toogle full screen rendering");
                    TextureFont.WriteText(2, 30,
                        "renderToTexture.Width=" + renderToTexture.Width);
                    TextureFont.WriteText(2, 60,
                        "renderToTexture.Height=" + renderToTexture.Height);
                    TextureFont.WriteText(2, 90,
                        "renderToTexture.Valid=" + renderToTexture.IsValid);
                    TextureFont.WriteText(2, 120,
                        "renderToTexture.XnaTexture=" + renderToTexture.XnaTexture);
                    TextureFont.WriteText(2, 150,
                        "renderToTexture.ZBufferSurface=" + renderToTexture.ZBufferSurface);
                    TextureFont.WriteText(2, 180,
                        "renderToTexture.Filename=" + renderToTexture.Filename);
                });
        }
Пример #8
0
 /// <summary>
 /// Add render to texture instance to allow recreating them all
 /// when DeviceReset is called with help of the remRenderToTextures list. 
 /// </summary>
 public static void AddRemRenderToTexture(RenderToTexture renderToTexture)
 {
     remRenderToTextures.Add(renderToTexture);
 }