Qt(QOpenGLShaderProgram)设置一个统一的布尔值?

2024-09-19 23:40:23 发布

您现在位置:Python中文网/ 问答频道 /正文

如何使用QOpenGLShaderProgram将布尔值传递给片段着色器?(Python)

如果我的程序被称为_program,我能用这样的方法吗:

self._program.setUniformValue('myVar', 1)

为了传递值true,然后在我的片段着色器中使用它,请使用:

uniform bool myVar;

可以吗?或者我应该用另一种方法吗? 谢谢!你知道吗


Tags: 方法self程序trueuniformprogrambool着色器
1条回答
网友
1楼 · 发布于 2024-09-19 23:40:23

没关系。^{} documentation说:

Either the i, ui or f variants may be used to provide values for uniform variables of type bool, bvec2, bvec3, bvec4, or arrays of these. The uniform variable will be set to false if the input value is 0 or 0.0f, and it will be set to true otherwise.

相关问题 更多 >