?/TD>
Microsoft DirectX 9.0

D3DXCompileShader Function


Compile a shader file.

Syntax

HRESULT WINAPI D3DXCompileShader(      

    LPCTSTR pSrcData,     UINT srcDataLen,     CONST D3DXMACRO* pDefines,     LPD3DXINCLUDE pInclude,     LPCTSTR pFunctionName,     LPCTSTR pTarget,     DWORD Flags,     LPD3DXBUFFER* ppShader,     LPD3DXBUFFER* ppErrorMsgs,     LPD3DXSHADER_CONSTANTTABLE* ppConstantTable );

Parameters

pSrcData
[in] Pointer to a string that contains the shader. If the compiler settings require Unicode, the data type LPCTSTR resolves to LPCWSTR. Otherwise, the string data type resolves to LPCSTR. See Remarks.
srcDataLen
[in] Length of the data in bytes.
pDefines
[in] Pointer to the preprocessor definitions. See D3DXMACRO.
pInclude
[in] Optional interface pointer, ID3DXInclude, to use for handling #include directives. If this value is NULL, #includes will either be honored when compiling from a file or will cause an error when compiled from a resource or memory.
pFunctionName
[in] Pointer to a string that contains the name of the shader entry point function where execution begins. If the compiler settings require Unicode, the data type LPCTSTR resolves to LPCWSTR. Otherwise, the string data type resolves to LPCSTR. See Remarks.
pTarget
[in] Pointer to a string that contains the compile target. See Remarks.
Flags
[in] Compile options identified by D3DXSHADER.
ppShader
[out] Returns a buffer containing the created shader. This buffer contains the compiled shader code, as well as any embedded debug and symbol table information.
ppErrorMsgs
[out] Returns a buffer containing a listing of errors and warnings that were encountered during the compile. These are the same messages the debugger displays when running in debug mode. This value may be NULL.
ppConstantTable
[out] Returns a pointer to the D3DXSHADER_CONSTANTTABLE block which is embedded inside the shader. Use this block to access shader constants using D3DXGetShaderConstantTable. This value may be NULL.

Return Value

If the function succeeds, the return value is D3D_OK.

If the function fails, the return value can be one of the following values.

D3DERR_INVALIDCALLThe method call is invalid. For example, a method's parameter may have an invalid value.
D3DXERR_INVALIDDATAThe data is invalid.
E_OUTOFMEMORYMicrosoft?Direct3D?could not allocate sufficient memory to complete the call.


Remarks

Targets can be specified for vertex shaders, pixel shaders, and texture fill functions.

Vertex shader targetsvs_1_1, vs_2_0, vs_2_sw
Pixel shader targetsps_1_1, ps_1_2, ps_1_3, ps_1_4, ps_2_0, ps_2_sw
Texture fill targetstx_0, tx_1

If the compiler settings require Unicode, the data type LPCTSTR resolves to LPCWSTR. Otherwise, the string data type resolves to LPCSTR.

The compiler setting also determines the function version. If Unicode is defined, the function call resolves to D3DXCompileShaderW. Otherwise, the function call resolves to D3DXCompileShaderA because ANSI strings are being used.

Function Information

Headerd3dx9shader.h
Import libraryd3dx9.lib
Minimum operating systems Windows 98

See Also

D3DXCompileShader, D3DXCompileShaderFromResource


© 2002 Microsoft Corporation. All rights reserved.