• Advertisement
Sign in to follow this  

Primitives trying to texture themselves

This topic is 3002 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In my game, every time I draw primitives without a shader, they try to texture themselves even though they only have a position and color. I'm using FVF: D3DFVF_XYZ | D3DFVF_DIFFUSE. It seems to use whatever texture was used last. Why won't it color my primitives with their vertex color?

Share this post


Link to post
Share on other sites
Advertisement
You have to set the appropriate texture stage states to specify that you want to use vertex color, and not texture color. Like this:

// Use material color for diffuse color
device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);

// Use material color for alpha
device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
device->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_CURRENT);

// Set vertex colors as the material color source, and enable per-vertex color
device->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);
device->SetRenderState(D3DRS_COLORVERTEX, TRUE);

Share this post


Link to post
Share on other sites
Awesome, I almost had all of those, but not quite. Although if I use the alpha settings, my text doesn't have alpha, but it works if I don't set those. You're awesome.

Share this post


Link to post
Share on other sites
Or just SetTexture(0, NULL) before rendering the primitive - the fixed function stage 0 default blend state is to modulate texture and diffuse.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement