burhan's picture

Help with zigzag polygons

Hi,
I'm trying to draw a cube (triangles), I enabled depth test but here's how it looks

It looks cool but I want it to draw correctly, how to fix that?


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

If your triangels are correct (2 triangles per face), then this looks like z-fighting.

You can try moving your near plane plane out (use 1.0 instead of e.g. 0.1) or increasing your depth resolution to 24 bits (GraphicsMode.Default defines a 16 bit depth buffer, so you'll have to use new GraphicsMode(32, 24) instead.)

flopoloco's picture

Or perhaps alternatively, you might try to reverse the index declaration order.

OpenGL needs triangles to be set anti clockwise. Also as mentioned here. http://stackoverflow.com/questions/12015886/whats-the-de-facto-standard-...

The real deal is that in reverse sequence your face will be flipped and will be visible from the other side only.

burhan's picture
the Fiddler wrote:

If your triangels are correct (2 triangles per face), then this looks like z-fighting.

You can try moving your near plane plane out (use 1.0 instead of e.g. 0.1) or increasing your depth resolution to 24 bits (GraphicsMode.Default defines a 16 bit depth buffer, so you'll have to use new GraphicsMode(32, 24) instead.)

Yes, depth buffer set to 24 bit solved it!!! thanx.

flopoloco wrote:

Or perhaps alternatively, you might try to reverse the index declaration order.

OpenGL needs triangles to be set anti clockwise. Also as mentioned here. http://stackoverflow.com/questions/12015886/whats-the-de-facto-standard-...

The real deal is that in reverse sequence your face will be flipped and will be visible from the other side only.

I have back face culling enabled, and this box is CW. At first I built it CCW and it showed a "room" not a box. Maybe it's something with my display drivers or something else.
[edit]: The problem (cw, ccw) was because of my camera object, originaly it follows different coord. system.