如何从不同线程绘制opengl图形? [英] How to draw opengl graphics from different threads?

查看:94
本文介绍了如何从不同线程绘制opengl图形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个显示一些3D图形和命令行的opengl应用程序.我想使它们成为单独的线程,因为它们都是繁重的过程.我以为我可以使用2个不同的视口来实现这一点,但是我想知道如何处理opengl中的线程.

I want to make an opengl application that shows some 3d graphics and a command-line. I would like to make them separate threads, because they both are heavy processes. I thought that I could approach this with 2 different viewports, but I would like to know how to handle the threads in opengl.

根据我所读的内容,Opengl是异步的,从不同线程调用其功能可能会遇到很大问题.有没有办法可以用来解决这个问题?理想情况下,我想在3d图形的顶部绘制命令行,并具有透明效果...(我猜这在视口中是不可能的)

According to what I've been reading, Opengl is asynchronous, and calling its functions from different threads can be very problematic. Is there a way that I could use to approach this problem? Ideally, I would like to draw the command line on top of the 3d graphics with some transparecy effect... (this is impossible with viewports I guess)

该解决方案具有可移植性很重要.

Is important that the solution is portable.

谢谢!

推荐答案

有可能您可以使用叠加来实现您想做的事情.
叠加是一种过时的功能,但在大多数设置中仍应支持.基本上,叠加层是一个单独的GL Context,它在与另一层相同的窗口中呈现,并在具有原始上下文的窗口上绘制的任何内容之上绘制.
您可以在此处阅读.

Its possible you can achieve what you want to do using Overlays.
Overlays are a somewhat dated feature but it should still be supported in most setups. Basically an overlay is a separate GL Context which is rendered in the same window as another layer, drawing on top of whatever was drawn on the windows with its original context.
You can read about it here.

这篇关于如何从不同线程绘制opengl图形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