Primitives trying to texture themselves

Started by
2 comments, last by Evil Steve 14 years, 4 months ago
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?
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 colordevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT);// Use material color for alphadevice->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 colordevice->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);device->SetRenderState(D3DRS_COLORVERTEX, TRUE);
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.
Or just SetTexture(0, NULL) before rendering the primitive - the fixed function stage 0 default blend state is to modulate texture and diffuse.

This topic is closed to new replies.

Advertisement