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
  • 1
    \$\begingroup\$ We could probably use a screenshot. \$\endgroup\$ Dec 18, 2010 at 2:08

1 Answer 1

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\$
1
  • \$\begingroup\$ Thank you! I figured it was something simple I was not understanding. \$\endgroup\$ Dec 18, 2010 at 18:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .