Game Development Reference
In-Depth Information
We have variables to represent the vertex shader and its constant table.
We have a teapot mesh variable, followed by a set of D3DXHANDLE s
whose variable names describe the variable they refer to.
The Setup function performs the following tasks:
Creates the teapot mesh
Compiles the vertex shader
Creates the vertex shader based on the compiled code
Obtains handles to several variables in the shader program through
the constant table
Initializes several of the shader variables through the constant
table
Note: For this application our vertex structure does not require any
additional components that a flexible vertex format cannot describe.
Therefore, we use a flexible vertex format instead of a vertex declara-
tion for this sample. Recall that a flexible vertex format description gets
converted to a vertex declaration internally.
bool Setup()
{
HRESULT hr = 0;
//
// Create geometry:
//
D3DXCreateTeapot(Device, &Teapot, 0);
//
// Compile shader
//
ID3DXBuffer* shader = 0;
ID3DXBuffer* errorBuffer = 0;
hr = D3DXCompileShaderFromFile(
"diffuse.txt",
0,
0,
"Main", // entry point function name
"vs_1_1",
D3DXSHADER_DEBUG,
&shader,
&errorBuffer,
&DiffuseConstTable);
// output any error messages
if( errorBuffer )
{
::MessageBox(0, (char*)errorBuffer->GetBufferPointer(), 0, 0);
d3d::Release<ID3DXBuffer*>(errorBuffer);
Team-Fly ®
Search WWH ::




Custom Search