Qt3d + glShadeModel

跟風遠走 提交于 2019-12-24 03:21:56

问题


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

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

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)

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


回答1:


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

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 inherits QGLAbstractEffect and is the class you are looking for in this case.

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.



来源:https://stackoverflow.com/questions/11091993/qt3d-glshademodel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!