1 OpenGL Context
- 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. -
Each context has its own set of OpenGL Objects, which are independent of those from other contexts. A context’s objects can be shared with other contexts. Most OpenGL objects are sharable, including Sync Objects and GLSL Objects. Container Objects are not sharable, nor are Query Objects.
- Objects can be separated into two different categories: regular objects and container objects.
| regular objects | container objects |
|---|---|
| Query Objects | Framebuffer Objects |
| Renderbuffer Objects | Program Pipeline Objects |
| Sampler Objects | Transform Feedback Objects |
| Texture Objects | Vertex Array Objects |
- Query Objects are OpenGL Objects that are used for asynchronous queries of certain kinds of information.
-
Any object 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.
本文深入解析OpenGL上下文的概念及其在应用程序中的作用。介绍了上下文如何存储OpenGL的状态,并为渲染指令提供默认帧缓冲区。此外,还探讨了多个上下文在同一进程中的创建与使用方式,以及上下文中对象的共享机制。
1万+

被折叠的 条评论
为什么被折叠?



