當前位置: 首頁>>代碼示例>>C#>>正文


C# Graphics.BlendState類代碼示例

本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.BlendState的典型用法代碼示例。如果您正苦於以下問題:C# BlendState類的具體用法?C# BlendState怎麽用?C# BlendState使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BlendState類屬於Microsoft.Xna.Framework.Graphics命名空間,在下文中一共展示了BlendState類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Level

        public Level(int _index)
        {
            random = new Random();
            removeQueue = new Queue<GameObject>();
            font = Main.font;
            prop = 0.08f;
            lightable = new List<Point>();
            nullColor = new Color(0, 0, 0, 0);
            multiply = new BlendState()
            {
                AlphaSourceBlend = Blend.DestinationAlpha,
                AlphaDestinationBlend = Blend.Zero,
                AlphaBlendFunction = BlendFunction.Add,
                ColorSourceBlend = Blend.DestinationColor,
                ColorDestinationBlend = Blend.Zero,
                ColorBlendFunction = BlendFunction.Add
            };
            index = _index;
            lightSources = new List<LightSource>();
            objects = new List<GameObject>();
            charMap = Managers.Executive.levels[index][0];
            backCharMap = Managers.Executive.levels[index][1];
            tileMap = new Tile[charMap.GetLength(0), charMap.GetLength(1)];
            backTileMap = new Tile[charMap.GetLength(0), charMap.GetLength(1)];
            lightMap = new Light[charMap.GetLength(0), charMap.GetLength(1)];

        }
開發者ID:AaronCC,項目名稱:Dread-Dungeon,代碼行數:27,代碼來源:Level.cs

示例2: DeferredRenderer

        public DeferredRenderer(GraphicsDevice GraphicsDevice, int Width, int Height)
            : base(GraphicsDevice)
        {
            //Create LightMap BlendState
            LightMapBS = new BlendState();
            LightMapBS.ColorSourceBlend = Blend.One;
            LightMapBS.ColorDestinationBlend = Blend.One;
            LightMapBS.ColorBlendFunction = BlendFunction.Add;
            LightMapBS.AlphaSourceBlend = Blend.One;
            LightMapBS.AlphaDestinationBlend = Blend.One;
            LightMapBS.AlphaBlendFunction = BlendFunction.Add;

            //Set GBuffer Texture Size
            GBufferTextureSize = new Vector2(Width, Height);

            //Intialize Each Target of the GBuffer
            GBufferTargets = new RenderTargetBinding[3];
            GBufferTargets[0] = new RenderTargetBinding(new RenderTarget2D(GraphicsDevice, Width, Height, false, SurfaceFormat.Rgba64, DepthFormat.Depth24Stencil8));
            GBufferTargets[1] = new RenderTargetBinding(new RenderTarget2D(GraphicsDevice, Width, Height, false, SurfaceFormat.Rgba64, DepthFormat.Depth24Stencil8));
            GBufferTargets[2] = new RenderTargetBinding(new RenderTarget2D(GraphicsDevice, Width, Height, false, SurfaceFormat.Vector2, DepthFormat.Depth24Stencil8));

            //Initialize LightMap
            LightMap = new RenderTarget2D(GraphicsDevice, Width, Height, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8);

            //Create Fullscreen Quad
            fsq = new FullscreenQuad(GraphicsDevice);
        }
開發者ID:scotttorgeson,項目名稱:HeroesOfRock,代碼行數:27,代碼來源:DeferredRenderer.cs

示例3: Draw

        public override void Draw(GameTime gameTime)
        {
            BlendState blend = new BlendState();
            blend.ColorBlendFunction = BlendFunction.Add;
            blend.ColorSourceBlend = Blend.One;
            blend.ColorDestinationBlend = Blend.One;

            sprites.Begin(SpriteSortMode.Immediate, blend);
            lock (notes)
            {
                foreach (Note note in notes)
                    sprites.Draw(note.Texture, new Rectangle((int)note.Position.X, (int)note.Position.Y, (int)(note.Scale * (float)note.Texture.Width/8), (int)(note.Scale * (float)note.Texture.Height/8)), new Color((float)note.Time, (float)note.Time, (float)note.Time));
            }

            sprites.Draw(square, new Rectangle(0, 0, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height), new Color(White.Value, White.Value, White.Value));

            sprites.End();

            blend = new BlendState();
            blend.ColorBlendFunction = BlendFunction.Add;
            blend.ColorSourceBlend = Blend.Zero;
            blend.ColorDestinationBlend = Blend.InverseSourceColor;

            sprites.Begin(SpriteSortMode.Immediate, blend);
            sprites.Draw(square, new Rectangle(0, 0, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height), new Color(Black.Value, Black.Value, Black.Value));

            sprites.End();

            base.Draw(gameTime);
        }
