Difference between revisions of "OpenGL Context"
m (fixing links)
m (Alfonse moved page OpenGL context to OpenGL Context: Captialized, in accord with Wikipedia standard.)
Revision as of 18:37, 2 October 2012
|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, like textures, buffer objects and program objects. 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.