aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/Shader.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-09-10 19:47:21 +0800
committerchai <chaifix@163.com>2018-09-10 19:47:21 +0800
commitd5cda5fddc078fa5fdb93805785fc707f050d8e7 (patch)
tree46224cbddb79959cbc26f045c757a9dde7ebb23b /src/libjin/Graphics/Shader.cpp
parent435e17c1a81fa74a45465829bd42d36e7fa24406 (diff)
*update
Diffstat (limited to 'src/libjin/Graphics/Shader.cpp')
-rw-r--r--src/libjin/Graphics/Shader.cpp21
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);