Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Why the following code did not work?

lijz

New member
The following code was used to readthe color and depth of apixel in Pro/E model window by using openGL functions to perfom some simulation. All the other opengl functions worked properly except depth reading. I don't know why. Anybody help me. Thanks a lot.


Now given a model displayed in Pro/E, as shown in this fig. when I tried to run the code, the resultsare shownin the comments.


View attachment 4895


intwinWidth, winHeight;
GLint iViewParams[4];
glGetIntegerv(GL_VIEWPORT, iViewParams);//It works
winWidth= iViewParams[2]-iViewParams[0];
winHeight= iViewParams[3]-iViewParams[1];


BYTEbtRGB[3];
GLfloatfZBuffer[1];


//Lower-left corner


glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, btRGB);//It works
glReadPixels(0, 0, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, fZBuffer); //dosn't work properly


//The center of the view


int cw = winWidth/2;
int ch = winHeight/2;
glReadPixels(cw, ch, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, fZBuffer);//dosn't work, always get fZBuffer[0]=1.0 everywhere


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.
 
I am impressed that you are using openGl functions to analyze the pro/E window. If I were you I would ask this question in another forum. This forum focuses on APIs provided by PTC. Good Luck!
 
To williaps,
This is what I have to do in my simulation. The same thing I did with Unigraphics now need to be shifted to proE. The problem is that the code works well in Unigraphics model window but doesn't in proE. So I post this question here and hope somebody could help me.
 

Sponsor

Articles From 3DCAD World

Back
Top