Pbuffer without a visible window

Is it possible? I am not very familiar with windows gdi but I am getting non-zero DC’s from either createdc or createcompatabledc but both throw an invalid handle error when I try to set the pixel format. Pbuffers work just fine when I have a visible window.

Yes, it’s possible.try hard again.
Do you reuse the hdc and hglrc . In my app,i create new hdc and hglrc .

It is good to know it is possible. I have only tried making my own DC’s since I am going in through java so I don’t have access to any pregenerated dc’s. GetDC(0), CreateDC(“DISPLAY”,null,null,null) and CreateCompatableDC(0) all return non-zero DC’s but all return invalid handle errors when I call SetPixelFormat. If you could post just a snippit of code that you know works I would appreciate. I am sure part of it is because of java but hopefully it is something I am doing wrong with windows gdi.

The code reading can be very boring .More often than not, they are useless. I know code tinkering is brain exhausted but would do you good .however if you insist ,please drop me your e mail address.

the problem may lay how you get DC
Why you get DC that way ,why not get DC from window,like GetDC(hwnd).CreateDC(“DISPLAY”) is little like CreateIC is to get the profiler of the current DC. man ,you can not use the DC created that way.

Another to check out is, don’t forget to put the choosePixelFormat api before setPixelFormat.'Cause the return value of the choosePixelFormat is one important parameter in the setPixelFormat.

I would use GetDC(hwin) but I don’t have access to any window handles since I am using java. That is why I am trying to create a device context from scratch. Like I said in the first post I don’t know much about windows gdi. I do get valid pixel formats from choosePixelFormat. If creating DC’s with CreateDC is wrong maybe you could point me in the right direction, that would seem to be the problem since I am getting invalid handle errors when I call setPixelFormat. Any help is much appreciated.

The reason that you can not use CreateDC(“DISPLAY”,NULL,NULL,NULL),is that for such created DC , your opengl app would never know what your DC’s info like resolution ,width,height,etc . However ,GetDC(hwnd) is a more sure bet , the passed-into hwnd parameter make sure the DC is appropriately setted.

If you stick to use the CreateDC
don’t use NULL for the second and fourth parameters
,you can try to use <EnumDisplayDevice> get the devicename and <DocumentProperty> to get the DEVMODE for the CreateDC.

This kind of code can get you very dirty.
And i suspect for the java-GL environment ,is it worth to go that far to do what the java itself is supposed to do --i.e. init GL window for you.

If i were you, i would either use Java to init window ,or use window api to init window. ,mix java and window api in code simply not proper way to do for my taste.
My two cents.

I will give that a try. Thanks for the info.