Qt3d + glShadeModel [英] Qt3d + glShadeModel

查看:103
本文介绍了Qt3d + glShadeModel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我开始使用qt3d(带有QGlView和QGLSceneNode).我为生成的模型提供了每个顶点的法线,现在想为我的建模应用程序使用GL_FLAT阴影模型.但是,简单地调用glShadeModel(GL_FLAT)不会执行任何操作-阴影看起来就像在平滑模式下一样

Recently I began to use qt3d (with it's QGlView and QGLSceneNode). I provide per-vertex normals for generated model and now want to use GL_FLAT shading model for my modeling app. But simple call to glShadeModel(GL_FLAT) doesnt do anything - shading is doing look like in smooth mode

我试图找到qt3d/qopengl在哪里调用该函数,但是除了QGLBuilder找不到任何东西.

I tried to find where qt3d/qopengl calls that function but besides QGLBuilder couldn't find anything.

在我看来,我必须对QOpenGLContext进行某些操作才能使本机opengl函数起作用(我在其他一些opengl函数中也遇到了同样的问题)

It seems to me that I have to do something with QOpenGLContext to make native opengl functions work (I have same problems with some other opengl functions)

还是QGLPainter/QGLSceneNode在内部设置着色模型,而我根本不需要使用它?

or maybe QGLPainter/QGLSceneNode internally sets shading model and I have not to use it at all?

推荐答案

我想您已经找到了解决方案或已放弃,但是出于完整性考虑,如果我对您的理解正确,这应该会有所帮助:

I guess you already found the solution or gave up, but for completeness this should help if I understood you correctly:

QGLPainter通过高级"效果设置着色程序,然后在绘制(渲染)QGLSceneNode s时使用.您可以使用此功能设置一些标准效果:

QGLPainter sets the shading program via a "high level" effect which will then be used when drawing (rendering) QGLSceneNodes. There are some standard effects you can set using this function:

void QGLPainter::setStandardEffect(QGL::StandardEffect effect);

在文档中定义了标准效果 .如果找不到所需的内容,则可以使用以下功能传递用户效果:

The standard effects are defined in the documentation. If you can't find what you want, you can pass a user effect using this function:

void QGLPainter::setUserEffect(QGLAbstractEffect * effect)

QGLShaderProgramEffect 继承了QGLAbstractEffect,并且是您所使用的类在这种情况下正在寻找.

QGLShaderProgramEffect inherits QGLAbstractEffect and is the class you are looking for in this case.

还请注意,Qt3D类似于高级" OpenGL包装器.在大多数情况下(除了初始化代码和其他一些东西),直接调用OpenGL命令不是正确的方法".您应该告诉Qt3D什么以及如何渲染,而不是OpenGL API.

Please also note that Qt3D is something like a "high level" OpenGL wrapper. Calling OpenGL commands directly isn't "the correct way" in most cases (apart from initialization code and some other things). You should tell Qt3D what and how to render, not the OpenGL API.

这篇关于Qt3d + glShadeModel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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