mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-07 01:03:22 +08:00
Merge pull request #87 from zlixine/master
Much faster mesh rendering with c++11 std::to_string
This commit is contained in:
@@ -68,19 +68,18 @@ public:
|
|||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE0 + i); // active proper texture unit before binding
|
glActiveTexture(GL_TEXTURE0 + i); // active proper texture unit before binding
|
||||||
// retrieve texture number (the N in diffuse_textureN)
|
// retrieve texture number (the N in diffuse_textureN)
|
||||||
stringstream ss;
|
|
||||||
string number;
|
string number;
|
||||||
string name = textures[i].type;
|
string name = textures[i].type;
|
||||||
if(name == "texture_diffuse")
|
if(name == "texture_diffuse")
|
||||||
ss << diffuseNr++; // transfer unsigned int to stream
|
number = std::to_string(diffuseNr++);
|
||||||
else if(name == "texture_specular")
|
else if(name == "texture_specular")
|
||||||
ss << specularNr++; // transfer unsigned int to stream
|
number = std::to_string(specularNr++); // transfer unsigned int to stream
|
||||||
else if(name == "texture_normal")
|
else if(name == "texture_normal")
|
||||||
ss << normalNr++; // transfer unsigned int to stream
|
number = std::to_string(normalNr++); // transfer unsigned int to stream
|
||||||
else if(name == "texture_height")
|
else if(name == "texture_height")
|
||||||
ss << heightNr++; // transfer unsigned int to stream
|
number = std::to_string(heightNr++); // transfer unsigned int to stream
|
||||||
number = ss.str();
|
|
||||||
// now set the sampler to the correct texture unit
|
// now set the sampler to the correct texture unit
|
||||||
glUniform1i(glGetUniformLocation(shader.ID, (name + number).c_str()), i);
|
glUniform1i(glGetUniformLocation(shader.ID, (name + number).c_str()), i);
|
||||||
// and finally bind the texture
|
// and finally bind the texture
|
||||||
glBindTexture(GL_TEXTURE_2D, textures[i].id);
|
glBindTexture(GL_TEXTURE_2D, textures[i].id);
|
||||||
|
|||||||
Reference in New Issue
Block a user