[dx9] setting a shader constant?

Started by
3 comments, last by 21st Century Moose 7 years, 7 months ago
hi, how would i set a matrix that i defined in my vertex shader like:
float4x4 WorldViewProj : register(c0);
and it's stored in my c++ code as:
D3DXMATRIXA16 matWorldViewProj;
thanks
Advertisement
If you're not using ID3DXConstantTable or ID3DXEffect, you have to use IDirect3DDevice9::SetVertexShaderConstantF. In your case you would pass "0" as your start register.
thanks for your reply

i've initially used the table but now i've switched to IDirect3DDevice9::SetVertexShaderConstantF

result = app.getDevice()->SetVertexShaderConstantF(0, &matWorldViewProj._11, 4);


but now I dont get the geometry on my screen anymore. it worked with the constant table

thanks for your reply

i've initially used the table but now i've switched to IDirect3DDevice9::SetVertexShaderConstantF


result = app.getDevice()->SetVertexShaderConstantF(0, &matWorldViewProj._11, 4);

but now I dont get the geometry on my screen anymore. it worked with the constant table

It should be 16 in the last parameters of SetVertexShaderConstantF, not 4. A matrix is made of 16 floats. So your're just passing the only 4 elements, not the whole matrix.

It should be 16 in the last parameters of SetVertexShaderConstantF, not 4. A matrix is made of 16 floats. So your're just passing the only 4 elements, not the whole matrix.


https://msdn.microsoft.com/en-us/library/windows/desktop/bb174467%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

No, 4 is correct:

Number of four float vectors in the array of constants.


but now I dont get the geometry on my screen anymore. it worked with the constant table


Do you need to transpose your matrix?

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement