D3D10CreateEffectFromMemory function

Creates an ID3D10Effect from a buffer containing a compiled effect.

Syntax


HRESULT D3D10CreateEffectFromMemory(
  _In_  void             *pData,
  _In_  SIZE_T           DataLength,
  _In_  UINT             FXFlags,
  _In_  ID3D10Device     *pDevice,
  _In_  ID3D10EffectPool *pEffectPool,
  _Out_ ID3D10Effect     **ppEffect
);

Parameters

pData [in]

Type: void*

A pointer to a compiled effect.

DataLength [in]

Type: SIZE_T

Length of pData.

FXFlags [in]

Type: UINT

Effect compile options.

pDevice [in]

Type: ID3D10Device*

A pointer to the device (see ID3D10Device Interface).

pEffectPool [in]

Type: ID3D10EffectPool*

Optional. A pointer to an memory space for effect variables that are shared across effects (see ID3D10EffectPool Interface).

ppEffect [out]

Type: ID3D10Effect**

A pointer to an ID3D10Effect Interface which contains the created effect.

Return value

Type: HRESULT

Returns one of the following Direct3D 10 Return Codes.

Remarks

This method is used to create an ID3D10Effect Interface object from an effect that has been compiled before runtime and loaded into memory. For help precompiling an effect, see Offline Compiling. To load and compile an ASCII .fx file see Compile an Effect (Direct3D 10).

Examples

Compiling and loading an effect

Compile the effect.



fxc.exe /T fx_4_0 /Fo Tutorial03.fxo Tutorial03.fx      
          

Load the compiled effect at runtime.



ifstream is("tutorial03.fxo", ios::binary);
is.seekg(0,ios_base::end);
streampos pos = is.tellg();
is.seekg(0,ios_base::beg);
char * effectBuffer = new char[pos];
is.read(effectBuffer,pos);
	
hr = D3D10CreateEffectFromMemory((void *)effectBuffer,pos,0,g_pd3dDevice,NULL,&g_pEffect);
          

Requirements

Header

D3D10Effect.h

Library

D3D10.lib

DLL

D3D10.dll

See also

Effect Functions (Direct3D 10)

 

 

Show: