mirror of
https://github.com/LearnOpenGL-CN/LearnOpenGL-CN.git
synced 2025-08-23 04:35:28 +08:00
Update 06 Textures.md
This commit is contained in:
@@ -368,7 +368,7 @@ glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||
我们还要通过使用<fun>glUniform1i</fun>设置每个采样器的方式告诉OpenGL每个着色器采样器属于哪个纹理单元。我们只需要设置一次即可,所以这个会放在渲染循环的前面:
|
||||
|
||||
```c++
|
||||
ourShader.use(); // 别忘记在激活着色器前先设置uniform!
|
||||
ourShader.use(); // 不要忘记在设置uniform变量之前激活着色器程序!
|
||||
glUniform1i(glGetUniformLocation(ourShader.ID, "texture1"), 0); // 手动设置
|
||||
ourShader.setInt("texture2", 1); // 或者使用着色器类设置
|
||||
|
||||
|
Reference in New Issue
Block a user