aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/render/jsl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/render/jsl.cpp')
-rw-r--r--src/libjin/render/jsl.cpp100
1 files changed, 50 insertions, 50 deletions
diff --git a/src/libjin/render/jsl.cpp b/src/libjin/render/jsl.cpp
index 58b9a15..3702e14 100644
--- a/src/libjin/render/jsl.cpp
+++ b/src/libjin/render/jsl.cpp
@@ -10,7 +10,7 @@ namespace render
"#define number float \n"
"#define Image sampler2D \n"
"#define Canvas sampler2D \n"
- "#define Color vec4 \n"
+ "#define Color vec4 \n"
"#define Texel texture2D \n"
"#define extern uniform \n"
"uniform Image _tex0_; \n"
@@ -19,10 +19,10 @@ namespace render
"gl_FragColor = effect(gl_Color, _tex0_, gl_TexCoord[0].xy, gl_FragCoord.xy);\n"
"}\0";
- shared GLint JSLProgram::currentTextureUnit = 0;
- shared GLint JSLProgram::maxTextureUnits = -1;
+ shared GLint JSLProgram::currentTextureUnit = 0;
+ shared GLint JSLProgram::maxTextureUnits = -1;
- shared JSLProgram* JSLProgram::currentJSLProgram = nullptr;
+ shared JSLProgram* JSLProgram::currentJSLProgram = nullptr;
JSLProgram::JSLProgram(const char* program)
{
@@ -61,17 +61,17 @@ namespace render
std::map<std::string, GLint>::iterator texture_unit = texturePool.find(name);
if (texture_unit != texturePool.end())
return texture_unit->second;
- if (++currentTextureUnit >= maxTextureUnits)
- return 0;
+ if (++currentTextureUnit >= maxTextureUnits)
+ return 0;
texturePool[name] = currentTextureUnit;
- return currentTextureUnit;
+ return currentTextureUnit;
}
#define checkJSL() if (currentJSLProgram != this) return
void JSLProgram::sendFloat(const char* variable, float number)
{
- checkJSL();
+ checkJSL();
int loc = glGetUniformLocation(pid, variable);
glUniform1f(loc, number);
@@ -79,12 +79,12 @@ namespace render
void JSLProgram::sendImage(const char* variable, const Image* image)
{
- checkJSL();
+ checkJSL();
GLint texture_unit = JSLProgram::getTextureUnit(variable);
GLint location = glGetUniformLocation(pid, variable);
- glUniform1i(location, texture_unit);
+ glUniform1i(location, texture_unit);
glActiveTexture(GL_TEXTURE0 + texture_unit);
glBindTexture(GL_TEXTURE_2D, image->getTexture());
@@ -92,57 +92,57 @@ namespace render
glActiveTexture(GL_TEXTURE0);
}
- void JSLProgram::sendCanvas(const char* variable, const Canvas* canvas)
- {
- checkJSL();
+ void JSLProgram::sendCanvas(const char* variable, const Canvas* canvas)
+ {
+ checkJSL();
- GLint texture_unit = getTextureUnit(variable);
+ GLint texture_unit = getTextureUnit(variable);
- GLint location = glGetUniformLocation(pid, variable);
- glUniform1i(location, texture_unit);
+ GLint location = glGetUniformLocation(pid, variable);
+ glUniform1i(location, texture_unit);
- glActiveTexture(GL_TEXTURE0 + texture_unit);
- glBindTexture(GL_TEXTURE_2D, canvas->getTexture());
+ glActiveTexture(GL_TEXTURE0 + texture_unit);
+ glBindTexture(GL_TEXTURE_2D, canvas->getTexture());
- glActiveTexture(GL_TEXTURE0);
- }
+ glActiveTexture(GL_TEXTURE0);
+ }
- void JSLProgram::sendVec2(const char* name, float x, float y)
- {
- checkJSL();
+ void JSLProgram::sendVec2(const char* name, float x, float y)
+ {
+ checkJSL();
- int loc = glGetUniformLocation(pid, name);
- glUniform2f(loc, x, y);
- }
+ int loc = glGetUniformLocation(pid, name);
+ glUniform2f(loc, x, y);
+ }
- void JSLProgram::sendVec3(const char* name, float x, float y, float z)
- {
- checkJSL();
+ void JSLProgram::sendVec3(const char* name, float x, float y, float z)
+ {
+ checkJSL();
- int loc = glGetUniformLocation(pid, name);
- glUniform3f(loc, x, y, z);
- }
+ int loc = glGetUniformLocation(pid, name);
+ glUniform3f(loc, x, y, z);
+ }
- void JSLProgram::sendVec4(const char* name, float x, float y, float z, float w)
- {
- checkJSL();
+ void JSLProgram::sendVec4(const char* name, float x, float y, float z, float w)
+ {
+ checkJSL();
- int loc = glGetUniformLocation(pid, name);
- glUniform4f(loc, x, y, z, w);
- }
+ int loc = glGetUniformLocation(pid, name);
+ glUniform4f(loc, x, y, z, w);
+ }
- void JSLProgram::sendColor(const char* name, const color* col)
- {
- checkJSL();
-
- int loc = glGetUniformLocation(pid, name);
- glUniform4f(loc,
- col->rgba.r / 255.f,
- col->rgba.g / 255.f,
- col->rgba.b / 255.f,
- col->rgba.a / 255.f
- );
- }
+ void JSLProgram::sendColor(const char* name, const color* col)
+ {
+ checkJSL();
+
+ int loc = glGetUniformLocation(pid, name);
+ glUniform4f(loc,
+ col->rgba.r / 255.f,
+ col->rgba.g / 255.f,
+ col->rgba.b / 255.f,
+ col->rgba.a / 255.f
+ );
+ }
}
}