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


C# Graphics.RenderTarget2D类代码示例

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


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

示例1: WaterSubMesh

 public WaterSubMesh(Mesh mesh, RenderTarget2D reflectionBuffer, RenderTarget2D refractionBuffer, Texture2D offsetMap, Texture2D normalMap) : base(mesh)
 {
     m_ReflectionTarget = reflectionBuffer;
     m_RefractionTarget = refractionBuffer;
     m_OffsetMap = offsetMap;
     m_NormalMap = normalMap;
 }
开发者ID:Imortilize,项目名称:Psynergy-Engine,代码行数:7,代码来源:WaterSubMesh.cs

示例2: TileCanvas

        public TileCanvas(TileLayer tileLayer)
        {
            TileLayer = tileLayer;

            //Init the textures array
            Size texSize = new Size(MAX_TEXTURE_SIZE - (MAX_TEXTURE_SIZE % TileLayer.Definition.Grid.Width), MAX_TEXTURE_SIZE - (MAX_TEXTURE_SIZE % TileLayer.Definition.Grid.Height));

            Size maxSize = new Size(TileLayer.Definition.Grid.Width * TileLayer.TileCellsX, TileLayer.Definition.Grid.Height * TileLayer.TileCellsY);

            // TODO: Clip the dimensions of the tiles that draw over the edges of the level.
            Textures = new List<TextureInfo>();
            for (int i = 0; i < maxSize.Width; i += texSize.Width)
            {
                for (int j = 0; j < maxSize.Height; j += texSize.Height)
                {
                    RenderTarget2D tex = new RenderTarget2D(
                        Ogmo.EditorDraw.GraphicsDevice,
                        Math.Min(maxSize.Width - i, texSize.Width),
                        Math.Min(maxSize.Height - j, texSize.Height));
                    Textures.Add(new TextureInfo(tex, new Point(i, j)));
                }
            }

            RefreshAll();
        }
开发者ID:hach-que,项目名称:OgmoEditor,代码行数:25,代码来源:TileCanvas.cs

示例3: ShallowWaterRC

 public ShallowWaterRC(Texture2D p_txTextre, Vector2 p_v2Pos)
     : base(p_txTextre, new TransformComponent(p_v2Pos))
 {
     this.enType = RenderComponent.ComponentType.StaticRenderComponent;
     this.graphics = Program.game.GraphicsDevice;
     this.rt2dDistortionMos = new RenderTarget2D(this.graphics, 640, 360);
 }
开发者ID:ancientgods,项目名称:SoG,代码行数:7,代码来源:ShallowWaterRC.cs

示例4: CreateBackground

        private Texture2D CreateBackground(GraphicsDevice gd, SpriteBatch sb, ContentManager cm)
        {
            RenderTarget2D target = new RenderTarget2D(gd, 2048, 2048);
            //tell the GraphicsDevice we want to render to the gamesMenu rendertarget (an in-memory buffer)
            gd.SetRenderTarget(target);

            //clear the background
            gd.Clear(Color.Transparent);

            //begin drawing
            sb.Begin();
            for (int x = 0; x < 8; x++)
            {
                for (int y = 0; y < 8; y++)
                {
                    sb.Draw(cm.Load<Texture2D>("Backgrounds/" + _level.ToString()), new Vector2(x * 400, y * 256), Color.White);
                }
            }

            sb.End();
            //reset the GraphicsDevice to draw on the backbuffer (directly to the backbuffer)
            gd.SetRenderTarget(null);

            return (Texture2D)target;
        }
开发者ID:Siryu,项目名称:Dinosaur-Laser-Assault,代码行数:25,代码来源:Background.cs

示例5: LightArea

 public LightArea(GraphicsDevice graphicsDevice, ShadowmapSize size)
 {
     int baseSize = 2 << (int)size;
     LightAreaSize = new Vector2(baseSize);
     RenderTarget = new RenderTarget2D(graphicsDevice, baseSize, baseSize);
     this.graphicsDevice = graphicsDevice;
 }
开发者ID:kmiron,项目名称:Sandbox-Games,代码行数:7,代码来源:LightArea.cs

