本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.SamplerState类的典型用法代码示例。如果您正苦于以下问题:C# SamplerState类的具体用法?C# SamplerState怎么用?C# SamplerState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SamplerState类属于Microsoft.Xna.Framework.Graphics命名空间,在下文中一共展示了SamplerState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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
示例2: DrawSkybox
private void DrawSkybox()
{
SamplerState ss = new SamplerState();
ss.AddressU = TextureAddressMode.Clamp;
ss.AddressV = TextureAddressMode.Clamp;
Engine.Video.GraphicsDevice.SamplerStates[0] = ss;
DepthStencilState dss = new DepthStencilState();
dss.DepthBufferEnable = false;
Engine.Video.GraphicsDevice.DepthStencilState = dss;
Matrix[] skyboxTransforms = new Matrix[skyboxModel.Bones.Count];
skyboxModel.CopyAbsoluteBoneTransformsTo(skyboxTransforms);
int i = 0;
foreach(ModelMesh mesh in skyboxModel.Meshes) {
foreach(Effect currentEffect in mesh.Effects) {
Matrix worldMatrix = skyboxTransforms[mesh.ParentBone.Index];
currentEffect.CurrentTechnique = currentEffect.Techniques["Textured"];
currentEffect.Parameters["xWorld"].SetValue(worldMatrix);
currentEffect.Parameters["xView"].SetValue(camera.ViewMatrix);
currentEffect.Parameters["xProjection"].SetValue(camera.ProjectionMatrix);
currentEffect.Parameters["xTexture"].SetValue(skyboxTextures[i++]);
}
mesh.Draw();
}
dss = new DepthStencilState();
dss.DepthBufferEnable = true;
Engine.Video.GraphicsDevice.DepthStencilState = dss;
}
开发者ID:PhoenixWright,项目名称:Mystery,代码行数:33,代码来源:Skybox.cs
示例3: DrawTerrainAsset
public void DrawTerrainAsset(TerrainBlock asset)
{
SamplerState s = new SamplerState();
effect.View = viewMatrix;
effect.Projection = projectionMatrix;
s.AddressU = TextureAddressMode.Wrap; s.AddressV = TextureAddressMode.Wrap;
Game.GraphicsDevice.SamplerStates[0] = s;
Game.GraphicsDevice.RasterizerState = new RasterizerState() { CullMode = CullMode.None };
//effect.FogEnabled = true;
//effect.FogStart = 120f;
//effect.FogEnd = 150f;
//effect.FogColor = Color.CornflowerBlue.ToVector3();
effect.TextureEnabled = true;
effect.Texture = asset.GetTexture();
effect.EnableDefaultLighting();
effect.AmbientLightColor = new Vector3(0.5f, 0.5f, 0.5f);
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
pass.Apply();
game.GraphicsDevice.SetVertexBuffer(asset.GetVertexBuffer());
game.GraphicsDevice.Indices = asset.GetIndexBuffer();
game.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, asset.GetVerticesLength(), 0, asset.GetIndicesLength() / 3);
}
//base.Draw(gameTime);
}
开发者ID:ewencluley,项目名称:Basic-Game-Engine,代码行数:26,代码来源:Camera.cs
示例4: 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
示例5: draw
public void draw(Matrix view, Matrix projection, Vector3 playerPosition)
{
SamplerState samplerState = new SamplerState();
samplerState.AddressU = TextureAddressMode.Clamp;
samplerState.AddressV = TextureAddressMode.Clamp;
Game1.getGraphics().GraphicsDevice.SamplerStates[0] = samplerState;
DepthStencilState dss = new DepthStencilState();
dss.DepthBufferEnable = false;
Game1.getGraphics().GraphicsDevice.DepthStencilState = dss;
Matrix[] skyboxTransforms = new Matrix[skyboxModel.Bones.Count];
skyboxModel.CopyAbsoluteBoneTransformsTo(skyboxTransforms);
foreach (ModelMesh mesh in skyboxModel.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
Matrix worldMatrix = skyboxTransforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(playerPosition);
//effect.CurrentTechnique = effect.Techniques["Textured"];
effect.LightingEnabled = true;
effect.AmbientLightColor = new Vector3(1f, 1f, 1f);
effect.EmissiveColor = new Vector3(0.4f, 0.4f, 0.4f);
effect.TextureEnabled = true;
effect.Texture = skyboxTextures;
effect.World = worldMatrix;
effect.View = view;
effect.Projection = projection;
}
mesh.Draw();
}
dss = new DepthStencilState();
dss.DepthBufferEnable = true;
Game1.getGraphics().GraphicsDevice.DepthStencilState = dss;
}
开发者ID:tobeneck,项目名称:WitchMaze,代码行数:35,代码来源:Skybox.cs
示例6: draw
public override void draw(Matrix projection, Matrix camera)
{
SamplerState samplerState = new SamplerState();
samplerState.AddressU = TextureAddressMode.Clamp;
samplerState.AddressV = TextureAddressMode.Clamp;
Game1.getGraphics().GraphicsDevice.SamplerStates[0] = samplerState;
Matrix[] transforms = new Matrix[model.Bones.Count];
model.CopyAbsoluteBoneTransformsTo(transforms);
foreach (ModelMesh mesh in model.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.LightingEnabled = true;
effect.AmbientLightColor = new Vector3(1f, 1f, 1f);
effect.EmissiveColor = new Vector3(1, 1, 1);
//effect.DirectionalLight0.Enabled = true;
effect.DirectionalLight0.Direction = new Vector3(0, 1, 0);
effect.DirectionalLight0.DiffuseColor = new Vector3(1, 0, 0);
//effect.DirectionalLight1.Direction = new Vector3(1, 1, 0);
//effect.DirectionalLight1.DiffuseColor = new Vector3(0, 1, 0);
effect.TextureEnabled = true;
effect.Texture = textur;
effect.View = camera;
effect.Projection = projection;
effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY((float)rotation) * Matrix.CreateScale((float)0.5) * Matrix.CreateTranslation(position);
}
mesh.Draw();
}
}
开发者ID:tobeneck,项目名称:WitchMaze,代码行数:32,代码来源:Floor.cs
示例7: TagRenderer
public TagRenderer(int tag)
{
Tag = tag;
BlendState = BlendState.AlphaBlend;
SamplerState = SamplerState.LinearClamp;
Camera = new Camera();
}
开发者ID:tanis2000,项目名称:MonoGameBunnyMark,代码行数:7,代码来源:TagRenderer.cs
示例8: EffectState
public EffectState(Effect effect, SamplerState sampler, RasterizerState raster, DepthStencilState stencil, bool texture)
{
Effect = effect;
Sampler = sampler;
Raster = raster;
TextureOverride = texture;
}
开发者ID:ZaneDubya,项目名称:YCPU,代码行数:7,代码来源:EffectState.cs
示例9: DrawSkybox
public void DrawSkybox(Camera camera, Vector3 shipPosition)
{
//A TextureAddressMode.Clamp state removes the seams between the cube.
SamplerState ss = new SamplerState();
ss.AddressU = TextureAddressMode.Clamp;
ss.AddressV = TextureAddressMode.Clamp;
_device.SamplerStates[0] = ss;
//Removes the ZBuffer so no size can be set for the skybox.
DepthStencilState dss = new DepthStencilState();
dss.DepthBufferEnable = false;
_device.DepthStencilState = dss;
Matrix[] transforms = new Matrix[_skyboxModel.Bones.Count]; //Represents the position of each model bone.
_skyboxModel.CopyAbsoluteBoneTransformsTo(transforms); //Models have a method that populates an array.
foreach (ModelMesh mesh in _skyboxModel.Meshes)
{
//BasicEffect is a simplified version of it's parent class Effect. Effects allow objects to be placed on screen.
foreach (BasicEffect basicEffect in mesh.Effects)
{
basicEffect.Projection = camera.Projection;
basicEffect.View = camera.View;
basicEffect.World = Matrix.CreateScale(80) * mesh.ParentBone.Transform * Matrix.CreateTranslation(shipPosition); //Positions the mesh in the correct place relavent to the world.
}
mesh.Draw();
}
//Reenabling the ZBuffer.
dss = new DepthStencilState();
dss.DepthBufferEnable = true;
_device.DepthStencilState = dss;
}
开发者ID:robertg,项目名称:Soar,代码行数:34,代码来源:Skybox.cs
示例10: TagExcludeRenderer
public TagExcludeRenderer(int excludeTag)
{
ExcludeTag = excludeTag;
BlendState = BlendState.AlphaBlend;
SamplerState = SamplerState.LinearClamp;
Camera = new Camera();
}
开发者ID:tanis2000,项目名称:MonoGameBunnyMark,代码行数:7,代码来源:TagExcludeRenderer.cs
示例11: 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
示例12: Draw
/// <summary>
/// Does the actual drawing of the skybox with our skybox effect.
/// There is no world matrix, because we're assuming the skybox won't
/// be moved around. The size of the skybox can be changed with the size
/// variable.
/// </summary>
/// <param name="view">The view matrix for the effect</param>
/// <param name="projection">The projection matrix for the effect</param>
/// <param name="cameraPosition">The position of the camera</param>
public override void Draw(GameTime gameTime)
{
GraphicsDevice device = game.GraphicsDevice;
SamplerState ss = new SamplerState();
ss.AddressU = TextureAddressMode.Clamp;
ss.AddressV = TextureAddressMode.Clamp;
device.SamplerStates[0] = ss;
DepthStencilState dss = new DepthStencilState();
dss.DepthBufferEnable = false;
device.DepthStencilState = dss;
Matrix[] skyboxTransforms = new Matrix[skyboxModel.Bones.Count];
skyboxModel.CopyAbsoluteBoneTransformsTo(skyboxTransforms);
int i = 0;
foreach (ModelMesh mesh in skyboxModel.Meshes)
{
foreach (BasicEffect currentEffect in mesh.Effects)
{
Matrix worldMatrix = skyboxTransforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(camera.position);
currentEffect.World = worldMatrix;
currentEffect.View = camera.view;
currentEffect.Projection = camera.projection;
currentEffect.TextureEnabled=true;
currentEffect.Texture = skyboxTextures[i++];
}
mesh.Draw();
}
dss = new DepthStencilState();
dss.DepthBufferEnable = true;
device.DepthStencilState = dss;
}
开发者ID:ewencluley,项目名称:Space1939,代码行数:44,代码来源:Skybox.cs
示例13: 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
示例14: DownColorTexture
/// <summary>
/// DownSample a Color Texture (using hardware Linear filtering, cant be used on Single/float Textures)
/// </summary>
/// <param name="render">The render.</param>
/// <param name="Texture2D">The texture2 D.</param>
/// <param name="SamplerState">State of the sampler.</param>
/// <returns></returns>
public Texture2D DownColorTexture(RenderHelper render, Texture2D Texture2D, SamplerState SamplerState)
{
render.PushRenderTarget(RenderTarget2D);
render.RenderTextureComplete(Texture2D, Color.White,
Rectangle, Matrix.Identity, Texture2D.Bounds,
true, SpriteSortMode.Deferred, SamplerState);
return render.PopRenderTargetAsSingleRenderTarget2D();
}
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:15,代码来源:DownSampler.cs
示例15: Draw
public override void Draw(GraphicsDevice device, Camera camera)
{
SamplerState ss = new SamplerState();
ss.AddressU = TextureAddressMode.Wrap;
ss.AddressV = TextureAddressMode.Wrap;
device.SamplerStates[0] = ss;
base.Draw(device, camera);
}
开发者ID:ji6878,项目名称:week9bonus,代码行数:8,代码来源:Ground.cs
示例16: Initialize
public override void Initialize()
{
base.Initialize();
SamplerState customState = new SamplerState();
customState.Filter = TextureFilter.Linear;
GraphicsDevice.SamplerStates[0] = customState;
isInitialized = true;
}
开发者ID:kralle333,项目名称:Monogame-Library,代码行数:8,代码来源:ScreenManager.cs
示例17: handleFinalRender
public void handleFinalRender( Color letterboxColor, RenderTarget2D source, Rectangle finalRenderDestinationRect, SamplerState samplerState )
{
// we can just draw directly to the screen here with our effect
Core.graphicsDevice.setRenderTarget( null );
Core.graphicsDevice.Clear( letterboxColor );
Graphics.instance.batcher.begin( BlendState.Opaque, samplerState, DepthStencilState.None, RasterizerState.CullNone, effect );
Graphics.instance.batcher.draw( source, finalRenderDestinationRect, Color.White );
Graphics.instance.batcher.end();
}
开发者ID:RastaCow,项目名称:Nez,代码行数:9,代码来源:PixelMosaicRenderDelegate.cs
示例18: SamplerState
static SamplerState()
{
AnisotropicClamp = new SamplerState("SamplerState.AnisotropicClamp", TextureFilter.Anisotropic, TextureAddressMode.Clamp);
AnisotropicWrap = new SamplerState("SamplerState.AnisotropicWrap", TextureFilter.Anisotropic, TextureAddressMode.Wrap);
LinearClamp = new SamplerState("SamplerState.LinearClamp", TextureFilter.Linear, TextureAddressMode.Clamp);
LinearWrap = new SamplerState("SamplerState.LinearWrap", TextureFilter.Linear, TextureAddressMode.Wrap);
PointClamp = new SamplerState("SamplerState.PointClamp", TextureFilter.Point, TextureAddressMode.Clamp);
PointWrap = new SamplerState("SamplerState.PointWrap", TextureFilter.Point, TextureAddressMode.Wrap);
}
开发者ID:BrainSlugs83,项目名称:MonoGame,代码行数:9,代码来源:SamplerState.cs
示例19: Begin
public void Begin(SpriteSortMode sortMode, BlendState blendState)
{
_sortMode = sortMode;
_blendState = (blendState == null) ? BlendState.AlphaBlend : blendState;
_depthStencilState = DepthStencilState.None;
_samplerState = SamplerState.LinearClamp;
_rasterizerState = RasterizerState.CullCounterClockwise;
_matrix = Matrix.Identity;
}
开发者ID:Jorgemagic,项目名称:MonoGame,代码行数:9,代码来源:SpriteBatch.cs
示例20: TTSpriteBatch
/// <summary>
/// construct a TTSpriteBatch with custom rendering parameters for the batch
/// </summary>
public TTSpriteBatch(GraphicsDevice gfx, SpriteSortMode ssm, BlendState bs, SamplerState ss, DepthStencilState dss, RasterizerState rs, Effect fx)
: base(gfx)
{
spriteSortMode = ssm;
blendState = bs;
samplerState = ss;
depthStencilState = dss;
rasterizerState = rs;
effect = fx;
}
开发者ID:IndiegameGarden,项目名称:TTengine,代码行数:13,代码来源:TTSpriteBatch.cs
注:本文中的Microsoft.Xna.Framework.Graphics.SamplerState类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论