aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libjin/audio/source.cpp2
-rw-r--r--src/libjin/audio/source.h19
-rw-r--r--src/libjin/render/jsl.cpp25
-rw-r--r--src/libjin/render/jsl.h19
-rw-r--r--src/main.cpp2
-rw-r--r--src/script/graphics/luaopen_graphics.cpp2
6 files changed, 40 insertions, 29 deletions
diff --git a/src/libjin/audio/source.cpp b/src/libjin/audio/source.cpp
new file mode 100644
index 0000000..cca4d3e
--- /dev/null
+++ b/src/libjin/audio/source.cpp
@@ -0,0 +1,2 @@
+#include "source.h"
+
diff --git a/src/libjin/audio/source.h b/src/libjin/audio/source.h
new file mode 100644
index 0000000..8b4b888
--- /dev/null
+++ b/src/libjin/audio/source.h
@@ -0,0 +1,19 @@
+#ifndef __JIN_AUDIO_SOURCE_H
+#define __JIN_AUDIO_SOURCE_H
+
+#include <SDL2/SDL.h>
+
+namespace jin
+{
+namespace audio
+{
+
+ class Source
+ {
+
+ };
+
+}
+}
+
+#endif \ No newline at end of file
diff --git a/src/libjin/render/jsl.cpp b/src/libjin/render/jsl.cpp
index 1fb4482..1935edc 100644
--- a/src/libjin/render/jsl.cpp
+++ b/src/libjin/render/jsl.cpp
@@ -11,12 +11,15 @@ namespace render
"#define Image sampler2D \n"
"#define Texel texture2D \n"
"#define extern uniform \n"
- "uniform sampler2D _tex0_; \n"
+ "uniform Image _tex0_; \n"
"%s \n"
"void main(){ \n"
"gl_FragColor = effect(gl_Color, _tex0_, gl_TexCoord[0].xy, gl_FragCoord.xy);\n"
"}\0";
+ shared GLint JSLProgram::_current_texture_unit;
+ shared GLint JSLProgram::_max_texture_units;
+
void JSLProgram::init(const char* program)
{
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &_max_texture_units);
@@ -32,27 +35,17 @@ namespace render
glLinkProgram(pid);
}
- shared std::map<std::string, GLint> JSLProgram::_texture_unit_pool;
- shared GLint JSLProgram::_current_texture_unit = 0;
- shared GLint JSLProgram::_max_texture_units = 0;
-
shared GLint JSLProgram::getTextureUnit(const std::string& name)
{
- std::map<std::string, GLint>::const_iterator it = _texture_unit_pool.find(name);
-
- if (it != _texture_unit_pool.end())
- return it->second;
-
- if (++_current_texture_unit >= _max_texture_units)
- return 0;
-
- _texture_unit_pool[name] = _current_texture_unit;
- return _current_texture_unit;
+ if (++_current_texture_unit >= _max_texture_units)
+ return 0;
+ return _current_texture_unit;
}
void JSLProgram::use()
{
glUseProgram(pid);
+ _current_texture_unit = 0;
}
shared void JSLProgram::unuse()
@@ -71,10 +64,10 @@ namespace render
GLint texture_unit = getTextureUnit(variable);
GLint location = glGetUniformLocation(pid, variable);
+ glUniform1i(location, texture_unit);
glActiveTexture(GL_TEXTURE0 + texture_unit);
glBindTexture(GL_TEXTURE_2D, image->getTexture()); // guarantee it gets bound
- glUniform1i(location, texture_unit);
// reset texture unit
glActiveTexture(GL_TEXTURE0);
diff --git a/src/libjin/render/jsl.h b/src/libjin/render/jsl.h
index 570235b..4e0a6f0 100644
--- a/src/libjin/render/jsl.h
+++ b/src/libjin/render/jsl.h
@@ -1,17 +1,16 @@
#ifndef __JIN_JSL_H
#define __JIN_JSL_H
+
#include <string>
#include <map>
#include "image.h"
#include "3rdparty/GLee/GLee.h"
+
namespace jin
{
namespace render
{
- /**
- * A JSL program for shadering textures which is
- * actually a glsl program.
- */
+
class JSLProgram
{
public:
@@ -24,20 +23,18 @@ namespace render
void sendFloat(const char* name, float number);
void sendImage(const char* name, const Image* image);
- //void sendMatrix(const char* name, int size, const GLfloat* m, int count);
- //void sendCanvas(const char* name, const Canvas& canvas);
-
+
private:
+
JSLProgram();
- // only id for identify glsl program
GLuint pid;
static GLint _current_texture_unit;
- static GLint _max_texture_units;
- static std::map<std::string, GLint> _texture_unit_pool;
- static GLint getTextureUnit(const std::string& name);
+ static GLint _max_texture_units;
+ static GLint getTextureUnit(const std::string& name);
};
+
}
}
diff --git a/src/main.cpp b/src/main.cpp
index 411ee93..e54d2c2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -8,7 +8,7 @@
#include "3rdparty/luax/luax.h"
#include "script/luaopen_jin.h"
-#include "libjin/fs/filesystem.h"
+#include "libjin/jin.h"
#include <Windows.h>
diff --git a/src/script/graphics/luaopen_graphics.cpp b/src/script/graphics/luaopen_graphics.cpp
index 4f61023..80acc94 100644
--- a/src/script/graphics/luaopen_graphics.cpp
+++ b/src/script/graphics/luaopen_graphics.cpp
@@ -51,7 +51,7 @@ namespace lua
Window* wnd = Window::get();
wnd->init(w, h, t);
- // set default blend method
+ // set default blend method
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);