Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
depth buffer problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

depth buffer problem



hello,
i am porting an application from unix/windowsX11 to macosX. we use openGL
to render medical visualizations. once i got the application running in
X11 on osX, i notived problems with the openGL renderings. It seems that
the depth buffer is not functioning correctly on this system. I checkeed
this out by writing a small program using gluSolidTeapot and have found
that both linking with the X11 and alternately the OSX framework libraries
give me the same incorrect behaviours. the only way to explain this is
just that the depth buffer if not depth buffering correctly. as i rotate
the teapot, various parts of the teapot show through where they should
not. has anyone heard of this kind of problem? could it be an issue with
the graphics cards? i ran our application on another g4, and i got the
same depth buffering problems, which had initialy led me to believe it was
a problem with the code. below i am including my teapot test code, just
in case i am doing something silly. thanks, m.

#include <gl.h>
#include <glu.h>
#include <glut.h>
#include <stdio.h>
#include <stdlib.h>

static float roty;

void init(void) {
GLfloat light_position[] = {1.0, 1.0, -2.0, 1.0};
GLfloat white_light[] = {1.0, 1.0, 1.0, 0.0};

glClearColor(0.0, 0.0, 0.0, 0.0);

glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);

glViewport(0, 0, 500, 500);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -10.0, 10.0);


glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);

/*
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
*/
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

roty = 0;
}

void display(void) {
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);

glColor3f(1.0, 1.0, 1.0);

glPushMatrix();
glTranslatef(.5, .5, .8);
glRotatef(roty, 0, 1, 0);
glutSolidTeapot(.2);
glPopMatrix();
glFlush();
}

void rotate(unsigned int key, int x, int y){
if(key == 113) glEnable(GL_DEPTH_TEST);
else if(key == 119) glDisable(GL_DEPTH_TEST);

/*
else if(key == 97) glEnable(GL_CULL_FACE);
else if(key == 115) glDisable(GL_CULL_FACE);
*/
else {

if(roty >=360) roty = roty - 360;
roty = roty + 5;
}
printf("%i\n", key);

glutPostRedisplay();
}

int main(int argc, char ** argv){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_DEPTH);
glutInitWindowSize(500, 500);
glutInitWindowPosition(100, 100);
glutCreateWindow("hello");
init();
glutDisplayFunc(display);
glutKeyboardFunc(rotate);
glutMainLoop();
return 0;
}
_______________________________________________
mac-opengl mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/mac-opengl
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.