Game Development Reference
In-Depth Information
effect instances. In this topic we specify null for this parameter,
indicating that we do not share parameters between effect files.
ppEffect —Returns a pointer to an ID3DXEffect interface rep-
resenting the created effect
ppCompilationErrors —Returns a pointer to an ID3DXBuffer
that contains a string of error codes and messages
Here is an example call of D3DXCreateEffectFromFile :
//
// Create effect.
//
ID3DXEffect* Effect = 0;
ID3DXBuffer* errorBuffer = 0;
hr = D3DXCreateEffectFromFile(
Device, // associated device
"effect.txt", // source filename
0, // no preprocessor definitions
0, // no ID3DXInclude interface
D3DXSHADER_DEBUG, // compile flags
0,
// don't share parameters
&Effect,
// return result
&errorBuffer);
// return error strings
// output any error messages
if( errorBuffer )
{
::MessageBox(0, (char*)errorBuffer->GetBufferPointer(), 0, 0);
d3d::Release<ID3DXBuffer*>(errorBuffer);
}
if(FAILED(hr))
{
::MessageBox(0, "D3DXCreateEffectFromFile() - FAILED", 0, 0);
return false;
}
19.5 Setting Constants
As with vertex and pixel shaders, we need to initialize variables in the
effect source code from the application source code. However, instead
of using a constant table, as we did with vertex and pixel shaders, the
ID3DXEffect interface has intrinsic methods for setting variables. We
are not going to list all the methods for setting different types of vari-
ables here because there are too many of them to simply relist—see
the DirectX SDK documentation for the complete list. Here is an
abridged listing:
Search WWH ::




Custom Search