当前位置: 首页>>代码示例>>C#>>正文


C# RenderTarget2D.GetTexture方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.RenderTarget2D.GetTexture方法的典型用法代码示例。如果您正苦于以下问题:C# RenderTarget2D.GetTexture方法的具体用法?C# RenderTarget2D.GetTexture怎么用?C# RenderTarget2D.GetTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Graphics.RenderTarget2D的用法示例。


在下文中一共展示了RenderTarget2D.GetTexture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreatePixelTexture

        //Creates a white 1*1 Texture that is used for the lines by scaling and rotating it
        public void CreatePixelTexture()
        {
            int TargetWidth = 1;
            int TargetHeight = 1;

            RenderTarget2D LevelRenderTarget = new RenderTarget2D(graphicsDevice, TargetWidth, TargetHeight, 1,
                graphicsDevice.PresentationParameters.BackBufferFormat, graphicsDevice.PresentationParameters.MultiSampleType,
                graphicsDevice.PresentationParameters.MultiSampleQuality, RenderTargetUsage.PreserveContents);

            DepthStencilBuffer stencilBuffer = new DepthStencilBuffer(graphicsDevice, TargetWidth, TargetHeight,
                graphicsDevice.DepthStencilBuffer.Format, graphicsDevice.PresentationParameters.MultiSampleType,
                graphicsDevice.PresentationParameters.MultiSampleQuality);

            graphicsDevice.SetRenderTarget(0, LevelRenderTarget);

            // Cache the current depth buffer
            DepthStencilBuffer old = graphicsDevice.DepthStencilBuffer;
            // Set our custom depth buffer
            graphicsDevice.DepthStencilBuffer = stencilBuffer;

            graphicsDevice.Clear(Color.White);

            graphicsDevice.SetRenderTarget(0, null);

            // Reset the depth buffer
            graphicsDevice.DepthStencilBuffer = old;
            pixel = LevelRenderTarget.GetTexture();
        }
开发者ID:RochesterIndiesAnonymous,项目名称:Ironstag,代码行数:29,代码来源:PrimitiveDrawer.cs

