OpenGL 查看器控制和渲染上下文
我构建了一个 OpenGL 查看器控件,可以简单地将其拖放到 Windows 窗体上(在设计时)并分配一个 OpenGL 显示列表(在运行时)。
查看器控件处理导航、显示选项(例如背景颜色)等。它还负责根据需要创建和销毁渲染和设备上下文。
显然,每个查看器控件实例都有自己的设备上下文,即绘制图像的“窗口”。
问题:
- 每个查看器控件实例应如何管理渲染上下文?
- 每个实例应该有自己的上下文还是共享全局渲染上下文?
我特别关心这如何影响 WGL 字体创建 (wglUseFontBitmaps 和 wglUseFontOutlines),它需要渲染上下文(无论当前上下文是什么)和设备上下文。
- 我是否需要为每个渲染/设备上下文组合创建每个 WGL 字体?
也许我的方法有缺陷。
I have built an OpenGL Viewer control that can simply be dropped onto a windows form (at design time) and assigned an OpenGL display list (at run time).
The viewer control handles navigation, display options (e.g. background color), etc. It is also responsible for creating and destroying rendering and device contexts as necessary.
Obviously, each viewer control instance has its own device context, the 'window' where the image is drawn.
Questions:
- How should each viewer control instance manage rendering contexts?
- Should each instance have it's own context or share a global rendering context?
I'm particularly concerned with how this affects WGL font creation (wglUseFontBitmaps and wglUseFontOutlines), which requires a rendering context (whatever the current context is) and a device context.
- Do I need to create each WGL font for each rendering/device context combination?
Perhaps my approach is flawed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会采用每个控制方法的上下文。您必须记住,扩展是基于上下文的,因此您必须为您创建的每个扩展绑定它们(我使用 glew_MX 来处理此问题)。
此外,您可以跨上下文共享显示列表(只要它们位于同一 GPU 上),并且 wgl 字体创建会创建显示列表,所以您应该没问题。
I would go with the context per control approach. You do have to remember that extensions are context based so you'll have to bind them for each one you make (I use glew_MX to handle this).
Also, you can share display lists across contexts (as long as they are on the same gpu) and the wgl font creation creates display lists so you should be fine.