Can I set up OpenGL Env without creating main window?

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!!

No, I do not think you can do that. Check with the nvidia papers about setting up a pbuffer.

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

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).]

@Xiao:
and remember: glGetString() returns always “0” while you haven’t initialized the OpenGL-stuff completely !

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