Skip to main content
GameDev.net gamedev.net
🔒 Locked

[dx9] setting a shader constant?

Started by spooky_paul Dec 3, 2008 at 7:57 AM 3 replies 3.3k views
Original Post
spooky_paul
spooky_paul
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
spooky_paul
spooky_paul
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
MD Forhad Reja
MD Forhad Reja

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.

21st Century Moose
21st Century Moose

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. 

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.