bad depth sorting in Cocoa OpenGL

Posts: 1
Joined: 2008.11
Post: #1
I am trying to convert the GLUTBasics example from MacDev to something more like the CocoaGL example which uses the NSOpenGL API. The object in the CocoaGL example is just a rotating cube. The object from GLUTBasics is a trefoil made up of thousands of triangles. I just copied over the code (and adjusted the camera attributes), and it displayed, but there seems to be a depth sorting problem. I've listed my pixel format below. When I don't include the NSOpenGLPFADepthSize attribute, the object totally self intersects as it rotates, almost like there's no depth sorting going on at all. When the attribute is included (and I've tried different values), it doesn't seem fluid any more, but parts of it still self-intersect as it rotates. I've tried enabling all kinds of stuff, but nothing helps. Any ideas about how to fix this?

NSOpenGLPixelFormatAttribute attributes [] = {
NSOpenGLPFASampleBuffers, 1,
NSOpenGLPFASamples, 4,
NSOpenGLPFADepthSize, 24,
Quote this message in a reply
Posts: 5
Joined: 2008.12
Post: #2
What do you mean by "it doesn't seem fluid any more?"

Are you enabling depth testing?
Quote this message in a reply
Posts: 1,563
Joined: 2003.10
Post: #3
aldermoore Wrote:I just copied over the code (and adjusted the camera attributes)

What did you set your near and far clipping planes to? The lower the ratio of near:far, the less precision you get in your depth buffer. If you have it set to something extreme (like 0.00001:100000), you might be losing enough precision to make the depth buffer ineffective.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Opengl/Cocoa text rendering tesil 15 25,191 Mar 20, 2012 11:16 AM
Last Post: OneSadCookie
  OpenGL Text Rendering (in Cocoa) daveh84 5 10,782 Feb 19, 2009 12:44 PM
Last Post: TomorrowPlusX
  OpenGL & Cocoa - Improving frame rate daveh84 4 8,534 Feb 2, 2009 06:53 AM
Last Post: backslash
  Loading and using textures with alpha in OpenGL with Cocoa corporatenewt 4 9,438 Dec 8, 2007 02:06 PM
Last Post: Malarkey
  Depth-first sorting cecilkorik 8 7,732 Oct 18, 2007 12:26 PM
Last Post: OneSadCookie