共享OpenGL VAO/VBO/etc通过QGLWidget [英] Sharing OpenGL VAO/VBO/etc. via QGLWidget

查看:277
本文介绍了共享OpenGL VAO/VBO/etc通过QGLWidget的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用QGLWidgets的3层层次结构在类似CAD的应用程序的5个OpenGL视口之间共享着色器和顶点数据.根上下文用于编译应用程序范围的着色器,每个文档上下文用于共享模型顶点数据,而视口上下文是实际进行渲染的对象(还包含网格顶点数据和每个视口的其他内容).

I am using a 3 layer hierarchy of QGLWidgets to share shaders and vertex data between 5 OpenGL viewports in my CAD-like app. The root context is used for compiling application-wide shaders, the per document context is used to share model vertex data, and the viewport contexts are the ones that actually do the rendering (and also contain grid vertex data and other per viewport stuff).

着色器共享似乎工作正常,网格绘图也是如此,但是在共享顶点数据时却失败了,说实话-我看不到它应该如何工作...

The shader sharing seems to work fine, and so does the grid drawing, but when it comes to sharing vertex data it fails and to be honest - I cannot see how it is supposed to work...

在模型上下文为当前时,我为一个项目构建了一个3D图标,因为它是第一个VAO,其名称"为1.当我绘制对象时,视口上下文(与模型上下文请记住)是当前的,因此调用了VAO 1,但是绘制的是视口的 VAO 1-我漂亮的红色网格中心线. OpenGL上下文可以共享,但是由于名称不是唯一的,您如何指定每个项目所属的命名空间"?

I built a 3D icon for an item whilst the model context was current, as it was the first VAO it had a 'name' of 1. When I come to draw the object, the viewport context (which is shared with the model context remember) is current, so VAO 1 is called but it's the viewport's VAO 1 that is drawn - my nice red grid centre line. The OpenGL contexts can be shared but how can you specify the 'namespace' each item belongs to as the names are not unique?

我试图在模型VAO调用之前将模型上下文设为当前,但是绘制了正确的VAO或视口,我认为在QPainter :: beginNativePainting()块中切换上下文不会使OpenGL满意.

I tried making the model context current just before the model VAO calls, but the proper VAO nor the viewport one are drawn, I think switching context during a QPainter::beginNativePainting() block does not make OpenGL happy.

对我来说,这似乎是一件非常基本的事情,所以我必须做一些愚蠢的事情-有任何建议吗?

This seems a very basic thing to me so I must be doing something stupid - any suggestions?

推荐答案

在OpenGL论坛上感谢Alfonse Reinheart,我现在知道这是因为VAO在上下文之间不共享.

Thanks to Alfonse Reinheart over at the OpenGL forums, I now know that it is because VAOs are not shared between contexts.

这篇关于共享OpenGL VAO/VBO/etc通过QGLWidget的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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