I use openGL for offsreen calculation, cause I don’t need a display window, so I create a dummy window to get a rendering context. Glew can be initialized and all rendering has no glerror, but what I got from the FBO is all zeros. I tried glut to create a window too. It seems that only after calling glutMainloop, I can get a right result. I wondered if the message loop is needed, but if so, it will block my calculation thread. Do you have any ideas how offscreen rendering works in window?
If you ‘render offscreen to window’ meaning you render to window that is not visible, OpenGL is entitled to not draw a thing. This is called pixel ownership test and at least nvidia is taking advantage of it and does not draw occluded parts of the window (they just stay black).
Easiest way to work around this would be to create an FBO or pbuffer and draw to this.
In UNIX/Linux under X, I believe you can create an OpenGL context which targets a PBuffer or X Pixmap instead of an X Window, which solves the problem.
You can also create a window and just not draw to it. Draw to an off-screen FBO or PBuffer as suggested.
Solve this problem by send onpaint message to the hidden window whenever need a off-screen rendering