   why glReadPixels() get the depth of z always equal to 0.0 ?
  hi,here is my c# code:onPaint() { glClearColor((float)red / 255.0f, (float)green / 255.0f, (float)blue/255.0f, 1.0f); wglMakeCurrent(DC, RC); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glTexEnvf(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_BLEND); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, intexture[0]); ...... //glTexParameteri()...... glPushMatrix();glLoadIdentity(); glTranslatef(MoveX, MoveY, -3.5f); glRotatef(fAngleX, 1.0f, 0.0f, 0.0f); glRotatef(fAngleY, 0.0f, 1.0f, 0.0f); glRotatef(fAngleZ, 0.0f, 0.0f, 1.0f); glScalef(fGlobalScale, fGlobalScale, fGlobalScale);drawPic();   //draw textureGetGLpos(mouse_x,mouse_y);//mouse_x,mouse_y are mouse button down position glPopMatrix(); glFinish(); wglSwapBuffers(DC); } void GetGLpos(int mouse_x, int mouse_y) {int[] viewport=new int[4];double[] modelview=new double[16];double[] projection=new double[16];double winX = 0.0f, winY = 0.0f, winZ = 0.0f;double posX = 0.0f, posY = 0.0f, posZ = 0.0f;glGetIntegerv(GL_VIEWPORT, viewport);glGetDoublev(GL_MODELVIEW_MATRIX, modelview);glGetDoublev(GL_PROJECTION_MATRIX, projection);winX = (float)mouse_x;winY = (float)viewport[3] - (float)mouse_y;glReadPixels((int)winX, (int)winY, 1, 1, GL_DEPTH_COMPONENT, GL_DOUBLE, ref winZ);gluUnProject(winX, winY, winZ, modelview, projection, viewport, ref posX, ref posY, ref posZ);glDown_x=(float)posX;    glDown_y=(float)posY;    glDown_z=(float)posZ;}I wonder why in the function glReadPixels((int)winX, (int)winY, 1, 1, GL_DEPTH_COMPONENT, GL_DOUBLE, ref winZ);the winZ always equals to 0?   
  According to glReadPixels(), it should be throwing you the GL_INVALID_ENUM error, because GL_DOUBLE is not an accepted type (GL_FLOAT on the other hand, is). That's about the only thing I can think of, because it looks fine otherwise...   ;  Thank you,Gorax, thank you very much.yes, it is just the problem, I changed the sixth parametre from GL_DOUBLE to GL_FLOAT, then I got the correct Z value.   ;  hi,there is a new problem:I don't use glLookAt() in the program, it looks like I look at the mountains set in one of the hill, how to make the camera far up the scene? I put the glLookAt, but it seems not work.   ;  Assuming the matrix being set where you're doing your translations and rotations is the modelview one, you simply need to replace the translations and rotations with a call to gluLookAt() (or if you have access to a camera class, whatever it uses instead). By the way, are you doing anything with the projection matrix? It'll go a long way to making 3D objects look better if you set up a perspective view as well.The code usually goes something like this:glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glMatrixMode(GL_PROJECTION);glLoadIdentity();///use either gluPerspective() or glOrtho() - NOT bothgluPerspective(45.0f,4.0f/3.0f,1.0f,1024.0f);//for 3D rendering//glOrtho(-1.0f,1.0f,-1.0f,1.0f,-1.0f,1.0f);//for 2D renderingglMatrixMode(GL_MODELVIEW);glLoadIdentity();gluLookAt(//for 3D rendering  position[0],position[1],position[2],//this is where you're looking from  center[0],center[1],center[2],//this is what you're looking at  0.0f,1.0f,0.0f//this points up);/*//for 2D renderingglTranslatef(-center[0],-center[1],-center[2]);glRotatef(cameraRotation,0.0f,0.0f,1.0f);*///this is where you start drawing things[EDIT]Corrected 2D translation...[Edited by - Gorax on May 14, 2010 7:16:27 PM]