開發者ID:Grutn,項目名稱:B.rain-project,代碼行數:30,代碼來源:FlyingNotes.cs

示例4: HighlightModule

 static HighlightModule()
 {
     var color = Color.Black;
     CubeVerticies = new[]
     {
         new VertexPositionColor(new XVector3(0, 0, 1), color),
         new VertexPositionColor(new XVector3(1, 0, 1), color),
         new VertexPositionColor(new XVector3(1, 1, 1), color),
         new VertexPositionColor(new XVector3(0, 1, 1), color),
         new VertexPositionColor(new XVector3(0, 0, 0), color),
         new VertexPositionColor(new XVector3(1, 0, 0), color),
         new VertexPositionColor(new XVector3(1, 1, 0), color),
         new VertexPositionColor(new XVector3(0, 1, 0), color)
     };
     CubeIndicies = new short[]
     {
         0, 1,   1, 2,   2, 3,   3, 0,
         0, 4,   4, 7,   7, 6,   6, 2,
         1, 5,   5, 4,   3, 7,   6, 5
     };
     DestructionBlendState = new BlendState
     {
         ColorSourceBlend = Blend.DestinationColor,
         ColorDestinationBlend = Blend.SourceColor,
         AlphaSourceBlend = Blend.DestinationAlpha,
         AlphaDestinationBlend = Blend.SourceAlpha
     };
     RasterizerState = new RasterizerState
     {
         DepthBias = -3,
         SlopeScaleDepthBias = -3
     };
 }
開發者ID:Zoxive,項目名稱:TrueCraft,代碼行數:33,代碼來源:HighlightModule.cs

示例5: InvalidOperationException

        /// <summary>
        /// Begins a new sprite and text batch with the specified render state.
        /// </summary>
        /// <param name="sortMode">The drawing order for sprite and text drawing. <see cref="SpriteSortMode.Deferred"/> by default.</param>
        /// <param name="blendState">State of the blending. Uses <see cref="BlendState.AlphaBlend"/> if null.</param>
        /// <param name="samplerState">State of the sampler. Uses <see cref="SamplerState.LinearClamp"/> if null.</param>
        /// <param name="depthStencilState">State of the depth-stencil buffer. Uses <see cref="DepthStencilState.None"/> if null.</param>
        /// <param name="rasterizerState">State of the rasterization. Uses <see cref="RasterizerState.CullCounterClockwise"/> if null.</param>
        /// <param name="effect">A custom <see cref="Effect"/> to override the default sprite effect. Uses default sprite effect if null.</param>
        /// <param name="transformMatrix">An optional matrix used to transform the sprite geometry. Uses <see cref="Matrix.Identity"/> if null.</param>
        /// <exception cref="InvalidOperationException">Thrown if <see cref="Begin"/> is called next time without previous <see cref="End"/>.</exception>
        /// <remarks>This method uses optional parameters.</remarks>
        /// <remarks>The <see cref="Begin"/> Begin should be called before drawing commands, and you cannot call it again before subsequent <see cref="End"/>.</remarks>
        public void Begin
        (
             SpriteSortMode sortMode = SpriteSortMode.Deferred,
             BlendState blendState = null,
             SamplerState samplerState = null,
             DepthStencilState depthStencilState = null,
             RasterizerState rasterizerState = null,
             Effect effect = null,
             Matrix? transformMatrix = null
        )
        {
            if (_beginCalled)
                throw new InvalidOperationException("Begin cannot be called again until End has been successfully called.");

            // defaults
            _sortMode = sortMode;
            _blendState = blendState ?? BlendState.AlphaBlend;
            _samplerState = samplerState ?? SamplerState.LinearClamp;
            _depthStencilState = depthStencilState ?? DepthStencilState.None;
            _rasterizerState = rasterizerState ?? RasterizerState.CullCounterClockwise;
            _effect = effect;
            _matrix = transformMatrix ?? Matrix.Identity;

            // Setup things now so a user can change them.
            if (sortMode == SpriteSortMode.Immediate)
            {
                Setup();
            }

            _beginCalled = true;
        }
