本文整理汇总了C++中Shader::GetProgID方法的典型用法代码示例。如果您正苦于以下问题:C++ Shader::GetProgID方法的具体用法?C++ Shader::GetProgID怎么用?C++ Shader::GetProgID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shader
的用法示例。
在下文中一共展示了Shader::GetProgID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawMesh
//--------------------------------------------------
// AssimpPainter
//--------------------------------------------------
void AssimpPainter::DrawMesh(
const Shader& shader,
GLuint vao,
const Mesh& mesh) const
{
shader.Use();
// Bind appropriate textures
GLuint diffuseNr = 1;
GLuint specularNr = 1;
// Bind textures
std::vector<Texture>::size_type index2 = 0;
for(Texture texture : mesh.textures)
{
glActiveTexture(GL_TEXTURE0 + (GLuint)index2);
// Retrieve texture number (the N in diffuse_textureN)
std::string number;
TextureType type = texture.type;
// Transfer GLuint to stream
switch(type)
{
case TextureType::DIFFUSE:
number += (char)diffuseNr++;
break;
case TextureType::SPECULAR:
number += (char)specularNr++;
break;
default:
break;
}
// Now set the sampler to the correct texture unit
glUniform1i(
glGetUniformLocation(shader.GetProgID(), ("material." + TextureTypeNames[(size_t)type] + number).c_str()),
(GLuint)index2);
// And finally bind the texture
glBindTexture(GL_TEXTURE_2D, texture.id);
index2++;
}
// Also set each mesh's shininess property to a default value
// (if you want you could extend this to another mesh property and possibly change this value)
glUniform1f(glGetUniformLocation(shader.GetProgID(), "material.shininess"), 16.0f);
// Draw mesh
glBindVertexArray(vao);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh.ebo);
glDrawElements(
GL_TRIANGLES,
(GLsizei)mesh.indices.size(),
GL_UNSIGNED_INT,
0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindVertexArray(0);
// "Unbind" textures
index2 = 0;
for(Texture texture : mesh.textures)
{
glActiveTexture(GL_TEXTURE0 + (GLuint)index2);
glBindTexture(GL_TEXTURE_2D, 0);
}
}