microsoft / DirectXTK

The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++

Home Page:https://walbourn.github.io/directxtk/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VertexPositionColor is not coloring

opened this issue · comments

I'm running into a strange problem where I'm following the Simple Rendering tutorial and the triangle is drawing in white instead of yellow or colored. I am also running the 2D sprite batch at the same time, I'm wondering if this might be impacting the primitive batch somehow in this simple example?

This image shows my code, my engine systems make some of these calls simpler.
image

When running, the triangle (is drawing white)
image

Many of the effects use different shaders (and therefore different input layouts) depending on the options set. The 'default' shader for BasicEffect does not have per-vertex color enabled, so it won't use "color" in VertexPositionColor.

You need to do:

m_effect  = std::make_unique<VertexType>(...);
m_effect->SetVertexColorEnabled(true);

CreateInputLayoutFromEffect<VertexType>(..., m_effect.get(), ...);

This will enable a shader that consumes the per-vertex color.

Thanks, Chuck. Was easy enough fix, guess I missed transcribing that line ;)

image