開發者ID:KennethYap,項目名稱:MonoGame,代碼行數:44,代碼來源:SpriteBatch.cs

示例6: LineDrawer

        public LineDrawer(Game game)
        {
            this.game = game;
            lineDrawer = new BasicEffect(game.GraphicsDevice);

            //Set up the default type mapping.
            displayTypes.Add(typeof(PointOnPlaneJoint), typeof(DisplayPointOnPlaneJoint));
            displayTypes.Add(typeof(SwivelHingeAngularJoint), typeof(DisplaySwivelHingeAngularJoint));
            displayTypes.Add(typeof(PointOnLineJoint), typeof(DisplayPointOnLineJoint));
            displayTypes.Add(typeof(BallSocketJoint), typeof(DisplayBallSocketJoint));
            displayTypes.Add(typeof(TwistJoint), typeof(DisplayTwistJoint));
            displayTypes.Add(typeof(TwistMotor), typeof(DisplayTwistMotor));
            displayTypes.Add(typeof(DistanceLimit), typeof(DisplayDistanceLimit));
            displayTypes.Add(typeof(DistanceJoint), typeof(DisplayDistanceJoint));
            displayTypes.Add(typeof(LinearAxisLimit), typeof(DisplayLinearAxisLimit));
            displayTypes.Add(typeof(EllipseSwingLimit), typeof(DisplayEllipseSwingLimit));
            displayTypes.Add(typeof(SingleEntityLinearMotor), typeof(DisplaySingleEntityLinearMotor));
            displayTypes.Add(typeof(RevoluteLimit), typeof(DisplayRevoluteLimit));

            blendState = new BlendState();
            blendState.ColorSourceBlend = Blend.SourceAlpha;
            blendState.AlphaSourceBlend = Blend.SourceAlpha;
            blendState.AlphaDestinationBlend = Blend.InverseSourceAlpha;
            blendState.ColorDestinationBlend = Blend.InverseSourceAlpha;
        }
開發者ID:EugenyN,項目名稱:BEPUphysicsMG,代碼行數:25,代碼來源:LineDrawer.cs

示例7: DrawPolygons

        public void DrawPolygons(Vector2 position, float angle, float scale,
            Texture2D texture, VertexPositionTexture[] vertices, BlendState blendMode)
        {
            effect.World = Matrix.CreateRotationZ(angle) *
                Matrix.CreateScale(scale) *
                Matrix.CreateTranslation(new Vector3(position, 0));
            effect.Texture = texture;

            GraphicsDevice device = GameEngine.Instance.GraphicsDevice;

            if (blendMode == BlendState.AlphaBlend)
            {
                device.BlendState = BlendState.AlphaBlend;
            }
            else if (blendMode == BlendState.Additive)
            {
                device.BlendState = BlendState.Additive;
            }
            SamplerState s = new SamplerState();
            s.AddressU = TextureAddressMode.Wrap;
            s.AddressV = TextureAddressMode.Wrap;
            device.SamplerStates[0] = s;

            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                device.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, vertices, 0, vertices.Length / 3);
                //pass.Apply();
            }
        }
開發者ID:danielpcox,項目名稱:Crisis-at-Swiss-Station,代碼行數:30,代碼來源:PolygonDrawer.cs

示例8: RenderLayer

 public RenderLayer(Vector2 parallax_vector, String layer_name, BlendState blend_state)
 {
     name = layer_name;
     visible = true;
     parallax = parallax_vector;
     blending = blend_state;
 }
開發者ID:Gayo,項目名稱:XNAVERGE,代碼行數:7,代碼來源:RenderLayer.cs

