Game Development Reference
In-Depth Information
Note: In the subsequent sections we will set several device states in
the example programs. For the most part, the meaning of the state
can be deduced from its name, but if you want more elaborate details,
see the SDK documentation.
19.4 Creating an Effect
An effect is represented by the ID3DXEffect interface, which we cre-
ate with the following D3DX function:
HRESULT D3DXCreateEffectFromFile(
LPDIRECT3DDEVICE9 pDevice,
LPCSTR pSrcFile,
CONST D3DXMACRO* pDefines,
LPD3DXINCLUDE pInclude,
DWORD Flags,
LPD3DXEFFECTPOOL pPool,
LPD3DXEFFECT* ppEffect,
LPD3DXBUFFER *ppCompilationErrors
);
pDevice —The device to be associated with the created
ID3DXEffect object
pSrcFile —Name of the text file (the effect file) that contains the
effect source code we want to compile
pDefines —This parameter is optional, and we specify null for it
in this topic.
pInclude —Pointer to an ID3DXInclude interface. This inter-
face is designed to be implemented by the application so that we
can override default include behavior. In general, the default behav-
ior is fine, and we can ignore this parameter by specifying null.
Flags —Optional flags for compiling the shaders in the effect file;
specify 0 for no flags. Valid options are:
D3DXSHADER_DEBUG —Instructs the compiler to write debug
information
D3DXSHADER_SKIPVALIDATION —Instructs the compiler not
to do any code validation. This should only be used when you
are using a shader that is known to work.
D3DXSHADER_SKIPOPTIMIZATION —Instructs the compiler
not to perform any code optimization. In practice this would
only be used in debugging, where you would not want the com-
piler to alter the code in any way.
pPool —Optional pointer to an ID3DXEffectPool interface that
is used to define how effect parameters are shared across other
Search WWH ::




Custom Search