View Full Version : Offscreen rendering without a window

10-13-2011, 06:59 PM
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?

10-14-2011, 11:16 AM
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.

Dark Photon
10-15-2011, 05:18 PM
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.

See glXChooseFBConfig() (http://www.opengl.org/sdk/docs/man/xhtml/glXChooseFBConfig.xml) and search down to GLX_DRAWABLE_TYPE which can be: GLX_WINDOW_BIT, GLX_PIXMAP_BIT, and/or GLX_PBUFFER_BIT. More here: glXIntro (http://www.opengl.org/sdk/docs/man/xhtml/glXIntro.xml).

You can also create a window and just not draw to it. Draw to an off-screen FBO or PBuffer as suggested.

10-17-2011, 10:11 PM
Solve this problem by send onpaint message to the hidden window whenever need a off-screen rendering