示例9: Start

        /// <summary>
        /// Starts the specified batch.
        /// </summary>
        /// <param name="batch">The batch.</param>
        /// <param name="useCamera">if set to <c>true</c> camera matrix will be applied.</param>
        /// <param name="sortMode">The sort mode.</param>
        /// <param name="blendState">State of the blend.</param>
        /// <param name="samplerState">State of the sampler.</param>
        /// <param name="depthStencilState">State of the depth stencil.</param>
        /// <param name="rasterizerState">State of the rasterizer.</param>
        /// <param name="effect">The effect.</param>
        /// <param name="transform">The transformation matrix.</param>
        public static void Start(this SpriteBatch batch,
            bool useCamera = false,
            SpriteSortMode sortMode = SpriteSortMode.Deferred,
            BlendState blendState = null,
            SamplerState samplerState = null,
            DepthStencilState depthStencilState = null,
            RasterizerState rasterizerState = null,
            Effect effect = null,
            Matrix? transform = null)
        {
            Matrix matrix = AlmiranteEngine.IsWinForms ? Matrix.Identity : AlmiranteEngine.Settings.Resolution.Matrix;

            if (useCamera)
            {
                matrix = AlmiranteEngine.Camera.Matrix * matrix;
            }

            if (transform.HasValue)
            {
                matrix = transform.Value * matrix;
            }

            BatchExtensions._sortMode = sortMode;
            BatchExtensions._blendState = blendState;
            BatchExtensions._samplerState = samplerState;
            BatchExtensions._depthStencilState = depthStencilState;
            BatchExtensions._rasterizerState = rasterizerState;
            BatchExtensions._effect = effect;
            BatchExtensions._matrix = matrix;

            batch.Begin(sortMode, blendState, samplerState, depthStencilState, rasterizerState, effect, matrix);
        }
開發者ID:WoLfulus,項目名稱:Almirante,代碼行數:44,代碼來源:BatchStart.cs

示例10: EffectPass

        internal EffectPass(    Effect effect, 
                                string name,
                                Shader vertexShader, 
                                Shader pixelShader, 
                                BlendState blendState, 
                                DepthStencilState depthStencilState, 
                                RasterizerState rasterizerState,
                                EffectAnnotationCollection annotations )
        {
            Debug.Assert(effect != null, "Got a null effect!");
            Debug.Assert(annotations != null, "Got a null annotation collection!");

            _effect = effect;

            Name = name;

            _vertexShader = vertexShader;
            _pixelShader = pixelShader;

            _blendState = blendState;
            _depthStencilState = depthStencilState;
            _rasterizerState = rasterizerState;

            Annotations = annotations;
        }
開發者ID:KennethYap,項目名稱:MonoGame,代碼行數:25,代碼來源:EffectPass.cs

示例11:

 protected override void InitialiserParamètresEffetDeBase()
 {
    EffetDeBase.TextureEnabled = true;
    EffetDeBase.Texture = Texture;
    GestionAlpha = BlendState.AlphaBlend;
    
 }
開發者ID:HazWard,項目名稱:Tank3D,代碼行數:7,代碼來源:PlanTexturé.cs

示例12: ImperativeRenderer

        public ImperativeRenderer(
            IBatchContainer container,
            DefaultMaterialSet materials,
            int layer = 0, 
            RasterizerState rasterizerState = null,
            DepthStencilState depthStencilState = null,
            BlendState blendState = null,
            SamplerState samplerState = null,
            bool worldSpace = true,
            bool useZBuffer = false,
            bool autoIncrementSortKey = false,
            bool autoIncrementLayer = false
        )
        {
            if (container == null)
                throw new ArgumentNullException("container");
            if (materials == null)
                throw new ArgumentNullException("materials");

            Container = container;
            Materials = materials;
            Layer = layer;
            RasterizerState = rasterizerState;
            DepthStencilState = depthStencilState;
            BlendState = blendState;
            SamplerState = samplerState;
            UseZBuffer = useZBuffer;
            WorldSpace = worldSpace;
            AutoIncrementSortKey = autoIncrementSortKey;
            AutoIncrementLayer = autoIncrementLayer;
            NextSortKey = 0;
            PreviousBatch = null;
        }
開發者ID:pakoito,項目名稱:Fracture,代碼行數:33,代碼來源:Convenience.cs

