I understand from my past post that Mr Jack Hoxley suggest the use of constant buffer.
However I can't seem to setup the constant buffer. After copying in the matrices into the buffer and setting it in the ID3D10Effect, nothing turns up on screen. If I set the values using the normal pEffectMatrix->SetMatrix(), everything works as expected.
Effect file cbuffer decleration:
cbuffer cbPerFrame : register(b0)
{
float4x4 World : WORLD : packoffset(c0);
float4x4 View : VIEW : packoffset(c4);
float4x4 Projection : PROJECTION : packoffset(c12);
};
Texture2D <float4> DiffuseTexture : DIFFUSE_TEXTURE;
CPP File:
Desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;
Desc.Desc.ByteWidth = sizeof(float) * 48;
Desc.Desc.Usage = D3D10_USAGE_DEFAULT;
Desc.Desc.CPUAccessFlags = 0;
Desc.MiscFlags = 0;
//... create buffer etc
std::vector<BYTE> SystemCopy;
SystemCopy.resize(sizeof(float) * 48);
//Per Frame:
memcpy(&SystemCopy[0], &World, sizeof(D3DXMATRIX));
memcpy(&SystemCopy[64], &World, sizeof(D3DXMATRIX));
memcpy(&SystemCopy[128], &World, sizeof(D3DXMATRIX));
pD3DDevice->UpdateSubresource(pCBuffer, 0, 0, &SystemCopy[0], 0, 0);
pEffectConstantBufferVariable->SetConstantBuffer(pCBuffer);
//... set the textures and other stuff and draw....
I got the offset location to copy from the D3D10_EFFECT_VARIABLE_DESC.BufferOffset member field. Am I missing anything? or am i suppose to ditch the ID3D10Effect framework and go with the VS, PS, GS individually?