概念
- Subroutine赋予了代码动态调用shader中函数的能力
- 写法比较固定,直接上代码
1 | #version 400 core |
- cpp代码中获得这些函数的index
1 | GLuint amibentLightIndex = glGetSubroutineIndex(program, GL_FRAGMENT_SHADER, "Ambient"); |
1 | model = glm::translate(1.0f, -0.5f, -4.0f)*glm::rotate(-90.0f, 0.0f, 1.0f, 0.0f)*glm::scale(0.01f, 0.01f, 0.01f); |