本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.BlendState类的典型用法代码示例。如果您正苦于以下问题:C# BlendState类的具体用法?C# BlendState怎么用?C# BlendState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlendState类属于Microsoft.Xna.Framework.Graphics命名空间,在下文中一共展示了BlendState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: TagRenderer
public TagRenderer(int tag)
{
Tag = tag;
BlendState = BlendState.AlphaBlend;
SamplerState = SamplerState.LinearClamp;
Camera = new Camera();
}
开发者ID:tanis2000,项目名称:MonoGameBunnyMark,代码行数:7,代码来源:TagRenderer.cs
示例17: CreateInstancedRequest
public IRenderRequest CreateInstancedRequest(IRenderContext renderContext, RasterizerState rasterizerState,
BlendState blendState, DepthStencilState depthStencilState, IEffect effect, IEffectParameterSet effectParameterSet,
VertexBuffer meshVertexBuffer, IndexBuffer meshIndexBuffer, PrimitiveType primitiveType,
Matrix[] instanceWorldTransforms, Action<List<Matrix>, VertexBuffer, IndexBuffer> computeCombinedBuffers)
{
throw new NotImplementedException();
}
开发者ID:RedpointGames,项目名称:Protogame,代码行数:7,代码来源:NullRenderBatcher.cs
示例18: TagExcludeRenderer
public TagExcludeRenderer(int excludeTag)
{
ExcludeTag = excludeTag;
BlendState = BlendState.AlphaBlend;
SamplerState = SamplerState.LinearClamp;
Camera = new Camera();
}
开发者ID:tanis2000,项目名称:MonoGameBunnyMark,代码行数:7,代码来源:TagExcludeRenderer.cs
示例19: BlendState
static BlendState()
{
Additive = new BlendState () {
ColorSourceBlend = Blend.SourceAlpha,
AlphaSourceBlend = Blend.SourceAlpha,
ColorDestinationBlend = Blend.One,
AlphaDestinationBlend = Blend.One
};
AlphaBlend = new BlendState () {
ColorSourceBlend = Blend.One,
AlphaSourceBlend = Blend.One,
ColorDestinationBlend = Blend.InverseSourceAlpha,
AlphaDestinationBlend = Blend.InverseSourceAlpha
};
NonPremultiplied = new BlendState () {
ColorSourceBlend = Blend.SourceAlpha,
AlphaSourceBlend = Blend.SourceAlpha,
ColorDestinationBlend = Blend.InverseSourceAlpha,
AlphaDestinationBlend = Blend.InverseSourceAlpha
};
Opaque = new BlendState () {
ColorSourceBlend = Blend.One,
AlphaSourceBlend = Blend.One,
ColorDestinationBlend = Blend.Zero,
AlphaDestinationBlend = Blend.Zero
};
}
开发者ID:rash-pro,项目名称:MonoGame,代码行数:30,代码来源:BlendState.cs
示例20: OnInit
protected override void OnInit()
{
base.OnInit();
Texture2D texture = Texture;
dtAfterGolUpdate = 0f;
golUpdatePeriod = 60f / 140f;
needFirstUpdate = true;
spriteBatch = new SpriteBatch(Screen.graphicsDevice);
eff = TTengineMaster.ActiveGame.Content.Load<Effect>("Effects/GoL");
effTime = eff.Parameters["Time"];
effDeltaPixelX = eff.Parameters["DeltaPixelX"];
effDeltaPixelY = eff.Parameters["DeltaPixelY"];
effDoGolUpdate = eff.Parameters["DoGolUpdate"];
effDeltaPixelX.SetValue(1f/((float)texture.Width));
effDeltaPixelY.SetValue(1f / ((float)texture.Height));
VertexShaderInit(eff);
renderBufInput = new RenderTarget2D(spriteBatch.GraphicsDevice, texture.Width, texture.Height);
renderBufOutput = new RenderTarget2D(spriteBatch.GraphicsDevice, texture.Width, texture.Height);
blendState = new BlendState();
blendState.AlphaDestinationBlend = Blend.Zero;
// first time rendering into buffer using BufferInit technique
eff.CurrentTechnique = eff.Techniques[0];
spriteBatch.Begin(SpriteSortMode.Deferred,blendState,null,null,null,eff);
spriteBatch.GraphicsDevice.SetRenderTarget(renderBufInput);
spriteBatch.Draw(texture, renderBufInput.Bounds, Color.White);
spriteBatch.End();
}
开发者ID:IndiegameGarden,项目名称:TTR,代码行数:30,代码来源:GoLEffect.cs
注:本文中的Microsoft.Xna.Framework.Graphics.BlendState类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论