本文整理汇总了C#中IEffect.SetArgument方法的典型用法代码示例。如果您正苦于以下问题:C# IEffect.SetArgument方法的具体用法?C# IEffect.SetArgument怎么用?C# IEffect.SetArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEffect
的用法示例。
在下文中一共展示了IEffect.SetArgument方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Intro
public override void Intro( params object [] args )
{
LiqueurSystem.GraphicsDevice.IsZWriteEnable = true;
LiqueurSystem.GraphicsDevice.CullingMode = CullingMode.None;
LiqueurSystem.GraphicsDevice.ScreenSize = new Vector2 ( 800, 600 );
LiqueurSystem.GraphicsDevice.BlendState = true;
LiqueurSystem.GraphicsDevice.BlendOperation = BlendOperation.AlphaBlend;
vertexShader = LiqueurSystem.GraphicsDevice.CreateShader ( @"#version 120
attribute vec3 a_position;
attribute vec2 a_texcoord;
uniform mat4 proj;
uniform mat4 modelView;
varying vec2 v_texcoord;
void main () {
vec4 pos = vec4(a_position, 1);
pos = modelView * pos;
pos = proj * pos;
gl_Position = pos;
v_texcoord = a_texcoord;
}
", ShaderType.VertexShader );
vertexShader.Option = new ShaderOption ()
{
AttributeOrdering = new ShaderOption.AttributeOrder []
{
new ShaderOption.AttributeOrder () { Name = "a_position", VertexType = FlexibleVertexFormat.PositionXYZ },
new ShaderOption.AttributeOrder () { Name = "a_texcoord", VertexType = FlexibleVertexFormat.TextureUV1 }
}
};
fragShader = LiqueurSystem.GraphicsDevice.CreateShader ( @"#version 120
varying vec2 v_texcoord;
uniform sampler2D texture;
void main () {
gl_FragColor = texture2D ( texture, v_texcoord.st );
}
", ShaderType.FragmentShader );
effect = LiqueurSystem.GraphicsDevice.CreateEffect ( vertexShader, fragShader );
effect.SetArgument<Matrix4x4> ( "modelView", Matrix4x4.Identity * new Daramkun.Liqueur.Mathematics.Transforms.View ( new Vector3 ( -7, 7, 10 ),
new Vector3 ( 0f, 0f, 0f ),
new Vector3 ( 0, 1, 0 ) ).Matrix );
effect.SetArgument<Matrix4x4> ( "proj", new PerspectiveFieldOfViewProjection ( ( float ) Math.PI / 4, 800 / 600.0f, 0.0001f, 1000.0f ).Matrix );
vertexBuffer = LiqueurSystem.GraphicsDevice.CreateVertexBuffer<Vertex> ( FlexibleVertexFormat.PositionXY |
FlexibleVertexFormat.Diffuse, new Vertex []
{
new Vertex ( new Vector2 ( -5.0f, +5.0f ), new Vector2 ( 0, 1 ) ),
new Vertex ( new Vector2 ( +5.0f, -5.0f ), new Vector2 ( 1, 0 ) ),
new Vertex ( new Vector2 ( -5.0f, -5.0f ), new Vector2 ( 0, 0 ) ),
new Vertex ( new Vector2 ( +5.0f, +5.0f ), new Vector2 ( 1, 1 ) ),
} );
indexBuffer = LiqueurSystem.GraphicsDevice.CreateIndexBuffer ( new int [] { 0, 2, 1, 0, 1, 3, } );
texture = LiqueurSystem.GraphicsDevice.CreateTexture2D ( new PngDecoder ().Decode (
Assembly.GetEntryAssembly ().GetManifestResourceStream ( "Test.Windows.CSharp.temp.png" ) )
);
renderBuffer = LiqueurSystem.GraphicsDevice.CreateRenderBuffer ( 1024, 1024 );
sprite = new Sprite ( texture );
font = new LsfFont ( Assembly.GetEntryAssembly ().GetManifestResourceStream ( "Test.Windows.CSharp.temp.lsf" ) );
FpsCalculator calc = new FpsCalculator ();
calc.DrawEvent += ( object sender, GameTimeEventArgs e ) =>
{
string fpsString = string.Format ( "Update FPS: {0:0.00}\nRender FPS: {1:0.00}", calc.UpdateFPS, calc.DrawFPS );
font.DrawFont ( fpsString, Color.Black,
new Vector2 ( 0, LiqueurSystem.GraphicsDevice.ScreenSize.Y - font.MeasureString ( fpsString ).Y ) );
};
Add ( calc );
base.Intro ( args );
}