how to init OpenGL in a none-windowed program?

Started by
5 comments, last by Krohm 17 years, 4 months ago
how to init OpenGL in a none-windowed program? I want to make a OpenGL program without a window, that is Rendering off screen and exporting to a bmp file. But I don't know how to init OpenGL in this none-windowed program. In a windowed program,there are always using CreateWindowEx() to create a window and then get back the HWND, and then : hDC = GetDC(HWND); hRC = wglCreateContext(hDC); wglMakeCurrent(hDC, hRC); But in my program ,there isn't any window,so how do I get the HWND hDC and hRC? Thanks.
Advertisement
Haven't done this, but I guess you could try to create a memoryDC using CreateCompatibleDC, create a bitmap, call SelectObject to bind the DC to the bitmap and then use that DC to call wglCreateContext.
Yes, you have to create Rendering Context with an own pixelformat with PFD_DRAW_TO_BITMAP flag. Then create a compatible DC and a bitmap and select it for the DC. Then you can render your scene directly to the memory. Maybe you have to know that it won't use any hardware acceleration, it will be done by CPU.
Thanks, but this job is too costly, I really need hardware accelerate.

Is there a way to use hardware accelerate without creating a window?

or Is there any better idea? I want to "pack" the openGL program into a COM object.
Would it be OK for your program to use a hidden window? So, create a window as usual, but never call ShowWindow on it? Then, use glReadPixels to read from the frame buffer and write that to a file.
(Again, I'm just guessing if this would work..)
I did this a while ago and I don't totally remember what I did but from what I recall you definitely had to create a window and I think you had to realize it. After that you could hide it with no worries.
"... we should have such an empire for liberty as she has never surveyed since the creation ..."Thomas Jefferson
Quote:Original post by GKW
I did this a while ago and I don't totally remember what I did but from what I recall you definitely had to create a window and I think you had to realize it. After that you could hide it with no worries.

This seems familiar also to me.

Previously "Krohm"

This topic is closed to new replies.

Advertisement