c - ID3D11XEffectMatrixVariable replace with what? -
i'm making directx engine i'm stuck 1 little problem. want not utilize fx files shader files, question can replace id3d11xeffectmatrixvariable
? help.
if not using effects 11 manage shader metadata , constants, take on responsibility binding , updating constant buffers directly.
for example, in direct3d tutorial (win32 desktop or windows store) hlsl shader defines constant buffer has matrices:
cbuffer cbneverchanges : register( b0 ) { matrix view; };
and manually set , bind in c++ code render it:
types:
struct cbneverchanges { xmmatrix mview; }; id3d11buffer* g_pcbneverchanges = nullptr;
setup:
// create constant buffers bd.usage = d3d11_usage_default; bd.bytewidth = sizeof(cbneverchanges); bd.bindflags = d3d11_bind_constant_buffer; bd.cpuaccessflags = 0; hr = g_pd3ddevice->createbuffer( &bd, nullptr, &g_pcbneverchanges ); if( failed( hr ) ) homecoming hr;
update:
cbneverchanges cbneverchanges; cbneverchanges.mview = xmmatrixtranspose( g_view ); g_pimmediatecontext->updatesubresource( g_pcbneverchanges, 0, nullptr, &cbneverchanges, 0, 0 );
render:
g_pimmediatecontext->vssetshader( g_pvertexshader, nullptr, 0 ); g_pimmediatecontext->vssetconstantbuffers( 0, 1, &g_pcbneverchanges );
note xmmatrixtranspose
because hlsl defaults using 'column-major' matrices while directx programs typically utilize 'row-major' matrices.
c visual-c++ directx-11
No comments:
Post a Comment