本文介绍了通过glUniform1i设置纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于如何通过glUniform1i设置纹理的问题.我已经看到类似下面的代码.

I have a question about how to set the texture by glUniform1i. I have seen code like below.

glActiveTexture(GL_TEXTURE0); 
glBindTexture(GL_TEXTURE_2D, texture0);
glUniform1i(_textureUniform, 0);
glActiveTexture(GL_TEXTURE1); 
glBindTexture(GL_TEXTURE_2D, texture1);
glUniform1i(_textureUniform, 1);

这是否意味着,如果我在glUniform1i中使用数字i,那么我必须使用glActiveTexture(GL_TEXTURE **i** )吗?

Does it mean, if I use the number i in the glUniform1i, then I have to use glActiveTexture(GL_TEXTURE **i** )?

推荐答案

是的,您是正确的.采样器的统一值是指纹理单位,而不是纹理id.

Yes, you are correct. The uniform value for a sampler refers to the texture unit, not the texture id.

这篇关于通过glUniform1i设置纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 06:56