PDA

View Full Version : display problem



12-06-2003, 09:37 AM
I'm writing a test program, with an OpenGL display. The result i'd like is this:
http://seb.sevilla.free.fr/opengl/test24bits.jpg

The problem is that I only got this result with 24 bits color, with 16 or 32 bits, I've got this:
http://seb.sevilla.free.fr/opengl/test16bits.jpg

Does anyone know the solution to my problem ? I use OpenGL with GLut under VC++, my OpenGL initialisation code :

GLview::GLview(int argc, char* argv[])
{
// glut-initialisations
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(640,480);
WindowName = glutCreateWindow("Test");
glutReshapeFunc(Reshape);
glutDisplayFunc(Draw);

glutKeyboardFunc(Keyboardnorm);
glutSpecialFunc(keyboardspec);

float MatSpec[4] = {1.f,1.f,1.f,1.f};
float MatDif[4] = {.5f,.6f,.5f,1.f};
float MatAmb[4] = {.8f,.8f,.7f,1.f};
float LightDif[4] ={.7f,.7f,.7f,1.f};
float LightSpec[4]={.5f,.5f,.5f,1.f};
float LightAmb[4] ={.2f,.2f,.2f,1.f};

glShadeModel(GL_SMOOTH);

glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);

glEnable(GL_LIGHT0);
glMatrixMode(GL_MODELVIEW);

glPointSize(3);
}

ZbuffeR
12-06-2003, 09:48 AM
Your problems seems to be related to zbuffer (lack of) precision.
With GLUT I don't think you can specify precisely the zbuffer precision.

Often, with 16bits color mode, you get 16bits zbuffer.
And with 32bits color, you get 24bits zbuffer and 8 bit stencil.
This 32bits alignment let the hardware perform faster.

12-07-2003, 05:03 AM
Thanks, that was a zbuffer problem.
i add :
glutInitDisplayString("rgba depth=32 double");
and now it seems to work.