Jump to content
  • Advertisement
Sign in to follow this  
lserlohn

OpenGL how to init OpenGL in a none-windowed program?

This topic is 4237 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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..)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!