bad depth sorting in Cocoa OpenGL
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 [] = {
NSOpenGLPFAWindow,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFASampleBuffers, 1,
NSOpenGLPFASamples, 4,
NSOpenGLPFANoRecovery,
NSOpenGLPFADepthSize, 24,
(NSOpenGLPixelFormatAttribute)nil
};
NSOpenGLPixelFormatAttribute attributes [] = {
NSOpenGLPFAWindow,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFASampleBuffers, 1,
NSOpenGLPFASamples, 4,
NSOpenGLPFANoRecovery,
NSOpenGLPFADepthSize, 24,
(NSOpenGLPixelFormatAttribute)nil
};
What do you mean by "it doesn't seem fluid any more?"
Are you enabling depth testing?
Are you enabling depth testing?
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.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Opengl/Cocoa text rendering | tesil | 15 | 14,410 |
Mar 20, 2012 11:16 AM Last Post: OneSadCookie |
|
| OpenGL Text Rendering (in Cocoa) | daveh84 | 5 | 6,617 |
Feb 19, 2009 12:44 PM Last Post: TomorrowPlusX |
|
| OpenGL & Cocoa - Improving frame rate | daveh84 | 4 | 4,912 |
Feb 2, 2009 06:53 AM Last Post: backslash |
|
| Loading and using textures with alpha in OpenGL with Cocoa | corporatenewt | 4 | 5,076 |
Dec 8, 2007 02:06 PM Last Post: Malarkey |
|
| Depth-first sorting | cecilkorik | 8 | 4,537 |
Oct 18, 2007 12:26 PM Last Post: OneSadCookie |
|

