OpenGL Context

本文深入解析OpenGL上下文的概念及其在应用程序中的作用。介绍了上下文如何存储OpenGL的状态,并为渲染指令提供默认帧缓冲区。此外,还探讨了多个上下文在同一进程中的创建与使用方式,以及上下文中对象的共享机制。

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 objectscontainer objects
Query ObjectsFramebuffer Objects
Renderbuffer ObjectsProgram Pipeline Objects
Sampler ObjectsTransform Feedback Objects
Texture ObjectsVertex 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.

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值