示例6: KarmaWorld

        public KarmaWorld(GraphicsDevice device, ContentManager content)
        {
            KarmaWorld.World = this;

            GraphicsDevice = device;
            ContentManager = content;
            RenderedWorld = new RenderTarget2D(device, device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight,
                                               true, device.DisplayMode.Format, DepthFormat.Depth24);

            Timers = new Utilities.TimerManager();
            Input = new ButtonInputManager();

            Input.AddInput("Zoom In", new ComboButton(new KeyboardButton(Keys.LeftControl, false), new KeyboardButton(Keys.PageUp, true)));
            Input.AddInput("Zoom Out", new ComboButton(new KeyboardButton(Keys.LeftControl, false), new KeyboardButton(Keys.PageDown, true)));

            CurrentTime = new GameTime(TimeSpan.Zero, TimeSpan.Zero);

            currentZoom = ZoomLevels.Three;

            Camera = new KarmaCamera(device);
            Camera.Zoom = GetCameraZoom(currentZoom);

            CurrentZoom = currentZoom;
            ZoomingIn = false;
            ZoomingOut = false;
            foreach (ZoomLevels zooms in WorldData.AscendingZooms)
                if (WorldData.Minigames[zooms] != null)
                    WorldData.Minigames[zooms].ResetGame();

            JoustingInput.InitializeInput();

            Camera.Update(new GameTime(TimeSpan.FromSeconds(0.016667), TimeSpan.FromSeconds(0.016667)));
            Camera.Zoom = GetCameraZoom(currentZoom);
        }
开发者ID:heyx3,项目名称:GGJ2014,代码行数:34,代码来源:KarmaWorld.cs

示例7: RoomEditor

 public RoomEditor()
 {
     editorSurface = new RenderTarget2D(Engine.Instance.GraphicsDevice, Engine.WINDOW_WIDTH * 2, Engine.WINDOW_HEIGHT * 2);
     Player p = new Player(Vector2.Zero, this);
     this.objects.Add(p);
     cameraTarget = p;
 }
开发者ID:adamgryu,项目名称:NewBabbleEngine,代码行数:7,代码来源:RoomEditor.cs

示例8: Lightning

        public Lightning(Vector2 p1, Vector2 p2, float width = 2f, int life = 60, int detailLevel = 6, bool sound = false, 
            float volume = 0.1f)
        {
            sound = false;//TODO rm

            MaxLife = life;
            w = width;
            GEN_DEPTH = detailLevel;

            Position = p1;

            float l = (p2 - p1).Length() * 4;
            rot = (float)Math.Atan2(p2.Y - p1.Y, p2.X - p1.X);
            transform = Matrix.CreateRotationZ(rot);
            fbo = new RenderTarget2D(GraphicsEngine.Renderer.GraphicsDevice, (int)l + 64, (int)l + 64);

            GenLightning(new Vector2(32, 32 + l / 2), new Vector2(32 + l, 32 + l / 2));
            var r = GraphicsEngine.Renderer;
            r.EnableFBO(fbo);
            r.GraphicsDevice.Clear(Color.Transparent);
            r.BeginUnscaled();
            DrawFBO(r);
            r.End();
            r.DisableFBO();

            if (sound)
                _sound = Sound.Sounds.tesla.Play(volume, (float)(new Random().Next(-250, 250)) / 1000f, 0f);
        }
开发者ID:XZelnar,项目名称:MicroWorld,代码行数:28,代码来源:Lightning.cs

示例9: 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

