Re: OpenGL Examples in Cocoa
Re: OpenGL Examples in Cocoa
- Subject: Re: OpenGL Examples in Cocoa
- From: Peter Ammon <email@hidden>
- Date: Fri, 08 Jun 2001 10:29:31 -0700
on 6/8/01 6:24 AM, John Stringham at email@hidden wrote:
>
Hey all,
>
>
First, Erik, great work on the examples. They're much appreciated. They've
>
helped me already :)
>
>
However - I have one itsy bitsy problem, which I believe Erik may run into
>
as well. Although OpenGL rendering works fine in a GLUT created window, in
>
an NSOpenGLView Subclass, it refuses to render depth properly. That is,
>
polygons that are created first are always displayed on top of other
>
polygons, even with proper calls to glEnable(GL_DEPTH_TEST) and
>
glDepthFunc(GL_LEQUAL) etc.
>
>
Very peculiar. Like I said, the exact same polygons and (pretty much) the
>
same code work flawlessy under a GLUT window. However this is blatantly
>
un-Obj-C, so if anyone knows how to get around it I'd appreciate their
>
input.
>
>
Thanks in advance,
>
>
-John S.
Perhaps your OpenGL context doesn't have a depth buffer allocated. If
you're setting up the NSOpenGLView IB, have you chosen a nonzero depth
buffer in the info window? What does the view claim its depth buffer is?
For example, try both
long vals;
[[myOpenGLView pixelFormat] getValues:&vals
forAttribute:NSOpenGLPFADepthSize forVirtualScreen:0];
NSLog(@"Depth bits: %d", (int)vals);
and (from within an OpenGL context)
GLint vals;
glGetIntegerv(GL_DEPTH_BITS, &vals);
NSLog("Depth bits: %d", (int)vals);
-Peter