PDA

View Full Version : Multiple rendering contexts and function pointers



Yandersen
12-07-2014, 10:44 AM
Those function pointers the user of OpenGL has to query with wglGetProcAddress - are those addresses static? I mean, every time the app launches and initializes OpenGL function pointers - does it always get the same addresses? Will the separate instance of the program get the same addresses? Or if the app uses multiple rendering contexts (created with the use of wglCreateContext), is it necessary to duplicate and individually initialize the pointers for each of the RC, or the same function' entry point for all RC will work?

mhagain
12-07-2014, 11:45 AM
The documentation for wglGetProcAddress (http://msdn.microsoft.com/en-us/library/windows/desktop/dd374386%28v=vs.85%29.aspx) says:
The OpenGL library supports multiple implementations of its functions. Extension functions supported in one rendering context are not necessarily available in a separate rendering context. Thus, for a given rendering context in an application, use the function addresses returned by the wglGetProcAddress function only.
But also:
The extension function addresses are unique for each pixel format. All rendering contexts of a given pixel format share the same extension function addresses.
These two don't necessarily contradict. The first warns that they are not necessarily the same (assuming that "not available" == "not the same"), the second gives the condition in which they differ.

So, as long as you're not creating contexts with different pixel formats, it looks like you can rely on them being the same.

Yandersen
12-07-2014, 08:24 PM
Thanks, mhagain!
I hoped for that to be so! :)