diff options
-rw-r--r-- | bin/jin.exe | bin | 726528 -> 1449472 bytes | |||
-rw-r--r-- | bin/main.lua | 8 | ||||
-rw-r--r-- | build/vs2015/jin.vcxproj | 2 | ||||
-rw-r--r-- | build/vs2015/jin.vcxproj.filters | 6 | ||||
-rw-r--r-- | src/libjin/render/jsl.cpp | 9 | ||||
-rw-r--r-- | src/libjin/render/jsl.h | 12 | ||||
-rw-r--r-- | src/script/audio/luaopen_Source.cpp (renamed from src/script/audio/luaopen_Sound.cpp) | 2 | ||||
-rw-r--r-- | src/script/graphics/luaopen_Canvas.cpp | 6 | ||||
-rw-r--r-- | src/script/graphics/luaopen_Image.cpp | 6 | ||||
-rw-r--r-- | src/script/graphics/luaopen_JSL.cpp | 8 | ||||
-rw-r--r-- | src/script/luaopen_types.h | 6 |
11 files changed, 33 insertions, 32 deletions
diff --git a/bin/jin.exe b/bin/jin.exe Binary files differindex 2072672..71918db 100644 --- a/bin/jin.exe +++ b/bin/jin.exe diff --git a/bin/main.lua b/bin/main.lua index f814079..ca3108c 100644 --- a/bin/main.lua +++ b/bin/main.lua @@ -1,12 +1,11 @@ local shader = [[ extern Image diffuse; -extern number mx; -extern number my; +extern vec2 mouse; extern number i ; vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords) { - vec3 light_vec = vec3(mx ,my,1); + vec3 light_vec = vec3(mouse,1); vec3 light_direction = light_vec - vec3(pixel_coords, 0); float distance = length(light_direction); light_direction = normalize(light_direction) * abs(sin(i)); @@ -72,8 +71,7 @@ jin.core.onDraw = function() i = i + 0.1 jg.bind(cvs) jg.use(effect) - effect:send("number", "mx", mx) - effect:send("number", "my", my) + effect:send("vec2", "mouse", mx, my) effect:send("number", "i", i) effect:send("Image", "diffuse", diffuse) jg.draw(img, ww / 2, wh / 2, 2, 2) diff --git a/build/vs2015/jin.vcxproj b/build/vs2015/jin.vcxproj index 2e1809d..8b8f099 100644 --- a/build/vs2015/jin.vcxproj +++ b/build/vs2015/jin.vcxproj @@ -178,7 +178,7 @@ <ClCompile Include="..\..\src\3rdparty\stb\stb_vorbis.c" /> <ClCompile Include="..\..\src\3rdparty\tekcos\tekcos.c" /> <ClCompile Include="..\..\src\script\audio\luaopen_audio.cpp" /> - <ClCompile Include="..\..\src\script\audio\luaopen_Sound.cpp" /> + <ClCompile Include="..\..\src\script\audio\luaopen_Source.cpp" /> <ClCompile Include="..\..\src\script\core\luaopen_core.cpp" /> <ClCompile Include="..\..\src\script\debug\luaopen_debug.cpp" /> <ClCompile Include="..\..\src\script\event\luaopen_event.cpp" /> diff --git a/build/vs2015/jin.vcxproj.filters b/build/vs2015/jin.vcxproj.filters index 2e42fcf..f65792d 100644 --- a/build/vs2015/jin.vcxproj.filters +++ b/build/vs2015/jin.vcxproj.filters @@ -255,9 +255,6 @@ <ClCompile Include="..\..\src\script\audio\luaopen_audio.cpp"> <Filter>src\script\audio</Filter> </ClCompile> - <ClCompile Include="..\..\src\script\audio\luaopen_Sound.cpp"> - <Filter>src\script\audio</Filter> - </ClCompile> <ClCompile Include="..\..\src\script\core\luaopen_core.cpp"> <Filter>src\script\core</Filter> </ClCompile> @@ -312,6 +309,9 @@ <ClCompile Include="..\..\src\script\joypad\luaopen_joypad.cpp"> <Filter>src\script\joypad</Filter> </ClCompile> + <ClCompile Include="..\..\src\script\audio\luaopen_Source.cpp"> + <Filter>src\script\audio</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\..\src\3rdparty\GLEE\GLee.h"> diff --git a/src/libjin/render/jsl.cpp b/src/libjin/render/jsl.cpp index 49bb18f..58b9a15 100644 --- a/src/libjin/render/jsl.cpp +++ b/src/libjin/render/jsl.cpp @@ -9,10 +9,11 @@ namespace render "#version 120 \n" "#define number float \n" "#define Image sampler2D \n" - "#define Texel texture2D \n" + "#define Canvas sampler2D \n" "#define Color vec4 \n" + "#define Texel texture2D \n" "#define extern uniform \n" - "uniform Image _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" @@ -33,13 +34,13 @@ namespace render destroy(); } - void JSLProgram::destroy() + inline void JSLProgram::destroy() { if (currentJSLProgram == this) unuse(); } - void JSLProgram::initialize(const char* program) + inline void JSLProgram::initialize(const char* program) { if (maxTextureUnits == -1) glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits); diff --git a/src/libjin/render/jsl.h b/src/libjin/render/jsl.h index 7183325..aff7fea 100644 --- a/src/libjin/render/jsl.h +++ b/src/libjin/render/jsl.h @@ -23,15 +23,15 @@ namespace render inline void JSLProgram::use() { glUseProgram(pid); - JSLProgram::currentJSLProgram = this; - JSLProgram::currentTextureUnit = 0; + currentJSLProgram = this; + currentTextureUnit = 0; } static inline void JSLProgram::unuse() { glUseProgram(0); - JSLProgram::currentJSLProgram = nullptr; - JSLProgram::currentTextureUnit = 0; + currentJSLProgram = nullptr; + currentTextureUnit = 0; } void sendFloat(const char* name, float number); @@ -59,8 +59,8 @@ namespace render GLint getTextureUnit(const std::string& name); - void initialize(const char* program); - void destroy(); + inline void initialize(const char* program); + inline void destroy(); }; diff --git a/src/script/audio/luaopen_Sound.cpp b/src/script/audio/luaopen_Source.cpp index d43147e..2ab5d16 100644 --- a/src/script/audio/luaopen_Sound.cpp +++ b/src/script/audio/luaopen_Source.cpp @@ -16,7 +16,7 @@ namespace lua {0, 0} }; - int luaopen_Sound(lua_State* L) + int luaopen_Source(lua_State* L) { return 1; diff --git a/src/script/graphics/luaopen_Canvas.cpp b/src/script/graphics/luaopen_Canvas.cpp index a34e3b3..1e22772 100644 --- a/src/script/graphics/luaopen_Canvas.cpp +++ b/src/script/graphics/luaopen_Canvas.cpp @@ -50,9 +50,9 @@ namespace lua static int l_gc(lua_State* L) { - Canvas* canvas = checkCanvas(L); - if (canvas != nullptr) - delete canvas; + Proxy* proxy = (Proxy*)luax_checktype(L, 1, TYPE_CANVAS); + Canvas* canvas = (Canvas*)proxy->object; + delete canvas; return 0; } diff --git a/src/script/graphics/luaopen_Image.cpp b/src/script/graphics/luaopen_Image.cpp index 9506ce4..246ea09 100644 --- a/src/script/graphics/luaopen_Image.cpp +++ b/src/script/graphics/luaopen_Image.cpp @@ -63,9 +63,9 @@ namespace lua static int l_gc(lua_State* L) { - Image* i = checkImage(L); - if (i != nullptr) - delete i; + Proxy* proxy = (Proxy*)luax_checktype(L, 1, TYPE_IMAGE); + Image* img = (Image*)proxy->object; + delete img; return 0; } diff --git a/src/script/graphics/luaopen_JSL.cpp b/src/script/graphics/luaopen_JSL.cpp index 33afa2c..919949c 100644 --- a/src/script/graphics/luaopen_JSL.cpp +++ b/src/script/graphics/luaopen_JSL.cpp @@ -121,11 +121,9 @@ namespace lua static int l_gc(lua_State* L) { - JSLProgram* jsl = checkJSLProgram(L); - if (jsl != nullptr && jsl != NULL) - { - delete jsl; - } + Proxy* proxy = (Proxy*)luax_checktype(L, 1, TYPE_JSL); + JSLProgram* jsl = (JSLProgram*)proxy->object; + delete jsl; return 0; } diff --git a/src/script/luaopen_types.h b/src/script/luaopen_types.h index 8c1f2a6..c6ce202 100644 --- a/src/script/luaopen_types.h +++ b/src/script/luaopen_types.h @@ -8,7 +8,7 @@ #define TYPE_FONT "Font" // audio module -#define TYPE_SOUND "Sound" +#define TYPE_SOURCE "Source" class Proxy { @@ -20,6 +20,10 @@ public: } void* object; + + ~Proxy() + { + } }; #endif |