OpenGL Context: Difference between revisions
m (Alfonse moved page OpenGL context to OpenGL Context: Captialized, in accord with Wikipedia standard.) |
(Also list object types that aren't shareable) |
||
Line 5: | Line 5: | ||
Contexts are localized within a particular process of execution (an application, more or less) on an operating system. A process can create multiple OpenGL contexts. Each context can represent a separate viewable surface, like a window in an application. | Contexts are localized within a particular process of execution (an application, more or less) on an operating system. A process can create multiple OpenGL contexts. Each context can represent a separate viewable surface, like a window in an application. | ||
Contexts can share many kinds of objects between each other | Contexts can share many kinds of objects between each other (see below). However, this sharing must be made explicitly, either as the context is created or before a newly created context creates any objects. However, contexts do not ''have'' to share objects; they can remain completely separate from one another. | ||
In order for any OpenGL commands to work, a context must be ''current''; all OpenGL commands affect the state of whichever context is current. The current context is a thread-local variable, so a single process can have several threads, each of which has its own current context. However, a single context cannot be current in multiple threads at the same time. | In order for any OpenGL commands to work, a context must be ''current''; all OpenGL commands affect the state of whichever context is current. The current context is a thread-local variable, so a single process can have several threads, each of which has its own current context. However, a single context cannot be current in multiple threads at the same time. | ||
== Which object types can be shared between contexts? == | |||
=== Shareable === | |||
* [[Texture]]s | |||
* [[Buffer Object]]s | |||
* [[GLSL Object]]s | |||
=== Not shareable === | |||
* [[Framebuffer Object]]s | |||
* [[Vertex Array Object]]s |
Revision as of 20:08, 27 November 2013
This article is a stub. You can help the OpenGL Wiki by expanding it. |
An OpenGL context represents many things. A context stores all of the state associated with this instance of OpenGL. It represents the (potentially visible) default framebuffer that rendering commands will draw to when not drawing to a framebuffer object. Think of a context as an object that holds all of OpenGL; when a context is destroyed, OpenGL is destroyed.
Contexts are localized within a particular process of execution (an application, more or less) on an operating system. A process can create multiple OpenGL contexts. Each context can represent a separate viewable surface, like a window in an application.
Contexts can share many kinds of objects between each other (see below). However, this sharing must be made explicitly, either as the context is created or before a newly created context creates any objects. However, contexts do not have to share objects; they can remain completely separate from one another.
In order for any OpenGL commands to work, a context must be current; all OpenGL commands affect the state of whichever context is current. The current context is a thread-local variable, so a single process can have several threads, each of which has its own current context. However, a single context cannot be current in multiple threads at the same time.