如何从不同线程绘制opengl图形?

编程入门 行业动态 更新时间:2024-10-21 18:48:09
本文介绍了如何从不同线程绘制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图形?

本文发布于:2023-11-12 12:26:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581494.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:线程   图形   opengl

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!