示例13: DoAsserts

        private static void DoAsserts(BlendState blendState, Action<TestDelegate> assertMethod)
        {
            assertMethod(() => blendState.AlphaBlendFunction = BlendFunction.Add);
            assertMethod(() => blendState.AlphaDestinationBlend = Blend.BlendFactor);
            assertMethod(() => blendState.AlphaSourceBlend = Blend.BlendFactor);
            assertMethod(() => blendState.BlendFactor = Color.White);
            assertMethod(() => blendState.ColorBlendFunction = BlendFunction.Add);
            assertMethod(() => blendState.ColorDestinationBlend = Blend.BlendFactor);
            assertMethod(() => blendState.ColorSourceBlend = Blend.BlendFactor);
            assertMethod(() => blendState.ColorWriteChannels = ColorWriteChannels.All);
            assertMethod(() => blendState.ColorWriteChannels1 = ColorWriteChannels.All);
            assertMethod(() => blendState.ColorWriteChannels2 = ColorWriteChannels.All);
            assertMethod(() => blendState.ColorWriteChannels3 = ColorWriteChannels.All);
#if !XNA
            assertMethod(() => blendState.IndependentBlendEnable = true);
#endif
            assertMethod(() => blendState.MultiSampleMask = 0);

#if !XNA
            for (var i = 0; i < 4; i++)
            {
                assertMethod(() => blendState[0].AlphaBlendFunction = BlendFunction.Add);
                assertMethod(() => blendState[0].AlphaDestinationBlend = Blend.BlendFactor);
                assertMethod(() => blendState[0].AlphaSourceBlend = Blend.BlendFactor);
                assertMethod(() => blendState[0].ColorBlendFunction = BlendFunction.Add);
                assertMethod(() => blendState[0].ColorDestinationBlend = Blend.BlendFactor);
                assertMethod(() => blendState[0].ColorSourceBlend = Blend.BlendFactor);
                assertMethod(() => blendState[0].ColorWriteChannels = ColorWriteChannels.All);
            }
#endif
        }
開發者ID:KennethYap,項目名稱:MonoGame,代碼行數:31,代碼來源:BlendStateTest.cs

示例14: BlendState

 static BlendState()
 {
     AlphaBlend = new BlendState(Blend.One, Blend.InverseSourceAlpha, "BlendState.AlphaBlend");
     NonPremultiplied = new BlendState(Blend.SourceAlpha, Blend.InverseSourceAlpha, "BlendState.NonPremultiplied");
     Additive = new BlendState(Blend.SourceAlpha, Blend.One, "BlendState.Additive");
     Opaque = new BlendState(Blend.One, Blend.Zero, "BlendState.Opaque");
 }
開發者ID:jlyonsmith,項目名稱:ExEnCopy,代碼行數:7,代碼來源:BlendState.cs

示例15: DefaultLightContext

 public DefaultLightContext(
     Texture2D deferredColorMap, 
     Texture2D deferredNormalMap,
     Texture2D deferredDepthMap, 
     Texture2D deferredSpecularMap,
     RenderTarget2D diffuseLightRenderTarget,
     RenderTarget2D specularLightRenderTarget,
     BlendState lightBlendState,
     RasterizerState rasterizerStateCullNone,
     RasterizerState rasterizerStateCullClockwiseFace, 
     RasterizerState rasterizerStateCullCounterClockwiseFace, 
     Vector2 halfPixel)
 {
     DeferredColorMap = deferredColorMap;
     DeferredNormalMap = deferredNormalMap;
     DeferredDepthMap = deferredDepthMap;
     DeferredSpecularMap = deferredSpecularMap;
     DiffuseLightRenderTarget = diffuseLightRenderTarget;
     SpecularLightRenderTarget = specularLightRenderTarget;
     LightBlendState = lightBlendState;
     RasterizerStateCullNone = rasterizerStateCullNone;
     RasterizerStateCullClockwiseFace = rasterizerStateCullClockwiseFace;
     RasterizerStateCullCounterClockwiseFace = rasterizerStateCullCounterClockwiseFace;
     HalfPixel = halfPixel;
 }
開發者ID:RedpointGames,項目名稱:Protogame,代碼行數:25,代碼來源:DefaultLightContext.cs


注:本文中的Microsoft.Xna.Framework.Graphics.BlendState類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。