本文整理汇总了C#中IEffect.CreateParameterSet方法的典型用法代码示例。如果您正苦于以下问题:C# IEffect.CreateParameterSet方法的具体用法?C# IEffect.CreateParameterSet怎么用?C# IEffect.CreateParameterSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEffect
的用法示例。
在下文中一共展示了IEffect.CreateParameterSet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BlitInternal
private void BlitInternal(
IRenderContext renderContext,
Texture2D source,
RenderTarget2D[] destinations = null,
IEffect shader = null,
IEffectParameterSet effectParameterSet = null,
BlendState blendState = null,
Vector2? offset = null,
Vector2? size = null)
{
float destWidth, destHeight;
if (destinations != null)
{
var destinationsBound = new RenderTargetBinding[destinations.Length];
for (var i = 0; i < destinations.Length; i++)
{
// Implicit cast.
destinationsBound[i] = destinations[i];
}
renderContext.PushRenderTarget(destinationsBound);
destWidth = destinations[0].Width;
destHeight = destinations[0].Height;
}
else
{
// TODO: renderContext.GraphicsDevice.GetRenderTargets();
destWidth = renderContext.GraphicsDevice.PresentationParameters.BackBufferWidth;
destHeight = renderContext.GraphicsDevice.PresentationParameters.BackBufferHeight;
}
offset = offset ?? new Vector2(0, 0);
size = size ?? new Vector2(1 - offset.Value.X, 1 - offset.Value.Y);
if (blendState == null)
{
blendState = BlendState.Opaque;
}
if (shader == null)
{
shader = _blitEffect;
}
if (effectParameterSet == null)
{
effectParameterSet = shader.CreateParameterSet();
}
if (_vertexBuffer == null)
{
_vertexBuffer = new VertexBuffer(renderContext.GraphicsDevice, typeof (VertexPositionNormalTexture),
_vertexes.Length, BufferUsage.WriteOnly);
_vertexBuffer.SetData(_vertexes);
}
if (_indexBuffer == null)
{
_indexBuffer = new IndexBuffer(renderContext.GraphicsDevice, typeof (short), _indicies.Length,
BufferUsage.WriteOnly);
_indexBuffer.SetData(_indicies);
}
var oldWorld = renderContext.World;
var oldProjection = renderContext.Projection;
var oldView = renderContext.View;
renderContext.GraphicsDevice.BlendState = blendState;
renderContext.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
renderContext.GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
renderContext.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
renderContext.World = Matrix.CreateScale(destWidth, destHeight, 1);
renderContext.Projection =
#if !PLATFORM_WINDOWS
Matrix.CreateTranslation(-0.5f, -0.5f, 0) *
#endif
Matrix.CreateOrthographicOffCenter(
destWidth * (-offset.Value.X / size.Value.X),
destWidth * (-offset.Value.X / size.Value.X) + destWidth / size.Value.X,
destHeight * (-offset.Value.Y / size.Value.Y) + destHeight / size.Value.Y,
destHeight * (-offset.Value.Y / size.Value.Y),
0,
1);
renderContext.View = Matrix.Identity;
if (source != null && effectParameterSet != null)
{
var semantic = effectParameterSet.GetSemantic<ITextureEffectSemantic>();
if (semantic.Texture != source)
{
semantic.Texture = source;
}
}
renderContext.GraphicsDevice.SetVertexBuffer(_vertexBuffer);
renderContext.GraphicsDevice.Indices = _indexBuffer;
shader.LoadParameterSet(renderContext, effectParameterSet);
foreach (var pass in shader.NativeEffect.CurrentTechnique.Passes)
//.........这里部分代码省略.........