diff options
Diffstat (limited to 'src/libjin/Graphics/Shader.cpp')
-rw-r--r-- | src/libjin/Graphics/Shader.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/libjin/Graphics/Shader.cpp b/src/libjin/Graphics/Shader.cpp index 7f849a6..12d4db0 100644 --- a/src/libjin/Graphics/Shader.cpp +++ b/src/libjin/Graphics/Shader.cpp @@ -11,9 +11,15 @@ namespace graphics using namespace jin::filesystem; + /** + * default_texture + * base_shader + * SHADER_FORMAT_SIZE + * formatShader + */ #include "base.shader.h" - /* + /** * https://stackoverflow.com/questions/27941496/use-sampler-without-passing-through-value * The default value of a sampler variable is 0. From the GLSL 3.30 spec, * section "4.3.5 Uniforms": @@ -57,8 +63,7 @@ namespace graphics JSLProgram::JSLProgram(const char* program) : currentTextureUnit(DEFAULT_TEXTURE_UNIT) { - int size = strlen(program) + SHADER_FORMAT_SIZE; - Buffer b = Buffer(size); + Buffer b = Buffer(strlen(program) + SHADER_FORMAT_SIZE); formatShader((char*)b.data, program); GLuint shader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(shader, 1, (const GLchar**)&b.data, NULL); @@ -92,7 +97,9 @@ namespace graphics { glUseProgram(pid); currentJSLProgram = this; - bindDefaultTexture(); + /* bind default texture */ + int loc = glGetUniformLocation(pid, default_texture); + glUniform1i(loc, DEFAULT_TEXTURE_UNIT); } /*static*/ void JSLProgram::unuse() @@ -101,12 +108,6 @@ namespace graphics currentJSLProgram = nullptr; } - void JSLProgram::bindDefaultTexture() - { - int loc = glGetUniformLocation(pid, default_texture); - glUniform1i(loc, DEFAULT_TEXTURE_UNIT); - } - GLint JSLProgram::claimTextureUnit(const std::string& name) { std::map<std::string, GLint>::iterator unit = textureUnits.find(name); |