Jump to content
  • Advertisement
Sign in to follow this  
digitaldisciple

cube faces drawn in wrong order

This topic is 2658 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

I have a little 3D framework that I built that works great with the standard XNA GraphicsDevice. I can draw textured cubes no problem. However, I'm trying to write a map editor, so I've been using the graphicsdevice code that comes in this example:


http://create.msdn.com/en-US/education/catalog/sample/winforms_series_1

which allows you to have a 3D scene with winform controls. However, when I try to draw a cube using this graphicsdevice, the cube faces are drawn in the incorrect order. It draws them back to front and the front ones get culled. This might be tough to answer, but I was wondering if anyone might have any insight into what could be going on here. It's as if the depth buffer is reversed for some reason. That code sample is built to mimic the xna graphics device but I suppose there could be a problem with it. Thank you much.

Share this post


Link to post
Share on other sites
Advertisement
Hmm, okay...I just fixed it for a single cube by doing:

GraphicsDevice.RasterizerState = RasterizerState.CullClockwise;

Something tells me this will bite me on the bit when I have more shapes...

Share this post


Link to post
Share on other sites
You need to maintain a consistent winding order for all your meshes, either clockwise or counter-clockwise. You probably wound the cube in the wrong direction, so when you switched the cull mode it started working, but broke something else.

This doesn't really have anything to do with XNA, its the same story for all graphics APIs.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!