opengl question

Started by
1 comment, last by androun 17 years ago
when I use the gluPerspective for tarce a sphere and when i extract the image of depth (z buffer) ,i see a value is different of the reality when i trace the sphere,and when i use the glortho i extract the reel value why??? and here is the program void Dessiner() { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glColor3f(1.0,1.0,1.0); //glMatrixMode( GL_MODELVIEW ); glLoadIdentity( ); gluLookAt(3,0,0,0.0,0.0,0,0,0,1); //glScalef(1.0,2.0,1.0); //activer son utilisation : après la création de la fenêtre OpenGL il faut simplement appeler : glEnable(GL_DEPTH_TEST); //le réinitialiser à chaque nouvelle image, en même temps que le buffer des pixels : //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ; glutWireSphere(1.0,50,25); glFlush(); IplImage *rendugl=cvCreateImage(cvSize(640,480),IPL_DEPTH_32F,1); glReadPixels(0,0,640,480,GL_DEPTH_COMPONENT,GL_FLOAT,rendugl->imageData); rendugl->origin=IPL_ORIGIN_BL; double mind1,maxd1; CvPoint locmin; CvPoint locmax; cvMinMaxLoc(rendugl,&mind1,&maxd1,&locmin,&locmax,0); fprintf(stderr,"Z min : %f,\t Z max : %f\n",mind1,maxd1); cvNamedWindow("depth",1); cvShowImage("depth",rendugl); } void reshape(int w,int h) { glViewport(0,0,(GLsizei) w,(GLsizei) h); glMatrixMode(GL_PROJECTION ); glLoadIdentity(); //glFrustum(-1.0,1.0,-1.0,1.0,1.5,20.0); //gluPerspective(70,(GLdouble)640/480,1,3); glOrtho(-3,3,-3*(GLdouble)480/640,3*(GLdouble)480/640,1,3); //glDepthRange(1,3); glMatrixMode(GL_MODELVIEW); glEnable(GL_DEPTH_TEST); } int main(int argc ,char **argv) { glutInit(&argc, argv); //glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutInitDisplayMode(GLUT_SINGLE| GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(640,480); glutInitWindowPosition(100,100); glutCreateWindow(argv[0]); glutDisplayFunc(Dessiner); glutReshapeFunc(reshape); glReadBuffer(GL_FRONT); //cvWaitKey(0); glutMainLoop (); return 0; }
Advertisement
Quote:Original post by androun
when I use the gluPerspective for tarce a sphere and when i extract the image of depth (z buffer) ,i see a value is different of the reality when i trace the sphere,and when i use the glortho i extract the reel value why???


i cant make out this sentence...
can you elaborate your question?

it is also a really good idea to write your code in english.
having french comments just make the code unreadable.
why the use of the gluperspective(for perspective projection) doesn't return the reel value of the coordannate Z in the Z-Buffer

This topic is closed to new replies.

Advertisement