本文整理汇总了C++中Shaders::ID方法的典型用法代码示例。如果您正苦于以下问题:C++ Shaders::ID方法的具体用法?C++ Shaders::ID怎么用?C++ Shaders::ID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shaders
的用法示例。
在下文中一共展示了Shaders::ID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void Mesh::Draw(Shaders & shader)
{
unsigned int diffuseNr = 1;
unsigned int specularNr = 1;
unsigned int normalNr = 1;
unsigned int heightNr = 1;
for(size_t i = 0; i < this->_textures.size(); i++)
{
glActiveTexture(GL_TEXTURE0 + i); // activate proper texture unit before binding
// retrieve texture number (the N in diffuse_textureN)
std::string number;
std::string name = this->_textures[i]._type;
if(name == "texture_diffuse")
number = std::to_string(diffuseNr++);
else if(name == "texture_specular")
number = std::to_string(specularNr++);
else if(name == "texture_normal")
number = std::to_string(normalNr++);
else if(name == "texture_height")
number = std::to_string(heightNr++);
glUniform1i(glGetUniformLocation(shader.ID(), (name + number).c_str()), i);
glBindTexture(GL_TEXTURE_2D, this->_textures[i]._id);
}
// draw mesh
glBindVertexArray(VAO);
glDrawElements(GL_TRIANGLES, this->_indices.size(), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
glActiveTexture(GL_TEXTURE0);
}