• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
question on opengl
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

question on opengl


  • Subject: question on opengl
  • From: Alex Golovinsky <email@hidden>
  • Date: Wed, 1 Aug 2001 14:44:43 -0400

Hi,
Here's a simple app that draws two squares, one in front of the other, when a key is pressed. I've been knocking my head on this for several days now: the depth test does NOT work. The red quad, which is drawn first in order, does not get overdrawn by the black quad despite the fact that the black quad is in the front and that depth buffer testing is enabled. Can anyone see what's wrong with this?


//controller is a subclass of NSOpenGLView

@implementation Controller

- (void)keyDown:(NSEvent *)event;
{
[self display];
}

- (void) applicationDidFinishLaunching: (NSNotification *) note;
{
width = [myGL frame].size.width;
height = [myGL frame].size.height;
[window setAcceptsMouseMovedEvents: YES];
[window makeFirstResponder: myGL];
glClearColor(1.0, 1.0, 1.0, 1.0);
glEnable(GL_DEPTH_TEST);
glViewport (0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, (float)width/height, 1.5, 20);
GL_INITIALIZED = YES;
}

- (void)drawRect:(NSRect)rect
{
if(GL_INITIALIZED){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0, 0, 7, 0, 0, 0, 0, 1, 0);

glColor3f(0, 0, 0);
glBegin(GL_QUADS);
glVertex3f(-1, -1, 1);
glVertex3f(1, -1, 1);
glVertex3f(1, 1, 1);
glVertex3f(-1, 1, 1);
glEnd();

glColor3f(1, 0, 0);
glBegin(GL_QUADS);
glVertex3f(-1, -1, 0);
glVertex3f(1, -1, 0);
glVertex3f(1, 1, 0);
glVertex3f(-1, 1, 0);
glEnd();

glFlush();
}
}
@end


  • Follow-Ups:
    • Re: question on opengl
      • From: Eric Peyton <email@hidden>
  • Prev by Date: Re: dragging from a NSTableView
  • Next by Date: Re: Making multiple windows from the same class
  • Previous by thread: Re: NSAppleEventManager question...
  • Next by thread: Re: question on opengl
  • Index(es):
    • Date
    • Thread