示例10: ConvertToPreMultipliedAlphaGPU

        public static Texture2D ConvertToPreMultipliedAlphaGPU(Texture2D texture)
        {
            // code borrowed from http://jakepoz.com/jake_poznanski__speeding_up_xna.html

            // Set up a render target to hold our final texture which will have premulitplied alpha values
            RenderTarget2D result = new RenderTarget2D(device, texture.Width, texture.Height);

            device.SetRenderTarget(result);
            device.Clear(Color.Black);

            // Multiply each color by the source alpha, and write in just the color values into the final texture
            SpriteBatch spriteBatch = new SpriteBatch(device);
            spriteBatch.Begin(SpriteSortMode.Immediate, blendColor);
            spriteBatch.Draw(texture, texture.Bounds, Color.White);
            spriteBatch.End();

            // Now copy over the alpha values from the PNG source texture to the final one, without multiplying them
            spriteBatch.Begin(SpriteSortMode.Immediate, blendAlpha);
            spriteBatch.Draw(texture, texture.Bounds, Color.White);
            spriteBatch.End();

            // Release the GPU back to drawing to the screen
            device.SetRenderTarget(null);

            return result as Texture2D;
        }
开发者ID:zetaPRIME,项目名称:xybrid,代码行数:26,代码来源:GraphicsManager.cs

示例11: FireParticle

        public FireParticle(Vector3 pos, Game1 game, float dist)
        {
            this.model = TextureManager.dirSquare;
            this.game = game;
            startPos = pos;
            scalef = Utilities.nextFloat() + .25f;

            direction.X = (float)Utilities.random.NextDouble() * 2 - 1;
            direction.Y = (float)Utilities.random.NextDouble() * 1.5f - .5f;
            direction.Z = (float)Utilities.random.NextDouble() * 2 - 1;
            direction.Normalize();

            startPos += direction * Utilities.nextFloat() / 2;

            goalPos = pos + direction * dist;
            speed = 4.5f + Utilities.nextFloat();
            alpha = 1;

            rTarg = new RenderTarget2D(game.GraphicsDevice, 128, 128);
            sb = new SpriteBatch(game.GraphicsDevice);

            game.GraphicsDevice.SetRenderTarget(rTarg);
            sb.Begin();
            sb.Draw(TextureManager.pyroFlame, Vector2.Zero, Color.Lerp(Color.Red, Color.White, Utilities.nextFloat()));
            sb.End();
            game.GraphicsDevice.SetRenderTarget(null);
        }
开发者ID:Thinny-Hendrix,项目名称:MoonCow,代码行数:27,代码来源:FireParticle.cs

示例12: Apply

        public void Apply(IPostEffectData data, RenderTarget2D target)
        {
            data.Effect.GraphicsDevice.SetRenderTargets(m_ParticleTarget, m_DataTarget);
            data.Effect.GraphicsDevice.Clear(Color.Transparent);

            data.Effect.CurrentTechnique = data.Effect.Techniques["DrawEmitters"];
            foreach(ParticleEmitter emitter in m_ParticleEngine.Emitters)
                DrawEmitter(data.Device, data.Effect, emitter);

            //merge particletarget with scene
            data.Effect.GraphicsDevice.SetRenderTarget(target);
            data.Effect.Parameters["SceneTexture"].SetValue(data.Scene);
            data.Effect.Parameters["ParticlesTexture"].SetValue(m_ParticleTarget); //debug this shit
            data.Effect.Parameters["ParticleDataTexture"].SetValue(m_DataTarget);

            if (Keyboard.GetState().IsKeyDown(Keys.P))
            {
                Thread.Sleep(1000);
                data.Scene.ToFile("Scene");
                m_ParticleTarget.ToFile("Particle");
                m_DataTarget.ToFile("Data");
            }

            data.Effect.GraphicsDevice.SetVertexBuffer(m_ScreenBuffer.Get().Buffer);
            data.Effect.CurrentTechnique = data.Effect.Techniques["MergeSceneAndParticles"];
            foreach (EffectPass pass in data.Effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                data.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2);
            }
        }
开发者ID:jumonb,项目名称:hideandsneeze,代码行数:31,代码来源:ParticleEffect.cs

