At the moment I have multiple scenes in my application.
Each scene has its own device context and its own pixel format.
Each device context has an OpenGl context (created for example with
The association is 1:1.
I would like to have multiple Device Context and only one OpenGl context for all.
Then in my rendering loop I would like to set for my unique OpenGl context the needed Device Context.
Is it possible?
Any suggestions are welcome
Thanks for the help
wglMakeCurrent doesn’t require that you use the same device context as was used for creating the rendering context, but it must have the same pixel format. Source.
Similarly, rendering contexts created for device contexts with different pixel formats cannot share data (or rather, it’s implementation-dependent whether they can share data). Source.
IOW, it’s going to be much simpler if you use a single pixel format.
Finally, if you have multiple physical devices (e.g. using both integrated graphics and a discrete GPU simultaneously), you can’t share anything between them. Even the function pointers returned by
wglGetProcAddress vary between drivers, so you can’t use GLEW, GLAD, etc for loading but must maintain separate function pointers for each device.
Assuming a loose connection between an actual device and a device context, which I am assuming is more like a window/widget context, you can use context sharing. As mentioned there are limits and you have to double check if the sharing actually worked after creation.
You talked about using wgl functions, so assuming Windows, my experience has been that the main discrete GPU vendors Windows drivers will share contexts without issue.
Create one central context that is you OpenGL context.
Then when creating new windows and contexts for them, share off of the OpenGL context.
When rendering, set the OpenGL context, render into it using an FBO, do not use the GL_FRONT/GL_BACK targets.
Once rendered, set the Window context, setup and an FBO using the previous context colo[u]r texture. Then blit from it to the GL_BACK/GL_FRONT.
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.