Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a vs_2_0 shader like this:

struct ConstantBuffer
{
    float4 diffuse;
    float4 specular
};

shared uniform ConstantBuffer g_cb : app_constantBuffer;

void PS(out float4 Color: COLOR0)
{
    Color = g_cb.diffuse;
}

The above example is simple, the constant buffer only stores two 4 component colors. I want to set the constant buffer before binding the pixel shader. I do not want to use the ID3DXEffect interface.

The IDirect3D9Device interface only provides methods for setting primitive types...I want to set the entire struct at one time. Is this possible?

share|improve this question
up vote 1 down vote accepted

D3D9 doesn't support constant buffers but all uniforms are placed into one global "constant buffer". You can set multiple float4 constants at once with IDirect3DDevice9::SetPixelShaderConstantF() by passing the number of constants as the last argument.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.