Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
The following codes were used to read the color and depth of a pixel in Pro/E model window by using openGL functions to perfom some simulation. All the other opengl functions worked properly except depth reading function. I don't know why. Any kind of helps are welcome.
Now given a model displayed in Pro/E window, as shown in this fig. When I tried to run the following codes, the results are shown in the comments.
BYTE btRGB[3];
GLfloat fZBuffer[1];
//go to the center of the view
int cw = winWidth/2; //width and height of the view are gotten in advance
int ch = winHeight/2;
glReadPixels(cw, ch, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, btRGB);//It works, color information is read correctly
glReadPixels(cw, ch, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, fZBuffer); //this dosn't work, always get fZBuffer[0]=1.0 even when we go to elsewhere
Actually the depth of every pixel of the model surface should be different value, but here it kept 1.0 for all pixels. This problem have troubled me for quite a long time. I really appreciate any kind of your help.