Game Development Reference
In-Depth Information
With that done, we need to create two more initialization functions: one will initialize
our shaders, and the other will initialize our geometry (the triangle we are going to
draw).
Initializing the shaders
We will create a new method named InitShaders() to initialize our shaders for
us. In this demo, we will set up both a vertex shader and a pixel shader. The follow-
ing is the code for this method:
public void InitShaders()
{
// Load and compile the vertex shader
string vsCompileError = "Vertex Shader
Compile Error!!!";
using (var bytecode
=ShaderBytecode.CompileFromFile("Effects.fx","Vertex_Shader","vs_4_0",ShaderFlags.Debug,SlimDX.D3DCompiler.EffectFlags.None,null,null,out
vsCompileError))
{
m_VShaderSignature =
ShaderSignature.GetInputSignature(bytecode);
m_VertexShader = new
VertexShader(m_Device, bytecode);
}
// Load and compile the pixel shader
string psCompileError = "Pixel Shader
Compile Error!!!";
using (var bytecode
=ShaderBytecode.CompileFromFile("Effects.fx","Pixel_Shader","ps_4_0",ShaderFlags.Debug,SlimDX.D3DCompiler.EffectFlags.None,null,null,out
psCompileError))
{
m_PixelShader = new
PixelShader(m_Device, bytecode);
}
}
Search WWH ::




Custom Search