PDA

View Full Version : Can I set up OpenGL Env without creating main window?



xiao
06-17-2002, 01:11 PM
Hi,

I am a college student. I am trying to do some openGL work without creating a main window, i.e. not using glut or wxWindows. In order to get DC and RC, I tried these ways:

hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
hdc = CreateCompatibleDC(NULL);

But when calling wglMakeCurrent(hdc, hrc), both do not work. Method glGetString(GL_EXTENSIONS)just returns null. Is there any way I can do it, or I have to create a window? Hope some experts could give me a help.

Thank you very much!!

06-17-2002, 03:45 PM
No, I do not think you can do that. Check with the nvidia papers about setting up a pbuffer.

MattS
06-18-2002, 02:44 AM
You have to create a window in order to instantiate OpenGL (well on Windows you do). You can however hide that window if you wish.

Matt

xiao
06-18-2002, 05:04 AM
Thank you for your suggestions. The reason to do this is trying to reduce some overhead when displaying is not needed.

I do work on pbuffer now and have read some nvidia papers on these topic. Some just mentioned "get your current window's device and render context", but did not explain in detail why. If we just want the image file, a window is really not needed from the high level viewpoint, but maybe some low level implementation details require such a window. I wonder if someone could tell me the "detail".

[This message has been edited by xiao (edited 06-18-2002).]

DJSnow
06-18-2002, 05:38 AM
@Xiao:
and remember: glGetString() returns always "0" while you haven't initialized the OpenGL-stuff completely !

mikael_aronsson
06-18-2002, 05:52 AM
Hi !

You can open a context without using a window, you just need to set the flag that you want to render to an off screen bitmap in the rendering context setup.

wglCreateBlaBla

Mikael