View Full Version : why can't get pixel depth from proE model window
I am using pro/Toolkit to develope some code to read pixel depth of proE model from proE view window with openGL function glReadPixels(), but all I got was 1. Actually it should be different value for different pixel of the displaying model. The codes are as following,
const int width=1024;
const int height=768;
Any comment is welcome and appreciated.
05-14-2009, 08:47 PM
pro/E: A 3D modeling software by PTC
05-16-2009, 04:42 AM
Are they all exactly 1? Depending on the projection matrix, it is typical for a scene to contain depth values very close to (but not exactly) 1.
They are all exactly 1.000. Any idea? Thanks
05-19-2009, 03:42 PM
Any GL errors? Is this a plugin for existing app?
GL didn't report any errors during the running but the returned result with glReadPixels function were all 1.0, should be different for different pixel.
Yes, we can call this program a plugin for proE because it was programed to communicate with proE in its session.
05-20-2009, 03:00 AM
Do you read front or back buffer ?
Maybe proE does actual depth rendering to an FBO or other offscreen resource, and only RGBA is copied to the final framebuffer ?
If you render geometry with your plugin, can it becomes occluded by proE already rendered geometry ?
05-20-2009, 04:05 AM
Try to spy pro/E with glIntercept. Add your drawing code, then dump one frame and examine log file. Depending how did you configure glIntercept, you can get complete framebuffer before and after all draw calls.
I do not check if I read front or back buffer. Could you tell me how to switch to either of the buffers that i can have a try?
My understanding is proE is doing depth rendering because it can provide a list when pick different parts at a pixel with mouse from the view and the pick list should be build by z-buffer information. Maybe it renders depth elsewhere. But RGB can be read with glReadPixels in proE.
I do not render geometry with my plugin. I just need to read such information from proe rendered view.
BTW, could you kindly tell me what kind of offscreen resource available for proE to do depth rendering, and how to read information from such resource?
Thank you very much
05-20-2009, 06:13 AM
Contact proE support, they would be more appropriate for your last question. This has nothing to do with general OpenGL.
To select buffer used for reads :
glReadBuffer(GL_BACK); // the default
glReadBuffer(GL_FRONT); // rarely works
I know you don't render geometry. But if you do, it will allow you to check where your current problem comes from.
As said yooyo, using glIntercept will really help you a lot.
Thank you all. I'll try it.
I tried different combination of the following codes, but it still doesn't work.
When I set depth scale to 0.8, I got 0.8 for all the pixels again.
I used glIntercept to spy proE, and got a log file, but I'm afraid it is beyond my understanding. Could you kindly help me make a quick analysis of the file, ZbufferR or yooyo? Thank you indeed.
05-21-2009, 04:48 AM
1. Copy OpenGl32.dll in proE app folder
2. Copy "C:\Program Files\GLIntercept0_5\gliConfig_XMLFrame.ini" to same folder (as in step 1) but rename gliConfig_XMLFrame.ini to gliConfig.ini
2.a. Open gliConfig.ini in notepad and remove comment on // DepthBufferLog = (pre,post,diff)
3. Start proE, draw something
4. Press Ctrl + Shift + F
5. wait until it finish
6. Open generated HTML file in Internet Expolrer
now, browse log file.. there will be listed all GL calls. Before and after each draw call you can see state of selected framebuffers.
Now, modify your plugin to do some irrelevant things ("placing a marker").. like 10x in row glGetString(GL_RENDERER), and dump frame again. Browse new log file and find place with 10x calls glGetString(GL_RENDERER). Before that "marker" is proE framebuffer state. Scroll up until you find last draw call before your code is invoked. From there see whats last and trace log file and check gl calls.
Make sure your pligin is active while you grabbing a frame.
Thanks a lot.
I already remove the comment in the config file, but didn't do Ctrl + Shift + F. I will try again with suggested markers. I'm new to opengl. Thanks again for your help.
I tried the suggested configuration file and Ctrl + Shift + F, but it seemed nothing happened. I even tried with different opengl program. There's no frame information exported. Only very simple log file created. Could you tell me what's the problem possible? Thanks
05-22-2009, 03:51 AM
Take look in proE folder.. there should be new folder like frame02345 or similar. in that folder you can found HTML files and all images, shaders, or whatever else glIntercet can get.
I searched the whole disk for new created files, only got the simple log file. I'll double check the configuration file. Do I need to do other modification on the configuration file besides removing the comment of DepthBufferLog? How long will it take after pressing Ctrl + Shift + F? It seems no delay at all on my computer.
05-22-2009, 07:25 AM
Can you try glIntercept with some other GL app .. some of your demos or test apps?
Depending on scene complacity, glIntercept can finish job from 1 sec to 3-4 minutes.
I have tried different opengl programs but Ctrl + Shift + F still doesn't work. My operation is as follows,
1. copy gliconfig.ini and opengl32.dll
2. modify config.ini for the depth buffer.
3. open my opengl program or proE and draw a scene.
4. press Ctrl + Shift + F
5. close my opengl program or proE.
I tried the initial gliConfig.ini and the name modified gliConfig_XML***.ini. For the initial one, I got a log file with opengl calling listed and for the later one, I only got a very simple log file with limited information listed. Seems nothing happened for Ctrl + Shift + F and no information about depth buffer. Anything wrong with the procedure? Thanks.
05-24-2009, 05:27 PM
Again... you need to copy opengl32.dll from glIntercept folder in app folder and gliConfig_XML***.ini from glIntercept folder in app folder and rename it to gliConfig.ini.
Edit gliConfig.ini in app folder and modify depth bufer loging options.
Now, run app and press Ctrl + Shift + F.
If still there is no result, please read some docs in glIntercept. Maybe Im missing something.. I used it long time ago.
05-25-2009, 05:37 AM
Last time I looked at Pro/ENGINEER it used a launcher to start the actual program. Means if you only got a simple log in the interceptor that was probably from the launcher and the actual process you're working in is called something different.
And folks, there is only one depth buffer (even in stereo), it doesn't matter if the glReadBuffer points to front or back for reading depth. ;)
To yooyo: Yes, I copied the opengl32.dll.
To Rlic: I tried my another opengl program and still couldn't get the buffer information.
Thanks you all.
05-25-2009, 04:00 PM
pfff.. I cant belive you didnt make it.
Assume you have opengl app in folder d:\test\glapp.exe.
Install glIntercept. From c:\Program Files\glIntercept0_5 copy:
1. opengl32.dll to d:\test\opengl32.dll
2. gliConfig_XMLFrame.ini to d:\test\gliConfig.ini
Edit d:\test\gliConfig.ini. Modify following lines:
- remove // from // DepthBufferLog = (pre,post,diff);
Now run your glapp.exe at some point, press Ctrl + Shift + F
app will freeze for a moment and then continue execution. Exit app and check d:\test folder. There you should find another folder.. like d:\test\frame_01234\ . From that folder open gliInterceptLog.xml in Internet Exporer. And thats it.. examine log.
In case of proE, maybe app dont have rights to write in same folder.. Adjust Log path in gliCOnfig.ini (LogPath = "c:\temp\";)
Maybe I need try on another machine. Thanks.
Now it works.
I tried glIntercept0_3, and it works. Then I compared the gliConfig.ini file and found there's one line different with that in glIntercept0_5:
Enabled = false;
FrameStartKeys = (ctrl,shift,f);
OneFrameOnly = True;
In glIntercept0_5 Enabled = true doesn't work. When I changed it to false, it also works. But ctrl+shift+f is unnecessary in both version.
Thank you again for all of your help. Hope this can help me solve the problem in proE development.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.