Cheery
Cheery

Reputation: 25463

Can you create OpenGL context without opening a window?

Occassionally I hit places where I'd want to get an OpenGL framebuffer object, but where I'm not interested about opening a window of any kind.

Is it possible to create an opengl context without attaching it to a window of any kind?

Upvotes: 32

Views: 16017

Answers (3)

ahoffer
ahoffer

Reputation: 6546

http://www.opengl.org/wiki/Creating_an_OpenGL_Context

According to this Web page, WGL_ARB_create_context can be used to create a context without a window. I have not actually tried it myself. I used freeGLUT to create the context and then rendered off-screen to a framebuffer+renderbuffer. I exit the program without ever calling glutMainLoop. It is klugy, but it works for my purposes.

Upvotes: 6

Ronny Vindenes
Ronny Vindenes

Reputation: 2361

Yes, you can perform off-screen rendering with OpenGL, but the exact way to set it up is dependent on the operating system. The closest you get to an OS independent way would be to use Mesa 3D, but then your off-screen rendering would not be hw accelerated.

Upvotes: 2

Dror Helper
Dror Helper

Reputation: 30819

Yes! you can use the desktop window as the window passed to OpenGL- as long as you don't try to display anything on it ;)

Just Call GetDesktopWindow and pass the result as an argument when creating new OpenGL window.

Upvotes: 14

Related Questions