2
\$\begingroup\$

A newbie to XNA here. This is a followup to my previous question that showed me part of what I was doing wrong but I'm still not getting what I want. I'm setting up a BasicEffect thus:

Effect = new BasicEffect(GraphicsDevice);
Effect.VertexColorEnabled = true;
Effect.Alpha = 1.0f;
Effect.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
Effect.GraphicsDevice.BlendState = BlendState.Opaque;

and the draw loop:

GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, MaxDepth, 0);

All polygons are being rendered where and how I wish except they should be fully opaque and they aren't. The actual image looks more like the various colors are being combined in a fashion I'm not sure about:

alt text

\$\endgroup\$
  • 1
    \$\begingroup\$ We could probably use a screenshot. \$\endgroup\$ – Andrew Russell Dec 18 '10 at 2:08
3
\$\begingroup\$

You must set the DepthStencilState and BlendState before drawing the object, and not when creating your Effect, just like this:

GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, MaxDepth, 0);
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
GraphicsDevice.BlendState = BlendState.Opaque;

DrawYourThings();
\$\endgroup\$
  • \$\begingroup\$ Thank you! I figured it was something simple I was not understanding. \$\endgroup\$ – Loren Pechtel Dec 18 '10 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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