   glreadpixels
  i have changed nehe lesson n.2. the original only displays a triangle and a quad. the only thing i have changed is that: pressing F1...open a file and read in the screen what value i have in z-bufferbut, the only value in z-buffer is 0????i have tried to change the coord vertex but nothing happened...where had i mistaken?fd=fopen("pino.txt","w+");for(int i=0;i<640;i++)for(int j=0;j<480;j++){    glReadPixels(i,j,1,1,GL_DEPTH_COMPONENT, GL_DOUBLE, &z);    sprintf(string,"%d %d %f\n",i,j,z);    fputs(string,fd); }   thanks   
  Hi, I'm assuming that, in your code, f is a double.You need to change it to a double *, because glReadPixels has the task of creating an array of pixels in memory. the last parameter returns a void* which you must convert to the correct memory format before reading. (My C sucks too badly to give you an example of how to do this.)read this:clickie[edit} p.s., after you get this working you will still find a depth of 0 because all the vertex calls are using 0 for the z component in the coordinate:glBegin(GL_TRIANGLES);// Drawing Using TrianglesglVertex3f( 0.0f, 1.0f, 0.0f);// Top-------------------------^ zero z depthglVertex3f(-1.0f,-1.0f, 0.0f);// Bottom Left-------------------------^ zero z depthglVertex3f( 1.0f,-1.0f, 0.0f);// Bottom Right-------------------------^ zero z depthglEnd();   ;  i found the mistake, GL_DOUBLE is not in type of glreadpixels, i have changed it to GL_FLOAT and double z to float z and it works perfectly. thanks   