Hidden window, pbuffer

Hello everybody,

I am trying to write a library that does some computations on the GPU. However, since this is a general-purpose library that could be used in any kind of windows program, I don’t want to have visible window opened during the computation phase.

I tried the following: create a window with no WS_VISIBLE attribute and ShowWindow(SW_HIDE). This, of course resulted in a hidden window. I checked whether the opengl resource associated with this window was software and it was not (I am using a nvidia Quadro4 card, so opengl reported the correct string). However, when rendering to this hidden window, and then using glReadPixels to read back some information I found out that all I was getting were ZEROS. Nothing was actually rendered in the window. When I disabled hardware acceleration in control panel, everything went fine – I was getting the expected values read back.

2nd try: create a pbuffer and render to it. This one worked fine – up to a point. When rendering to a pbuffer with the window hidden, I was indeed getting results back from it. However, the results were slightly different from those I was expecting (to be more specific, slightly different depth values). The differences were small (e.g., only few pixels having different depths), but large enough to mess up my results. I did make sure that the pbuffer was initialized with the same parameters as my initial context.

What could be the reason for getting slightly different depth values in the pbuffer?

Also, is there any way to actually get something rendered into a context that is associated with a hidden window? (Of course, this question is both general and particular. If you know something that would work only on nvidia, it’s still fine).

Rendering to a hidden window won’t work in general since the spec states that the framebuffer content is undefined. In your test, you found that MS GDI implementation keeps a valid framebuffer for a hidden window, while the NVIDIA driver does not. Both implementations conform to the spec (on that matter).
So the proper way to do it is use a pbuffer, like you did.

The problem of slight differences is tied to the path taken by your rendering commands. Software, hardware fixed-function and hardware programs can give slightly different results due to rounding and approximations that happen during the computations. You might want to search for “position invariance”-related topics.

Hello, I have a question and I write to next because it’s same subject.

I want to work with a PBuffer and not a Window.
I do NOT work with a Window !
So to initialize PBuffer I have to use “wglCreatePbufferARB”

BUT to use this function I have to use “wglGetProcAddress(“wglCreatePbufferARB”)” !!!

AND tu use this second function I have to initialize a WINDOW otherwise this don’t work !!!

My conclusion : It’s impossible to use a PBuffer without Window.

Please ! Say me I’m stupid and It’s possible !

Links, samples will are welcome :wink:

what I would try : setup a (hidden) window, load function pointers, kill the window and do the pbuffer stuff.

I create a hidden window which I then cache for the duration of the program. Destroying the window after you create the pbuffer cause you problems.

Thank Kehziah and GKW !

I thought about your methode.

Frankly, it suck ! It’s not clean.

OpenGL : Looser !

While you’re wasting your time trying to find a solution that looks clean to you, you could have setup a dummy hidden window and have your pbuffer rendering running smoothly; and nobody would ever ask you if you need a hidden window or not. Who cares about that? Your average customer/user? As long as it doesn’t introduce new bugs and gets the job done, any workaround is fine, even if it is not really consistent with the architecture of your program. Programing is not a style exercise (apart from academic work), it is about making software that runs and fulfil its purpose.
Last I checked, creating a window (even with OpenGL support) is not that hard. With some experience, it’s a matter of minutes to do properly.
In the real world, very few things are optimal, but many paths are good enough to reach your goal.

I have a disease :
“I like to waste my time trying to find a solution that looks clean to me”

I like OpenGL 1.1. But the next… burck !

Thank Doc. Kehziah !

Is following problem due to the fact that opengl doesn’t keep frame buffer for hidden window?

Following seems confusing due to the way I worded few things. you can email or post message and I’ll explain the problem differently.

Here is my problem:

I have MFC MDI Application , where I create opengl window as derived class of CWnd. This class I use as a control on the CFormViews and render.
Problem I am having is, when the child formview is moved outside the monitor( invisible part of the desktop) and if I resize it in that position then whatever part of the window was outside the desktop doesn’t get rendered and leaves black patch when I move child window back inside the visible desktop area. Once I move back in and then if I redraw opengl (by resizing again) then black patch gets rendered and everything is normal.
I remember MS admitted the bug in generic implementation of win 2000 GL drivers where we saw two black patches right and bottom strips if no hardware acclearation.
But this one I am not sure what the heck is going on. Seems like Opengl doesn’t render when its outside the desktop.
most of the opengl applications I have scene are glut windows or on the mfc dialogs or mfc CViews.
What I have is the one on CFormview.
Do you think this is related to the above fact or related to the microsoft generic bug? I am running XP and nvidia newest driver.
Can anyone help?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.