示例13: GaussianBlur

        public GaussianBlur(Game game)
        {
            this.game = game;
            this.device = game.GraphicsDevice;
            this.spriteBatch = (game as GameManager).spriteBatch;

            effect = game.Content.Load<Effect>(@"Effects\GaussianBlur");

            // Since we're performing a Gaussian blur on a texture image the
            // render targets are half the size of the source texture image.
            // This will help improve the blurring effect.
            renderTargetWidth = device.Viewport.Width / 4;
            renderTargetHeight = device.Viewport.Height / 4;

            blurHTarget = new RenderTarget2D(device, renderTargetWidth, renderTargetHeight,
                false, SurfaceFormat.Color, DepthFormat.Depth24);
            blurVTarget = new RenderTarget2D(device, renderTargetWidth, renderTargetHeight,
                false, SurfaceFormat.Color, DepthFormat.Depth24);

            Radius = 7;
            Amount = 3.0f;

            ComputeKernel(Radius, Amount);
            ComputeOffsets(renderTargetWidth, renderTargetHeight);
        }
开发者ID:MintL,项目名称:datx02-rally,代码行数:25,代码来源:GaussianBlur.cs

示例14: CreditsScene

        // 188/157!09
        #endregion

        #region Getter & Setter
        #endregion

        #region Constructor
        public CreditsScene()
        {
            isActiv = true;
            _name = "Credits";
            _backgroundColor = Color.Black;

            _partikelTop = new RectanglePartikelEmitter(@"Partikel\circle",new Vector4(0,1280,0,100), 220);
            _partikelTop.SetColor(new Color(255, 223, 76), new Color(145, 24, 25));
            _partikelBottom = new RectanglePartikelEmitter(@"Partikel\circle", new Vector4(0, 1280, 620, 720), 220);
            _partikelBottom.SetColor(new Color(255, 223, 76), new Color(145, 24, 25));
            _partikelLeft = new RectanglePartikelEmitter(@"Partikel\circle", new Vector4(0, 100, 100, 620), 140);
            _partikelLeft.SetColor(new Color(255, 223, 76), new Color(145, 24, 25));
            _partikelRight = new RectanglePartikelEmitter(@"Partikel\circle", new Vector4(1180, 1280, 100, 620), 140);
            _partikelRight.SetColor(new Color(255, 223, 76), new Color(145, 24, 25));

            //_partikelCenter = new CirclePartikelEmitter("circle", new Vector2(640, 360), 500, 180, 0, false);
            //_partikelCenter.SetColor(Color.Green, Color.Yellow);
            //_partikelCenter2 = new CirclePartikelEmitter("circle", new Vector2(640, 360), 500, 220, 0, true);
            //_partikelCenter2.SetColor(Color.Green, Color.Yellow);

            _spriteBatch = new SpriteBatch(SceneManager.Graphics.GraphicsDevice);
            _renderTarget = new RenderTarget2D(SceneManager.Graphics.GraphicsDevice, 1280, 720);

            for(int i = 0; i < 3; i++)
                TextureManager.Instance.LoadContentFromStream(@"\Content\Credits\" + i + ".png", "credits" + i);

            _backgroundColor = new Color(188, 157, 109, 255);
 }
开发者ID:TheEternalCircle,项目名称:TheEternalCircleMasterSolution,代码行数:35,代码来源:CreditsScene.cs

示例15: Water

        public Water(GraphicsDevice device, Texture2D particleTexture)
        {
            pb = new PrimitiveBatch(device);
            this.particleTexture = particleTexture;
            spriteBatch = new SpriteBatch(device);
            metaballTarget = new RenderTarget2D(device, device.Viewport.Width, device.Viewport.Height);
            particlesTarget = new RenderTarget2D(device, device.Viewport.Width, device.Viewport.Height);
            drawTarget = new RenderTarget2D(device, device.Viewport.Width, device.Viewport.Height);
            alphaTest = new AlphaTestEffect(device);
            alphaTest.ReferenceAlpha = 175;

            var view = device.Viewport;
            alphaTest.Projection = Matrix.CreateTranslation(-0.5f, -0.5f, 0) *
                Matrix.CreateOrthographicOffCenter(0, view.Width, view.Height, 0, 0, 1);

            for (int i = 0; i < columns.Length; i++)
            {
                columns[i] = new WaterColumn()
                {
                    Height = 240,
                    TargetHeight = 240,
                    Speed = 0
                };
            }
        }
开发者ID:Zalrioth,项目名称:BitSmith,代码行数:25,代码来源:Water.cs


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