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.
pro/E: A 3D modeling software by PTC
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
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.
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 ?
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
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.
- Copy OpenGl32.dll in proE app folder
- 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)
- Start proE, draw something
- Press Ctrl + Shift + F
- wait until it finish
- 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
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.
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,
- copy gliconfig.ini and opengl32.dll
- modify config.ini for the depth buffer.
- open my opengl program or proE and draw a scene.
- press Ctrl + Shift + F
- 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.