Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How can I initialize a windowless OpenGL context with the minimal amount of code?

I've read here that you can use wglCreateContextAttribsARB to create windowless context, however it doesn't explain how?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
380 views
Welcome To Ask or Share your Answers For Others

1 Answer

From the link:

Creating a context without a window, for off-screen rendering. This may not actually work.

That second sentence is important. From the WGL_ARB_create_context specification:

4) Should there be a way to make a context current without binding it to a window system drawable at the same time?

RESOLVED: Yes, but only in OpenGL 3.0 and later. This results in a context with an invalid default framebuffer, the meaning of which is defined in the OpenGL 3.0 specification.

NOTE: Apparently on Windows, opengl32.dll makes use of the drawable argument to identify the namespace of the driver, so we may not be able to work around it.

The specification doesn't allow you to create a context without a window, since it needs the pixel format that you set into the device context. But you theoretically can pass NULL for the HDC when making the context current, which causes OpenGL to not have a default framebuffer.

But, as noted above, this may not actually work. You can try it to see what happens, but I wouldn't get my hopes up.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...