Jump to content
  • Advertisement
Sign in to follow this  
androun

OpenGL opengl question

This topic is 4174 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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; }

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
why the use of the gluperspective(for perspective projection) doesn't return the reel value of the coordannate Z in the Z-Buffer

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!