示例2: method_11

 // Token: 0x06002540 RID: 9536
 // RVA: 0x000E0B84 File Offset: 0x000DED84
 private Texture2D method_11(Color color_3, Color color_4, Color color_5, Color color_6, float float_1)
 {
     RenderTarget2D renderTarget2D = new RenderTarget2D(base.method_8(), 128, 1, 1, 1);
     VertexPositionColor[] array = new VertexPositionColor[]
     {
         new VertexPositionColor(new Vector3(-0.5f, 0f, 0f), Color.get_TransparentBlack()),
         new VertexPositionColor(new Vector3(0f, 0f, 0f), Color.get_TransparentBlack()),
         new VertexPositionColor(new Vector3(0.078125f - float_1, 0f, 0f), color_3),
         new VertexPositionColor(new Vector3(0.078125f + float_1, 0f, 0f), color_4),
         new VertexPositionColor(new Vector3(0.1875f - float_1, 0f, 0f), color_4),
         new VertexPositionColor(new Vector3(0.1875f + float_1, 0f, 0f), color_6),
         new VertexPositionColor(new Vector3(1f, 0f, 0f), color_5),
         new VertexPositionColor(new Vector3(1.5f, 0f, 0f), color_5)
     };
     RenderTarget2D renderTarget2D2 = (RenderTarget2D)base.method_8().GetRenderTarget(0);
     base.method_8().SetRenderTarget(0, renderTarget2D);
     base.method_8().get_RenderState().set_AlphaBlendEnable(false);
     base.method_8().get_RenderState().set_DepthBufferEnable(false);
     base.method_8().get_RenderState().set_AlphaTestEnable(false);
     base.method_8().get_RenderState().set_BlendFunction(1);
     base.method_8().get_RenderState().set_AlphaBlendOperation(1);
     base.method_8().set_VertexDeclaration(new VertexDeclaration(base.method_8(), VertexPositionColor.VertexElements));
     base.method_8().Clear(Color.get_PaleVioletRed());
     base.method_9().set_World(Matrix.get_Identity());
     base.method_9().set_Projection(Matrix.CreateOrthographicOffCenter(0f, 1f, 1f, -1f, -1f, 1f));
     base.method_9().set_View(Matrix.get_Identity());
     base.method_9().set_TextureEnabled(false);
     base.method_9().set_Texture(null);
     base.method_9().set_VertexColorEnabled(true);
     base.method_9().Begin();
     base.method_9().get_CurrentTechnique().get_Passes().get_Item(0).Begin();
     base.method_8().DrawUserPrimitives<VertexPositionColor>(3, array, 0, 7);
     base.method_9().get_CurrentTechnique().get_Passes().get_Item(0).End();
     base.method_9().End();
     base.method_8().ResolveRenderTarget(0);
     Texture2D texture = renderTarget2D.GetTexture();
     base.method_8().SetRenderTarget(0, renderTarget2D2);
     return texture;
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:41,代码来源:Class586.cs

示例3: Generate2DNoise

        public Texture2D Generate2DNoise(NoiseParameters noiseParams, int width, int height, int mipCount)
        {
            Vector2 invRes = Vector2.One / new Vector2(width, height);
            noise2DShader.SetupShader();
            GFX.Device.SetVertexShaderConstant(0, invRes);
            GFX.Device.SetPixelShaderConstant(0, invRes);
            GFX.Device.SetPixelShaderConstant(1, new Vector4(noiseParams.Amplitude, noiseParams.Frequency, noiseParams.Persistance, noiseParams.Octaves));
            GFX.Device.Textures[0] = ComputeRandomTexture(width / 2, height / 2);

            RenderTarget2D rtNoise = new RenderTarget2D(GFX.Device, width, height, 1, SurfaceFormat.Color);
            DepthStencilBuffer dsOld = GFX.Device.DepthStencilBuffer;
            GFX.Device.DepthStencilBuffer = GFX.Inst.dsBufferLarge;
            GFX.Device.SetRenderTarget(0, rtNoise);
            GFXPrimitives.Quad.Render();
            GFX.Device.SetRenderTarget(0, null);
            GFX.Device.DepthStencilBuffer = dsOld;

            Color[] colorData = new Color[width * height];
            rtNoise.GetTexture().GetData<Color>(colorData);
            Texture2D noiseTexture = new Texture2D(GFX.Device, width, height, mipCount, TextureUsage.None, SurfaceFormat.Color);
            noiseTexture.SetData<Color>(colorData);
            noiseTexture.GenerateMipMaps(TextureFilter.GaussianQuad);
            return noiseTexture;
        }
开发者ID:MattVitelli,项目名称:IslandAdventure,代码行数:24,代码来源:PerlinNoiseSimulator.cs

示例4: CreateRoadAtlas

        public Texture2D CreateRoadAtlas(Texture2D[] input, SpriteBatch spriteBatch)
        {
            DepthStencilBuffer OldDSBuffer = m_GraphicsDevice.DepthStencilBuffer;

            RenderTarget2D RTarget = new RenderTarget2D(m_GraphicsDevice, 512, 512, 0, SurfaceFormat.Color,
                RenderTargetUsage.PreserveContents);
            DepthStencilBuffer DSBuffer = new DepthStencilBuffer(m_GraphicsDevice, 512, 512,
                OldDSBuffer.Format);

            m_GraphicsDevice.DepthStencilBuffer = DSBuffer;
            m_GraphicsDevice.SetRenderTarget(0, RTarget);

            m_GraphicsDevice.Clear(Color.TransparentBlack);

            spriteBatch.Begin();

            for (int i = 0; i < 16; i++)
            {
                spriteBatch.Draw(input[i], new Rectangle((i%4) * 128, (int)(i/4.0)*128, 128, 128), Color.White);
            }

            spriteBatch.End();

            m_GraphicsDevice.SetRenderTarget(0, null);
            m_GraphicsDevice.DepthStencilBuffer = OldDSBuffer;

            Texture2D Ret = RTarget.GetTexture();
            RTarget.Dispose(); //free up memory used by render target, as we have moved the data to a texture.
            return Ret;
        }
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:30,代码来源:Terrain.cs

示例5: BlurRenderTarget

        public void BlurRenderTarget(RenderTarget2D target, BlurFilter filterType, int blurPasses)
        {
            Vector2 invRes = Vector2.One / new Vector2(target.Width, target.Height);
            GFX.Device.SetVertexShaderConstant(GFXShaderConstants.VC_INVTEXRES, invRes);
            GFX.Device.SetPixelShaderConstant(1, Vector4.One * 0.015f);
            GFX.Device.SetPixelShaderConstant(0, invRes);

            Shader activeHShader = boxBlurHShader;
            Shader activeVShader = boxBlurVShader;
            switch (filterType)
            {
                case BlurFilter.Gauss:
                    activeHShader = gaussBlurHShader;
                    activeVShader = gaussBlurVShader;
                    break;
            }

            for (int i = 0; i < blurPasses; i++)
            {
                GFX.Device.Textures[0] = target.GetTexture();
                GFX.Device.SetRenderTarget(0, target);
                activeHShader.SetupShader();
                GFXPrimitives.Quad.Render();
                GFX.Device.SetRenderTarget(0, null);

                GFX.Device.Textures[0] = target.GetTexture();

                GFX.Device.SetRenderTarget(0, target);
                activeVShader.SetupShader();
                GFXPrimitives.Quad.Render();
                GFX.Device.SetRenderTarget(0, null);
            }
        }
开发者ID:MattVitelli,项目名称:Nosferatu,代码行数:33,代码来源:PostProcessElementManager.cs

示例6: Resize

        public static Texture2D Resize(GraphicsDevice gd, Texture2D texture, int newWidth, int newHeight)
        {
            RenderTarget2D renderTarget = new RenderTarget2D(
                gd,
                newWidth, newHeight, 1,
                SurfaceFormat.Color);

            SpriteBatch batch = new SpriteBatch(gd);

            Rectangle destinationRectangle = new Rectangle(0, 0, newWidth, newHeight);
            lock (gd)
            {
                gd.SetRenderTarget(0, renderTarget);
                batch.Begin();
                batch.Draw(texture, destinationRectangle, Color.White);
                batch.End();
                gd.SetRenderTarget(0, null);
            }
            var newTexture = renderTarget.GetTexture();
            return newTexture;
        }
开发者ID:Tranquill6,项目名称:Project-Dollhouse,代码行数:21,代码来源:TextureUtils.cs

示例7: GenerateNormalMap

        void GenerateNormalMap()
        {
            Texture2D heightmap = new Texture2D(GFX.Device, width, depth, 1, TextureUsage.None, SurfaceFormat.Single);
            heightmap.SetData<float>(heightValues);

            Vector2 invRes = Vector2.One / new Vector2(heightmap.Width, heightmap.Height);
            Shader normalTangentShader = ResourceManager.Inst.GetShader("NormalTangentHeightmap");
            normalTangentShader.SetupShader();
            GFX.Device.SetVertexShaderConstant(0, invRes);
            GFX.Device.SetPixelShaderConstant(0, invRes);
            GFX.Device.SetPixelShaderConstant(1, Vector4.One / MaximumHeight);
            GFX.Device.Textures[0] = heightmap;
            GFX.Inst.SetTextureFilter(0, TextureFilter.Linear);

            RenderTarget2D normTanTarget = new RenderTarget2D(GFX.Device, heightmap.Width, heightmap.Height, 1, SurfaceFormat.Vector4);
            DepthStencilBuffer dsOld = GFX.Device.DepthStencilBuffer;
            DepthStencilBuffer dsNew = new DepthStencilBuffer(GFX.Device, heightmap.Width, heightmap.Height, dsOld.Format);
            GFX.Device.DepthStencilBuffer = dsNew;
            GFX.Device.SetRenderTarget(0, normTanTarget);
            GFXPrimitives.Quad.Render();
            GFX.Device.SetRenderTarget(0, null);
            GFX.Device.DepthStencilBuffer = dsOld;

            normalTexture = normTanTarget.GetTexture();
        }
开发者ID:MattVitelli,项目名称:IslandAdventure,代码行数:25,代码来源:TerrainHeightmap.cs

示例8: PerformBlur

        void PerformBlur(Texture2D heightmap)
        {
            Shader heightBlur2DShader = ResourceManager.Inst.GetShader("HeightmapBlurMinMax");
            RenderTarget2D paramTarget = new RenderTarget2D(GFX.Device, DensityFieldWidth, DensityFieldDepth, 1, SurfaceFormat.Vector4);
            GFX.Device.SetPixelShaderConstant(GFXShaderConstants.VC_INVTEXRES, Vector2.One / new Vector2(DensityFieldWidth, DensityFieldDepth));
            GFX.Device.SetPixelShaderConstant(0, Vector2.One / new Vector2(DensityFieldWidth, DensityFieldDepth));
            heightBlur2DShader.SetupShader();
            GFX.Device.Textures[0] = heightmap;

            GFX.Device.SetRenderTarget(0, paramTarget);
            GFXPrimitives.Quad.Render();
            GFX.Device.SetRenderTarget(0, null);

            Shader gradShader = ResourceManager.Inst.GetShader("GradientHeightmap");
            GFX.Device.Textures[0] = paramTarget.GetTexture();
            gradShader.SetupShader();

            RenderTarget2D gradTarget = new RenderTarget2D(GFX.Device, DensityFieldWidth, DensityFieldDepth, 1, SurfaceFormat.Single);
            GFX.Device.SetRenderTarget(0, gradTarget);
            GFXPrimitives.Quad.Render();
            GFX.Device.SetRenderTarget(0, null);

            GFX.Device.Textures[0] = null;

            Shader blurShader = ResourceManager.Inst.GetShader("VoxelBlur3x3x3");

            srcTarget = new RenderTarget2D(GFX.Device, DensityFieldWidth, DensityFieldHeight, 1, GFX.Inst.ByteSurfaceFormat);
            DepthStencilBuffer dsOld = GFX.Device.DepthStencilBuffer;
            GFX.Device.DepthStencilBuffer = GFX.Inst.dsBufferLarge;

            blurShader.SetupShader();
            GFX.Device.SetPixelShaderConstant(0, Vector3.One / new Vector3(DensityFieldWidth, DensityFieldHeight, DensityFieldDepth));

            GFX.Device.SamplerStates[0].AddressU = TextureAddressMode.Clamp;
            GFX.Device.SamplerStates[0].AddressV = TextureAddressMode.Clamp;
            GFX.Device.SamplerStates[0].AddressW = TextureAddressMode.Clamp;

            GFX.Device.RenderState.DepthBufferEnable = false;
            GFX.Device.RenderState.DepthBufferWriteEnable = false;

            //Here we generate our noise textures
            int nSize = 32;
            noiseTextures = new Texture3D[4];
            float[] noiseData = new float[nSize * nSize * nSize];
            Random rand = new Random();
            for (int i = 0; i < noiseTextures.Length; i++)
            {
                noiseTextures[i] = new Texture3D(GFX.Device, nSize, nSize, nSize, 1, TextureUsage.None, SurfaceFormat.Single);
                for (int j = 0; j < noiseData.Length; j++)
                {
                    noiseData[j] = (float)(rand.NextDouble() * 2 - 1);
                }
                noiseTextures[i].SetData<float>(noiseData);
            }

            noiseData = null;

            //Lets activate our textures
            for (int i = 0; i < noiseTextures.Length; i++)
                GFX.Device.Textures[i+3] = noiseTextures[i];

            //CopyDensityTextureData(ref DensityField, currDensityField);
            GFX.Device.Textures[0] = heightmap;
            GFX.Device.Textures[1] = paramTarget.GetTexture();
            GFX.Device.Textures[2] = gradTarget.GetTexture();
            for (int z = 0; z < DensityFieldDepth; z++)
            {
                Vector4 depth = Vector4.One * (float)z / (float)(DensityFieldDepth - 1);
                GFX.Device.SetVertexShaderConstant(0, depth); //Set our current depth

                GFX.Device.SetRenderTarget(0, srcTarget);
                //GFX.Device.Clear(Color.TransparentBlack);

                GFXPrimitives.Quad.Render();

                GFX.Device.SetRenderTarget(0, null);

                //Now the copying stage.
                ExtractDensityTextureData(ref DensityField, z);

            }
            GFX.Device.Textures[0] = null;
            /*
            Texture3D voxelTexture = new Texture3D(GFX.Device, DensityFieldWidth, DensityFieldHeight, DensityFieldDepth, 1, TextureUsage.None, GFX.Inst.ByteSurfaceFormat);
            switch (GFX.Inst.ByteSurfaceDataType)
            {
                case GFXTextureDataType.BYTE:
                    voxelTexture.SetData<byte>(DensityField);
                    break;
                case GFXTextureDataType.COLOR:
                    Color[] tempColor = new Color[DensityField.Length];
                    for(int i = 0; i < tempColor.Length; i++)
                        tempColor[i] = new Color(DensityField[i], DensityField[i], DensityField[i], DensityField[i]);
                    voxelTexture.SetData<Color>(tempColor);
                    tempColor = null;
                    break;
                case GFXTextureDataType.SINGLE:
                    float[] tempFloat = new float[DensityField.Length];
                    float invScale = 1.0f / 255.0f;
                    for (int i = 0; i < tempFloat.Length; i++)
//.........这里部分代码省略.........
开发者ID:MattVitelli,项目名称:Nosferatu,代码行数:101,代码来源:TerrainVoxel.cs

示例9: AssembleTextureAtlas

        void AssembleTextureAtlas(Texture3D target, Texture2D[] srcTextures, int textureSize, int mipCount)
        {
            Shader imageShader = ResourceManager.Inst.GetShader("Generic2D");
            RenderTarget2D rtTarget = new RenderTarget2D(GFX.Device, textureSize, textureSize, 1, SurfaceFormat.Color);
            target = new Texture3D(GFX.Device, textureSize, textureSize, srcTextures.Length, mipCount, TextureUsage.AutoGenerateMipMap, SurfaceFormat.Color);

            Color[] colorBuffer = new Color[textureSize * textureSize];

            GFX.Device.SamplerStates[0].MagFilter = TextureFilter.Linear;
            GFX.Device.SamplerStates[0].MinFilter = TextureFilter.Linear;
            GFX.Device.SamplerStates[0].MipFilter = TextureFilter.Linear;
            imageShader.SetupShader();
            for (int i = 0; i < srcTextures.Length; i++)
            {
                GFX.Device.SetVertexShaderConstant(GFXShaderConstants.VC_INVTEXRES, Vector2.One / new Vector2(srcTextures[i].Width, srcTextures[i].Height));
                GFX.Device.Textures[0] = srcTextures[i];
                GFX.Device.SetRenderTarget(0, rtTarget);
                GFXPrimitives.Quad.Render();
                GFX.Device.SetRenderTarget(0, null);
                rtTarget.GetTexture().GetData<Color>(colorBuffer);
                target.SetData<Color>(colorBuffer, colorBuffer.Length * i, colorBuffer.Length, SetDataOptions.None);
            }

            target.GenerateMipMaps(TextureFilter.Linear);
        }
开发者ID:MattVitelli,项目名称:Nosferatu,代码行数:25,代码来源:TerrainVoxel.cs

示例10: PerformHistogramEqualization

        void PerformHistogramEqualization(Texture2D heightmap)
        {
            Vector2 MinMax = GetMinMaxHeight(heightmap);
            RenderTarget2D rtHist = new RenderTarget2D(GFX.Device, heightmap.Width, heightmap.Height, 1, heightmap.Format);

            GFX.Device.SetRenderTarget(0, rtHist);

            GFX.Device.Textures[0] = heightmap;
            GFX.Device.SetVertexShaderConstant(GFXShaderConstants.VC_INVTEXRES, new Vector2(1.0f / (float)heightmap.Width, 1.0f / (float)heightmap.Height));
            GFX.Device.SetPixelShaderConstant(0, MinMax);
            histogramShader.SetupShader();

            GFXPrimitives.Quad.Render();

            GFX.Device.SetRenderTarget(0, null);
            GFX.Device.Textures[0] = null;

            CopyToTexture(rtHist.GetTexture(), heightmap);
        }
开发者ID:MattVitelli,项目名称:Nosferatu,代码行数:19,代码来源:TerrainGenerator.cs

示例11: CopyTextureToRenderTarget

 private void CopyTextureToRenderTarget(Texture2D src, RenderTarget2D rt, ref Texture2D dest)
 {
     var dsb = GraphicsDevice.DepthStencilBuffer;
     GraphicsDevice.DepthStencilBuffer = null;
     GraphicsDevice.SetRenderTarget(0, rt);
     spriteBatch.Begin(SpriteBlendMode.None, SpriteSortMode.Immediate, SaveStateMode.None);
     spriteBatch.Draw(src, new Rectangle(0, 0, src.Width, src.Height), Color.White);
     spriteBatch.End();
     GraphicsDevice.SetRenderTarget(0, null);
     GraphicsDevice.DepthStencilBuffer = dsb;
     dest = rt.GetTexture();
     dest.GenerateMipMaps(TextureFilter.Linear);
 }
开发者ID:romainpi,项目名称:berkelium-managed,代码行数:13,代码来源:BerkeliumTestGame.cs

示例12: Process

        public void Process(GraphicsDevice g, RenderTarget2D sceneTarget)
        {
            // extract brightest parts of the scene
            g.SetRenderTarget(0, rTarget1);
            Texture2D sceneTexture = sceneTarget.GetTexture();
            ppManager.RenderScreenQuad(e, luminosityExtractTechnique, sceneTexture);

            // blur the luminosity extract horizontally
            g.SetRenderTarget(0, rTarget2);
            e.Parameters["fWeights"].SetValue(horizontalBlurParameters.Weights);
            e.Parameters["vOffsets"].SetValue(horizontalBlurParameters.Offsets);
            ppManager.RenderScreenQuad(e, gaussianBlurTechnique, rTarget1.GetTexture());

            // blur the luminosity extract vertically
            g.SetRenderTarget(0, rTarget1);
            e.Parameters["fWeights"].SetValue(verticalBlurParameters.Weights);
            e.Parameters["vOffsets"].SetValue(verticalBlurParameters.Offsets);
            ppManager.RenderScreenQuad(e, gaussianBlurTechnique, rTarget2.GetTexture());
            
            // combine blurred luminosity extract with scene
            g.SetRenderTarget(0, null);
            g.Textures[1] = sceneTexture;
            ppManager.RenderScreenQuad(e, compositeTechnique, rTarget1.GetTexture());
        }
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:24,代码来源:Bloom.cs

示例13: DrawWithClipRect

        protected override void DrawWithClipRect()
        {
            if (Visible)
            {
                Vector2 drawPos = new Vector2(AbsoluteTransform.X, AbsoluteTransform.Y);

                if (SourceRectangle.HasValue && IsPartiallyObscured)
                {
                    //Game.GraphicsDevice.ScissorRectangle = SourceRectangle.Value;
                    //Game.GraphicsDevice.RenderState.ScissorTestEnable = true;

                    //Game.GraphicsDevice.SetRenderTarget(0, null);
                    RenderTarget2D renderTarget = new RenderTarget2D(Game.GraphicsDevice,
                        SourceRectangle.Value.Width,
                        SourceRectangle.Value.Height,
                        1,
                        SurfaceFormat.Color,
                        RenderTargetUsage.PreserveContents);

                    Game.GraphicsDevice.SetRenderTarget(0, renderTarget);

                    Game.GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.TransparentWhite, 1, 0);

                    //draw the text!
                    SpriteBatch spriteBatch = new SpriteBatch(Game.GraphicsDevice);
                    spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Deferred, SaveStateMode.SaveState);
                    spriteBatch.DrawString(spriteFont,
                                            Text,
                                            new Vector2(SourceRectangle.Value.X, -SourceRectangle.Value.Y),
                                            fontColor,
                                            0,
                                            Origin,
                                            1,
                                            SpriteEffects.None,
                                            0);
                    spriteBatch.End();

                    Game.GraphicsDevice.SetRenderTarget(0, null);
                    //Game.GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.White, 1, 0);

                    _texture = renderTarget.GetTexture();

                    _guiManager.SpriteBatch.Draw(_texture,
                        drawPos + new Vector2(SourceRectangle.Value.X, SourceRectangle.Value.Y),
                        new Rectangle(0,0, SourceRectangle.Value.Width, SourceRectangle.Value.Height),
                        fontColor,
                        0f,
                        Vector2.Zero,
                        1f,
                        SpriteEffects.None,
                        0);

                }
                else if (!Parent.IsTotallyObscured)
                {
                    //draw the text!
                    _guiManager.SpriteBatch.DrawString(spriteFont,
                                            Text,
                                            drawPos,
                                            fontColor,
                                            0,
                                            Origin,
                                            1,
                                            SpriteEffects.None,
                                            0);
                }

                //Game.GraphicsDevice.RenderState.ScissorTestEnable = false;
            }
        }
开发者ID:konlil,项目名称:pipe,代码行数:70,代码来源:DText.cs

示例14: DrawBlur

        void DrawBlur(float x, float y, Effect effectToUse,
            RenderTarget2D source, RenderTarget2D target)
        {
            SetBlurEffectParameters(x, y, effectToUse);

            GraphicsDevice.SetRenderTarget(0, target);

            spriteBatch.Begin(SpriteBlendMode.None,
                              SpriteSortMode.Immediate,
                              SaveStateMode.None);

            effectToUse.Begin();
            effectToUse.CurrentTechnique.Passes[0].Begin();

            spriteBatch.Draw(source.GetTexture(),
                new Rectangle(0, 0,
                    target.Width,
                    target.Height), Color.White);
            spriteBatch.End();

            effectToUse.CurrentTechnique.Passes[0].End();
            effectToUse.End();
        }
开发者ID:alittle1234,项目名称:XNA_Project,代码行数:23,代码来源:Game1.cs

示例15: GenTextureDebug

        //Debugging methods
        public Texture2D GenTextureDebug(String text)
        {
            int w = (int)debugFont.MeasureString(text).X;
            int h = (int)debugFont.MeasureString(text).Y;

            RenderTarget2D render = new RenderTarget2D(GraphicsDevice, w, h, 1, GraphicsDevice.DisplayMode.Format
                                    , GraphicsDevice.PresentationParameters.MultiSampleType
                                    , GraphicsDevice.PresentationParameters.MultiSampleQuality
                                    , RenderTargetUsage.DiscardContents);

            GraphicsDevice.SetRenderTarget(0, render);

            spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState);
            spriteBatch.DrawString(debugFont, text, new Vector2(1, 1), Color.Black);
            spriteBatch.DrawString(debugFont, text, new Vector2(0, 0), Color.White);
            spriteBatch.End();

            GraphicsDevice.SetRenderTarget(0, null);
            return render.GetTexture();
        }
开发者ID:elliottroland,项目名称:Emergence,代码行数:21,代码来源:CoreEngine.cs


注:本文中的Microsoft.Xna.Framework.Graphics.RenderTarget2D.GetTexture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。