diff --git a/src/graphics/gpuparticles.cpp b/src/graphics/gpuparticles.cpp index 26db98880..1b4839f62 100644 --- a/src/graphics/gpuparticles.cpp +++ b/src/graphics/gpuparticles.cpp @@ -105,11 +105,11 @@ public: assignUniforms("sourcematrix", "dt", "level", "size_increase_factor", "track_x", "track_x_len", "track_z", "track_z_len"); m_TU_heightmap = 2; - assignTextureUnit(TexUnit(m_TU_heightmap, "heightmap")); - } + assignTextureUnit(m_TU_heightmap, "heightmap"); + } // HeightmapSimulationShader -}; +}; // class HeightmapSimulationShader // ============================================================================ diff --git a/src/graphics/shader.hpp b/src/graphics/shader.hpp index fd8b9967c..5685e0828 100644 --- a/src/graphics/shader.hpp +++ b/src/graphics/shader.hpp @@ -240,35 +240,21 @@ private: } // printFileList protected: - /** Stores texture index and uniform. */ - class TexUnit - { - public: - GLuint m_index; - const char* m_uniform; - - TexUnit(GLuint index, const char* uniform) - { - m_index = index; - m_uniform = uniform; - } // TexUnit - }; // class TexUnit - // ======================================================================== - void assignTextureUnit(TexUnit tex_unit) + void assignTextureUnit(GLuint index, const char* uniform) { glUseProgram(m_program); - GLuint uniform = glGetUniformLocation(m_program, tex_unit.m_uniform); - glUniform1i(uniform, tex_unit.m_index); + GLuint uniform_loc = glGetUniformLocation(m_program, uniform); + glUniform1i(uniform_loc, index); glUseProgram(0); } // assignTextureUnit // ------------------------------------------------------------------------ template - void assignTextureUnit(TexUnit tex_unit, T... rest) + void assignTextureUnit(GLuint index, const char* uniform, T... rest) { glUseProgram(m_program); - GLuint uniform = glGetUniformLocation(m_program, tex_unit.m_uniform); - glUniform1i(uniform, tex_unit.m_index); + GLuint uniform_loc = glGetUniformLocation(m_program, uniform); + glUniform1i(uniform_loc, index); assignTextureUnitNoUse(rest...); glUseProgram(0); } // assignTextureUnit @@ -277,12 +263,12 @@ protected: void assignTextureUnitNoUse() {} // ------------------------------------------------------------------------ template - void assignTextureUnitNoUse(TexUnit tex_unit, T... rest) + void assignTextureUnitNoUse(GLuint index, const char* uniform, T... rest) { - GLuint uniform = glGetUniformLocation(m_program, tex_unit.m_uniform); - glUniform1i(uniform, tex_unit.m_index); + GLuint uniform_loc = glGetUniformLocation(m_program, uniform); + glUniform1i(uniform_loc, index); assignTextureUnitNoUse(rest...); - } + } // assignTextureUnitNoUse public: diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 6c48d9680..5381660b5 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -515,39 +515,9 @@ namespace UtilShader glBindVertexArray(0); glBindBuffer(GL_ARRAY_BUFFER, 0); } - - - template - std::vector TexUnits(T curr) // required on older clang versions - { - std::vector v; - v.push_back(curr); - return v; - } - - template - std::vector TexUnits(T curr, R... rest) // required on older clang versions - { - std::vector v; - v.push_back(curr); - VTexUnits(v, rest...); - return v; - } - - template - void VTexUnits(std::vector& v, T curr, R... rest) // required on older clang versions - { - v.push_back(curr); - VTexUnits(v, rest...); - } - - template - void VTexUnits(std::vector& v, T curr) - { - v.push_back(curr); - } - } + + using namespace UtilShader; @@ -791,7 +761,7 @@ namespace UtilShader assignUniforms("PermutationMatrix", "ViewportSize"); TU_Samples = 1; AssignSamplerNames(m_program, 0, "tex"); - assignTextureUnit(TexUnit(TU_Samples, "samples")); + assignTextureUnit(TU_Samples, "samples"); } } @@ -1576,7 +1546,7 @@ namespace FullScreenShader TU_SHR = 0; TU_SHG = 1; TU_SHB = 2; - assignTextureUnit(TexUnit(TU_SHR, "SHR"), TexUnit(TU_SHG, "SHG"), TexUnit(TU_SHB, "SHB")); + assignTextureUnit(TU_SHR, "SHR", TU_SHG, "SHG", TU_SHB, "SHB"); } GlobalIlluminationReconstructionShader::GlobalIlluminationReconstructionShader() @@ -1606,7 +1576,7 @@ namespace FullScreenShader TU_dest = 2; assignUniforms("pixel"); AssignSamplerNames(m_program, 0, "source", 1, "depth"); - assignTextureUnit(TexUnit(TU_dest, "dest")); + assignTextureUnit(TU_dest, "dest"); } ComputeGaussian6HBlurShader::ComputeGaussian6HBlurShader() @@ -1616,7 +1586,7 @@ namespace FullScreenShader TU_dest = 1; assignUniforms("pixel", "weights"); AssignSamplerNames(m_program, 0, "source"); - assignTextureUnit(TexUnit(TU_dest, "dest")); + assignTextureUnit(TU_dest, "dest"); } ComputeShadowBlurHShader::ComputeShadowBlurHShader() @@ -1626,7 +1596,7 @@ namespace FullScreenShader TU_dest = 1; assignUniforms("pixel", "weights"); AssignSamplerNames(m_program, 0, "source"); - assignTextureUnit(TexUnit(TU_dest, "dest")); + assignTextureUnit(TU_dest, "dest"); } Gaussian6HBlurShader::Gaussian6HBlurShader() @@ -1676,7 +1646,7 @@ namespace FullScreenShader TU_dest = 2; assignUniforms("pixel"); AssignSamplerNames(m_program, 0, "source", 1, "depth"); - assignTextureUnit(TexUnit(TU_dest, "dest")); + assignTextureUnit(TU_dest, "dest"); } ComputeGaussian6VBlurShader::ComputeGaussian6VBlurShader() @@ -1686,7 +1656,7 @@ namespace FullScreenShader TU_dest = 1; assignUniforms("pixel", "weights"); AssignSamplerNames(m_program, 0, "source"); - assignTextureUnit(TexUnit(TU_dest, "dest")); + assignTextureUnit(TU_dest, "dest"); } ComputeShadowBlurVShader::ComputeShadowBlurVShader() @@ -1696,7 +1666,7 @@ namespace FullScreenShader TU_dest = 1; assignUniforms("pixel", "weights"); AssignSamplerNames(m_program, 0, "source"); - assignTextureUnit(TexUnit(TU_dest, "dest")); + assignTextureUnit(TU_dest, "dest"); } Gaussian6VBlurShader::Gaussian6VBlurShader() @@ -1736,7 +1706,7 @@ namespace FullScreenShader GL_FRAGMENT_SHADER, "layertexturequad.frag"); TU_texture = 0; assignUniforms("layer"); - assignTextureUnit(TexUnit(TU_texture, "tex")); + assignTextureUnit(TU_texture, "tex"); vao = createVAO(m_program); }