User contexts: added context documentation and updated references

This commit is contained in:
Doug Binks 2021-03-23 14:40:54 +00:00
parent 7874992888
commit 1ba83ede44
3 changed files with 53 additions and 7 deletions

View File

@ -92,6 +92,28 @@ You can disable context creation by setting the
without contexts must not be passed to @ref glfwMakeContextCurrent or @ref without contexts must not be passed to @ref glfwMakeContextCurrent or @ref
glfwSwapBuffers. glfwSwapBuffers.
@subsection context_user User contexts for multi context windows
GLFW supports multiple OpenGL or OpenGL ES contexts per window. Providing
a window with an existing OpenGL or OpenGL ES context has been created further
user contexts can be created using @ref glfwCreateUserContext with the same
API sharing the window context objects.
@code
GLFWusercontext* usercontext = glfwCreateUserContext(window);
/* make the user context current */
glfwMakeUserContextCurrent(usercontext);
/* make the window context current */
glfwMakeContextCurrent(window);
/* destroy the user context */
glfwDestroyUserContext(usercontext);
@endcode
User contexts See also the test program `usercontext`.
@section context_current Current context @section context_current Current context
@ -122,6 +144,26 @@ error.
- @ref glfwExtensionSupported - @ref glfwExtensionSupported
- @ref glfwGetProcAddress - @ref glfwGetProcAddress
@subsection context_current_user Current user context
When using [user contexts](@ref context_user) the user context can be
made current using @ref glfwMakeUserContextCurrent.
@code
glfwMakeUserContextCurrent(usercontext);
@endcode
This makes the any window context non-current on the calling thread, such that
a call to @ref glfwGetCurrentContext will return `NULL`.
The current user context is returned by @ref glfwGetCurrentUserContext.
@code
GLFWusercontext* usercontext = glfwGetCurrentUserContext();
@endcode
This will return the current user context or `NULL` if either the main window context
or no context is current.
@section context_swap Buffer swapping @section context_swap Buffer swapping

View File

@ -9,14 +9,14 @@
@subsection features_34 New features in version 3.4 @subsection features_34 New features in version 3.4
@subsubsection user_context_34 Multiple window contexts @subsubsection context_user_34 Multiple window contexts
GLFW now provides the ability to create multiple OpenGL and OpenGL ES GLFW now provides the ability to create multiple OpenGL and OpenGL ES
contexts for a given window. Called user contexts, a [GLFWusercontext](@ref usercontext) contexts for a given window. Called user contexts, a [GLFWusercontext](@ref context_user)
can be created using @ref glfwCreateUserContext, can be created using @ref glfwCreateUserContext,
destroyed using @ref glfwDestroyUserContext, and managed with destroyed using @ref glfwDestroyUserContext, and managed with
@ref glfwMakeUserContextCurrent and @ref glfwGetCurrentUserContext. @ref glfwMakeUserContextCurrent and @ref glfwGetCurrentUserContext.
For more information see the [user context](@ref usercontext) documentation. For more information see the [user context](@ref context_user) documentation.
@subsubsection standard_cursors_34 More standard cursors @subsubsection standard_cursors_34 More standard cursors

View File

@ -1315,7 +1315,7 @@ typedef struct GLFWwindow GLFWwindow;
* *
* Opaque user OpenGL OpenGL ES context object. * Opaque user OpenGL OpenGL ES context object.
* *
* @see @ref usercontext * @see @ref context_user
* *
* @since Added in version 3.4. * @since Added in version 3.4.
* *
@ -5635,7 +5635,7 @@ GLFWAPI uint64_t glfwGetTimerFrequency(void);
* *
* @sa @ref context_current * @sa @ref context_current
* @sa @ref glfwGetCurrentContext * @sa @ref glfwGetCurrentContext
* @sa @ref usercontext_current * @sa @ref context_current_user
* @sa @ref glfwMakeUserContextCurrent * @sa @ref glfwMakeUserContextCurrent
* @sa @ref glfwGetCurrentUserContext * @sa @ref glfwGetCurrentUserContext
* *
@ -5854,6 +5854,7 @@ GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref context_user
* @sa @ref usercontext_creation * @sa @ref usercontext_creation
* @sa @ref glfwDestroyUserContext * @sa @ref glfwDestroyUserContext
* @sa @ref window_creation * @sa @ref window_creation
@ -5887,6 +5888,7 @@ GLFWAPI GLFWusercontext* glfwCreateUserContext(GLFWwindow* window);
* *
* @thread_safety This function must only be called from the main thread. * @thread_safety This function must only be called from the main thread.
* *
* @sa @ref context_user
* @sa @ref usercontext_creation * @sa @ref usercontext_creation
* @sa @ref glfwCreateUserContext * @sa @ref glfwCreateUserContext
* @sa @ref window_creation * @sa @ref window_creation
@ -5926,7 +5928,8 @@ GLFWAPI void glfwDestroyUserContext(GLFWusercontext* context);
* *
* @thread_safety This function may be called from any thread. * @thread_safety This function may be called from any thread.
* *
* @sa @ref usercontext_current * @sa @ref context_user
* @sa @ref context_current_user
* @sa @ref glfwGetCurrentUserContext * @sa @ref glfwGetCurrentUserContext
* @sa @ref context_current * @sa @ref context_current
* @sa @ref glfwMakeContextCurrent * @sa @ref glfwMakeContextCurrent
@ -5950,7 +5953,8 @@ GLFWAPI void glfwMakeUserContextCurrent(GLFWusercontext* context);
* *
* @thread_safety This function may be called from any thread. * @thread_safety This function may be called from any thread.
* *
* @sa @ref usercontext_current * @sa @ref context_user
* @sa @ref context_current_user
* @sa @ref glfwMakeUserContextCurrent * @sa @ref glfwMakeUserContextCurrent
* @sa @ref context_current * @sa @ref context_current
* @sa @ref glfwMakeContextCurrent * @sa @ref glfwMakeContextCurrent