Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question
1  
We could probably use a screenshot. –  Andrew Russell Dec 18 '10 at 2:08
add comment

1 Answer

up vote 3 down vote accepted

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();
share|improve this answer
    
Thank you! I figured it was something simple I was not understanding. –  Loren Pechtel Dec 18 '10 at 18:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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