aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--bin/ParticleSystem.exebin0 -> 1161216 bytes
-rw-r--r--bin/SDL2.dllbin1279488 -> 1279488 bytes
-rw-r--r--bin/game/main.lua6
-rw-r--r--bin/jin.exebin2565632 -> 0 bytes
-rw-r--r--build/vc++/3rdparty/GLee/GLee.vcxproj4
-rw-r--r--build/vc++/3rdparty/SDL2/SDL2.vcxproj4
-rw-r--r--build/vc++/3rdparty/SDL2main/SDL2main.vcxproj4
-rw-r--r--build/vc++/3rdparty/buildvm/buildvm.vcxproj4
-rw-r--r--build/vc++/3rdparty/luajit/luajit.vcxproj4
-rw-r--r--build/vc++/3rdparty/minilua/minilua.vcxproj4
-rw-r--r--build/vc++/3rdparty/smount/smount.vcxproj4
-rw-r--r--build/vc++/3rdparty/stb/stb.vcxproj4
-rw-r--r--build/vc++/3rdparty/tekcos/tekcos.vcxproj4
-rw-r--r--build/vc++/3rdparty/wav/wav.vcxproj4
-rw-r--r--build/vc++/examples/Animation/Animation.vcxproj4
-rw-r--r--build/vc++/examples/ParticleSystem/ParticleSystem.vcxproj4
-rw-r--r--build/vc++/examples/StateMachine/StateMachine.vcxproj4
-rw-r--r--build/vc++/jin.vcxproj4
-rw-r--r--build/vc++/jin/jin.vcxproj4
-rw-r--r--build/vc++/libjin/libjin.vcxproj11
-rw-r--r--build/vc++/libjin/libjin.vcxproj.filters21
-rw-r--r--examples/particle_system/main.cpp49
-rw-r--r--src/3rdparty/buildvm/buildvm.exebin123392 -> 0 bytes
-rw-r--r--src/3rdparty/minilua/minilua.exebin219136 -> 0 bytes
-rw-r--r--src/3rdparty/ogl/OpenGL.h184
-rw-r--r--src/libjin/ai/je_behavior_tree.h4
-rw-r--r--src/libjin/audio/SDL/je_sdl_source.h4
-rw-r--r--src/libjin/audio/je_source.h4
-rw-r--r--src/libjin/common/je_exception.h5
-rw-r--r--src/libjin/common/je_noncopyable.h4
-rw-r--r--src/libjin/common/je_object.h4
-rw-r--r--src/libjin/common/je_pool.hpp4
-rw-r--r--src/libjin/common/je_singleton.hpp4
-rw-r--r--src/libjin/common/je_stringmap.hpp4
-rw-r--r--src/libjin/common/je_temporary.h4
-rw-r--r--src/libjin/common/je_utf8.h2
-rw-r--r--src/libjin/filesystem/je_asset_database.h2
-rw-r--r--src/libjin/game/je_entity.cpp0
-rw-r--r--src/libjin/game/je_entity.h27
-rw-r--r--src/libjin/game/je_gameobject.cpp2
-rw-r--r--src/libjin/game/je_gameobject.h48
-rw-r--r--src/libjin/game/je_scene.cpp0
-rw-r--r--src/libjin/game/je_scene.h73
-rw-r--r--src/libjin/graphics/animations/je_animation.h4
-rw-r--r--src/libjin/graphics/animations/je_animator.h3
-rw-r--r--src/libjin/graphics/fonts/je_decoder.h4
-rw-r--r--src/libjin/graphics/fonts/je_font.h2
-rw-r--r--src/libjin/graphics/fonts/je_text.h4
-rw-r--r--src/libjin/graphics/fonts/je_ttf.h4
-rw-r--r--src/libjin/graphics/je_bitmap.h2
-rw-r--r--src/libjin/graphics/je_gl.cpp110
-rw-r--r--src/libjin/graphics/je_gl.h127
-rw-r--r--src/libjin/graphics/je_graphic.h3
-rw-r--r--src/libjin/graphics/je_image.h3
-rw-r--r--src/libjin/graphics/je_mesh.h1
-rw-r--r--src/libjin/graphics/je_sprite.h2
-rw-r--r--src/libjin/graphics/je_sprite_batch.h4
-rw-r--r--src/libjin/graphics/je_window.cpp9
-rw-r--r--src/libjin/math/je_percentage.h36
-rw-r--r--src/libjin/math/je_ranged_value.cpp71
-rw-r--r--src/libjin/math/je_ranged_value.h57
-rw-r--r--src/libjin/math/je_transform.h2
-rw-r--r--src/libjin/math/je_vector2.hpp5
-rw-r--r--src/lua/common/je_lua.h2
-rw-r--r--src/lua/common/je_lua_reference.cpp2
-rw-r--r--src/lua/common/je_lua_shared.cpp4
-rw-r--r--src/lua/common/je_lua_shared.hpp11
-rw-r--r--src/lua/embed/embed.h6
-rw-r--r--src/lua/modules/graphics/je_lua_graphics.cpp120
-rw-r--r--src/lua/modules/graphics/je_lua_particle_system.cpp2
71 files changed, 647 insertions, 481 deletions
diff --git a/.gitignore b/.gitignore
index d5f3de6..f943d9f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,5 @@
*.db-wal
*.iobj
*.ipdb
+*.sbr
+*.bsc
diff --git a/bin/ParticleSystem.exe b/bin/ParticleSystem.exe
new file mode 100644
index 0000000..ec0a224
--- /dev/null
+++ b/bin/ParticleSystem.exe
Binary files differ
diff --git a/bin/SDL2.dll b/bin/SDL2.dll
index e663582..8e26c27 100644
--- a/bin/SDL2.dll
+++ b/bin/SDL2.dll
Binary files differ
diff --git a/bin/game/main.lua b/bin/game/main.lua
index b233272..97079f2 100644
--- a/bin/game/main.lua
+++ b/bin/game/main.lua
@@ -38,7 +38,7 @@ local shader2 = [[
Color c = texel(tex, v.uv);
return c;
}
-
+
#END_FRAGMENT_SHADER
]]
music = nil
@@ -100,8 +100,8 @@ end
function jin.core.onUpdate()
tb.x = t
t = t + jin.time.getDelta()
- animator:update(jin.time.getDelta())
- timer:update(jin.time.getDelta())
+ animator:update(jin.time.getDelta())
+ timer:update(jin.time.getDelta())
end
function jin.core.onDraw()
diff --git a/bin/jin.exe b/bin/jin.exe
deleted file mode 100644
index 85d76d7..0000000
--- a/bin/jin.exe
+++ /dev/null
Binary files differ
diff --git a/build/vc++/3rdparty/GLee/GLee.vcxproj b/build/vc++/3rdparty/GLee/GLee.vcxproj
index 7efcdd2..fdc6f0a 100644
--- a/build/vc++/3rdparty/GLee/GLee.vcxproj
+++ b/build/vc++/3rdparty/GLee/GLee.vcxproj
@@ -84,7 +84,11 @@
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAs>CompileAsCpp</CompileAs>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/3rdparty/SDL2/SDL2.vcxproj b/build/vc++/3rdparty/SDL2/SDL2.vcxproj
index cbd29bd..91570e3 100644
--- a/build/vc++/3rdparty/SDL2/SDL2.vcxproj
+++ b/build/vc++/3rdparty/SDL2/SDL2.vcxproj
@@ -89,6 +89,7 @@
<OmitDefaultLibName>true</OmitDefaultLibName>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<BufferSecurityCheck>false</BufferSecurityCheck>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
<Link>
<AdditionalDependencies>winmm.lib;imm32.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -98,6 +99,9 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<LinkTimeCodeGeneration>UseFastLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/3rdparty/SDL2main/SDL2main.vcxproj b/build/vc++/3rdparty/SDL2main/SDL2main.vcxproj
index 14d4711..0367473 100644
--- a/build/vc++/3rdparty/SDL2main/SDL2main.vcxproj
+++ b/build/vc++/3rdparty/SDL2main/SDL2main.vcxproj
@@ -101,7 +101,11 @@
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src\3rdparty\SDL2\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<OmitDefaultLibName>true</OmitDefaultLibName>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/3rdparty/buildvm/buildvm.vcxproj b/build/vc++/3rdparty/buildvm/buildvm.vcxproj
index faf0e65..bf55f5e 100644
--- a/build/vc++/3rdparty/buildvm/buildvm.vcxproj
+++ b/build/vc++/3rdparty/buildvm/buildvm.vcxproj
@@ -83,10 +83,14 @@
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src\3rdparty\LuaJIT-2.0.5\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
<PostBuildEvent>
<Command>buildvm-post.bat $(SolutionDir)..\..\src\3rdparty\buildvm\$(TargetName) $(SolutionDir)..\..\src\3rdparty\LuaJIT-2.0.5\src</Command>
</PostBuildEvent>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/3rdparty/luajit/luajit.vcxproj b/build/vc++/3rdparty/luajit/luajit.vcxproj
index 2950a92..70b5c91 100644
--- a/build/vc++/3rdparty/luajit/luajit.vcxproj
+++ b/build/vc++/3rdparty/luajit/luajit.vcxproj
@@ -90,6 +90,7 @@
<SDLCheck>true</SDLCheck>
<ConformanceMode>false</ConformanceMode>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;D_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
<Lib>
<AdditionalDependencies>lj_vm.obj</AdditionalDependencies>
@@ -102,6 +103,9 @@
<AdditionalDependencies>lj_vm.obj;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>luajit.def</ModuleDefinitionFile>
</Link>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/3rdparty/minilua/minilua.vcxproj b/build/vc++/3rdparty/minilua/minilua.vcxproj
index e663cb1..9e2aff2 100644
--- a/build/vc++/3rdparty/minilua/minilua.vcxproj
+++ b/build/vc++/3rdparty/minilua/minilua.vcxproj
@@ -82,10 +82,14 @@
<SDLCheck>true</SDLCheck>
<ConformanceMode>false</ConformanceMode>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
<PostBuildEvent>
<Command>minilua-post.bat $(SolutionDir)..\..\src\3rdparty\minilua\$(TargetName) $(SolutionDir)..\..\src\3rdparty\LuaJIT-2.0.5\src</Command>
</PostBuildEvent>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/3rdparty/smount/smount.vcxproj b/build/vc++/3rdparty/smount/smount.vcxproj
index 6b710f4..63eab3a 100644
--- a/build/vc++/3rdparty/smount/smount.vcxproj
+++ b/build/vc++/3rdparty/smount/smount.vcxproj
@@ -84,7 +84,11 @@
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAs>CompileAsCpp</CompileAs>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/3rdparty/stb/stb.vcxproj b/build/vc++/3rdparty/stb/stb.vcxproj
index e6abf2a..e48ddc9 100644
--- a/build/vc++/3rdparty/stb/stb.vcxproj
+++ b/build/vc++/3rdparty/stb/stb.vcxproj
@@ -84,7 +84,11 @@
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAs>CompileAsCpp</CompileAs>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/3rdparty/tekcos/tekcos.vcxproj b/build/vc++/3rdparty/tekcos/tekcos.vcxproj
index e8a5bd7..ec2a716 100644
--- a/build/vc++/3rdparty/tekcos/tekcos.vcxproj
+++ b/build/vc++/3rdparty/tekcos/tekcos.vcxproj
@@ -84,7 +84,11 @@
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAs>CompileAsCpp</CompileAs>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/3rdparty/wav/wav.vcxproj b/build/vc++/3rdparty/wav/wav.vcxproj
index ff62736..0ae6d75 100644
--- a/build/vc++/3rdparty/wav/wav.vcxproj
+++ b/build/vc++/3rdparty/wav/wav.vcxproj
@@ -84,7 +84,11 @@
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<CompileAs>CompileAsCpp</CompileAs>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/examples/Animation/Animation.vcxproj b/build/vc++/examples/Animation/Animation.vcxproj
index f53dff8..83e5dd3 100644
--- a/build/vc++/examples/Animation/Animation.vcxproj
+++ b/build/vc++/examples/Animation/Animation.vcxproj
@@ -79,12 +79,16 @@
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src\;$(SolutionDir)..\..\src\3rdparty\SDL2\include;$(SolutionDir)..\..\src\3rdparty\LuaJIT-2.0.5\include;$(SolutionDir)..\..\src\3rdparty\</AdditionalIncludeDirectories>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(SolutionDir)libs\SDL2-2.0.5\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
</Link>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/examples/ParticleSystem/ParticleSystem.vcxproj b/build/vc++/examples/ParticleSystem/ParticleSystem.vcxproj
index ab310c9..faadeec 100644
--- a/build/vc++/examples/ParticleSystem/ParticleSystem.vcxproj
+++ b/build/vc++/examples/ParticleSystem/ParticleSystem.vcxproj
@@ -100,12 +100,16 @@
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src\;$(SolutionDir)..\..\src\3rdparty\SDL2\include;$(SolutionDir)..\..\src\3rdparty\LuaJIT-2.0.5\include;$(SolutionDir)..\..\src\3rdparty\</AdditionalIncludeDirectories>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>$(SolutionDir)libs\SDL2-2.0.5\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/examples/StateMachine/StateMachine.vcxproj b/build/vc++/examples/StateMachine/StateMachine.vcxproj
index 90821de..55a0815 100644
--- a/build/vc++/examples/StateMachine/StateMachine.vcxproj
+++ b/build/vc++/examples/StateMachine/StateMachine.vcxproj
@@ -82,11 +82,15 @@
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src\;$(SolutionDir)..\..\src\3rdparty\SDL2\include;$(SolutionDir)..\..\src\3rdparty\LuaJIT-2.0.5\include;$(SolutionDir)..\..\src\3rdparty\</AdditionalIncludeDirectories>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalDependencies>opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/jin.vcxproj b/build/vc++/jin.vcxproj
index 556de9a..3394bf6 100644
--- a/build/vc++/jin.vcxproj
+++ b/build/vc++/jin.vcxproj
@@ -90,6 +90,7 @@
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<IntrinsicFunctions>true</IntrinsicFunctions>
<Optimization>Disabled</Optimization>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
<Link>
<AdditionalDependencies>opengl32.lib;lua51.lib;SDL2main.lib;SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -98,6 +99,9 @@
<EntryPointSymbol>
</EntryPointSymbol>
</Link>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/jin/jin.vcxproj b/build/vc++/jin/jin.vcxproj
index ac3cec8..20cad7c 100644
--- a/build/vc++/jin/jin.vcxproj
+++ b/build/vc++/jin/jin.vcxproj
@@ -104,6 +104,7 @@
<SDLCheck>true</SDLCheck>
<ConformanceMode>false</ConformanceMode>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src\;$(SolutionDir)..\..\src\3rdparty\SDL2\include;$(SolutionDir)..\..\src\3rdparty\LuaJIT-2.0.5\include;$(SolutionDir)..\..\src\3rdparty\</AdditionalIncludeDirectories>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -111,6 +112,9 @@
</AdditionalLibraryDirectories>
<AdditionalDependencies>opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
diff --git a/build/vc++/libjin/libjin.vcxproj b/build/vc++/libjin/libjin.vcxproj
index 533de49..c59405e 100644
--- a/build/vc++/libjin/libjin.vcxproj
+++ b/build/vc++/libjin/libjin.vcxproj
@@ -106,7 +106,11 @@
<CompileAs>CompileAsCpp</CompileAs>
<ObjectFileName>$(IntDir)/%(RelativeDir)/</ObjectFileName>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
+ <BrowseInformation>true</BrowseInformation>
</ClCompile>
+ <Bscmake>
+ <PreserveSbr>true</PreserveSbr>
+ </Bscmake>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
@@ -154,10 +158,8 @@
<ClInclude Include="..\..\..\src\libjin\core\je_version.h" />
<ClInclude Include="..\..\..\src\libjin\Filesystem\je_buffer.h" />
<ClInclude Include="..\..\..\src\libjin\Filesystem\je_asset_database.h" />
- <ClInclude Include="..\..\..\src\libjin\Game\je_entity.h" />
<ClInclude Include="..\..\..\src\libjin\Game\je_application.h" />
<ClInclude Include="..\..\..\src\libjin\Game\je_gameobject.h" />
- <ClInclude Include="..\..\..\src\libjin\game\je_scene.h" />
<ClInclude Include="..\..\..\src\libjin\graphics\animations\je_animation.h" />
<ClInclude Include="..\..\..\src\libjin\graphics\animations\je_animator.h" />
<ClInclude Include="..\..\..\src\libjin\graphics\fonts\je_decoder.h" />
@@ -202,8 +204,10 @@
<ClInclude Include="..\..\..\src\libjin\math\je_ellipse.h" />
<ClInclude Include="..\..\..\src\libjin\Math\je_math.h" />
<ClInclude Include="..\..\..\src\libjin\Math\je_matrix.h" />
+ <ClInclude Include="..\..\..\src\libjin\math\je_percentage.h" />
<ClInclude Include="..\..\..\src\libjin\Math\je_quad.h" />
<ClInclude Include="..\..\..\src\libjin\math\je_random.h" />
+ <ClInclude Include="..\..\..\src\libjin\math\je_ranged_value.h" />
<ClInclude Include="..\..\..\src\libjin\Math\je_transform.h" />
<ClInclude Include="..\..\..\src\libjin\Math\je_vector2.hpp" />
<ClInclude Include="..\..\..\src\libjin\Math\je_vector3.hpp" />
@@ -232,10 +236,8 @@
<ClCompile Include="..\..\..\src\libjin\Common\je_exception.cpp" />
<ClCompile Include="..\..\..\src\libjin\Common\je_utf8.cpp" />
<ClCompile Include="..\..\..\src\libjin\Filesystem\je_asset_database.cpp" />
- <ClCompile Include="..\..\..\src\libjin\Game\je_entity.cpp" />
<ClCompile Include="..\..\..\src\libjin\Game\je_gameobject.cpp" />
<ClCompile Include="..\..\..\src\libjin\Game\je_application.cpp" />
- <ClCompile Include="..\..\..\src\libjin\Game\je_scene.cpp" />
<ClCompile Include="..\..\..\src\libjin\graphics\animations\je_animation.cpp" />
<ClCompile Include="..\..\..\src\libjin\graphics\animations\je_animator.cpp" />
<ClCompile Include="..\..\..\src\libjin\graphics\fonts\je_decoder.cpp" />
@@ -268,6 +270,7 @@
<ClCompile Include="..\..\..\src\libjin\math\je_ellipse.cpp" />
<ClCompile Include="..\..\..\src\libjin\Math\je_matrix.cpp" />
<ClCompile Include="..\..\..\src\libjin\math\je_random.cpp" />
+ <ClCompile Include="..\..\..\src\libjin\math\je_ranged_value.cpp" />
<ClCompile Include="..\..\..\src\libjin\Math\je_transform.cpp" />
<ClCompile Include="..\..\..\src\libjin\Net\je_net_manager.cpp" />
<ClCompile Include="..\..\..\src\libjin\Net\je_socket.cpp" />
diff --git a/build/vc++/libjin/libjin.vcxproj.filters b/build/vc++/libjin/libjin.vcxproj.filters
index 9b9227d..c50f0be 100644
--- a/build/vc++/libjin/libjin.vcxproj.filters
+++ b/build/vc++/libjin/libjin.vcxproj.filters
@@ -207,9 +207,6 @@
<ClInclude Include="..\..\..\src\libjin\core\je_version.h">
<Filter>source\core</Filter>
</ClInclude>
- <ClInclude Include="..\..\..\src\libjin\game\je_scene.h">
- <Filter>source\game</Filter>
- </ClInclude>
<ClInclude Include="..\..\..\src\libjin\ai\je_behavior_tree.h">
<Filter>source\ai</Filter>
</ClInclude>
@@ -231,9 +228,6 @@
<ClInclude Include="..\..\..\src\libjin\Graphics\je_graphic.h">
<Filter>source\graphics</Filter>
</ClInclude>
- <ClInclude Include="..\..\..\src\libjin\Game\je_entity.h">
- <Filter>source\game</Filter>
- </ClInclude>
<ClInclude Include="..\..\..\src\libjin\Game\je_application.h">
<Filter>source\game</Filter>
</ClInclude>
@@ -318,6 +312,12 @@
<ClInclude Include="..\..\..\src\libjin\graphics\je_renderable.h">
<Filter>source\graphics</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\src\libjin\math\je_percentage.h">
+ <Filter>source\math</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\..\src\libjin\math\je_ranged_value.h">
+ <Filter>source\math</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\src\libjin\README.md">
@@ -418,15 +418,9 @@
<ClCompile Include="..\..\..\src\libjin\ai\je_state_machine.cpp">
<Filter>source\ai</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\src\libjin\Game\je_scene.cpp">
- <Filter>source\game</Filter>
- </ClCompile>
<ClCompile Include="..\..\..\src\libjin\Graphics\je_graphic.cpp">
<Filter>source\graphics</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\src\libjin\Game\je_entity.cpp">
- <Filter>source\game</Filter>
- </ClCompile>
<ClCompile Include="..\..\..\src\libjin\Game\je_application.cpp">
<Filter>source\game</Filter>
</ClCompile>
@@ -487,5 +481,8 @@
<ClCompile Include="..\..\..\src\libjin\graphics\animations\je_animator.cpp">
<Filter>source\graphics\animations</Filter>
</ClCompile>
+ <ClCompile Include="..\..\..\src\libjin\math\je_ranged_value.cpp">
+ <Filter>source\math</Filter>
+ </ClCompile>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/examples/particle_system/main.cpp b/examples/particle_system/main.cpp
index b337722..3fd96ce 100644
--- a/examples/particle_system/main.cpp
+++ b/examples/particle_system/main.cpp
@@ -38,39 +38,48 @@ const float Pi = 3.14f;
void onLoad()
{
tex = Texture::createTexture("particle.png");
- spr = new Sprite(tex, Origin::BottomCenter);
+ spr = new Sprite(tex, Origin::MiddleCenter);
shader = Shader::createShader(shader_code);
ParticleSystemDef def;
def.maxParticleCount = 30;
def.emitterDef.emitRateDef.rate.rate = 0.01f;
- def.emitterDef.forceDef.force.force = 50.f;
+
+ def.emitterDef.forceDef.enableRandom = true;
+ def.emitterDef.forceDef.force.random.floor = 80;
+ def.emitterDef.forceDef.force.random.ceil = 150;
+
def.emitterDef.positionDef.enableRandom = true;
- def.emitterDef.positionDef.position.random.floor = Vector2<float>(0, 0);
- def.emitterDef.positionDef.position.random.ceil = Vector2<float>(0, 0);
+ def.emitterDef.positionDef.position.random.floor = Vector2<float>(-2, 0);
+ def.emitterDef.positionDef.position.random.ceil = Vector2<float>(2, 0);
def.emitterDef.directionDef.enableRandom = true;
- def.emitterDef.directionDef.direction.random.floor = -Pi / 2 ;
- def.emitterDef.directionDef.direction.random.ceil = -Pi / 2 ;
-
- def.particleDef.colorOverTimeDef.enable = true;
- def.particleDef.colorOverTimeDef.colorStart = Color(255, 255, 0, 255);
- def.particleDef.colorOverTimeDef.colorEnd = Color(255, 0, 0, 0);
-/*
- def.particleDef.angularSpeedDef.enableRandom = true;
- def.particleDef.angularSpeedDef.angularSpeed.random.floor = -1;
- def.particleDef.angularSpeedDef.angularSpeed.random.ceil = 1;
-*/
+ def.emitterDef.directionDef.direction.random.floor = -Pi / 8 - Pi / 2 ;
+ def.emitterDef.directionDef.direction.random.ceil = Pi / 8 - Pi / 2 ;
def.particleDef.linearAccelarationDef.linearAccelaration = Vector2<float>(0, 10);
- def.particleDef.sizeOverTimeDef.enable = true;
- def.particleDef.sizeOverTimeDef.start = 1;
- def.particleDef.sizeOverTimeDef.end = 1;
+ def.particleDef.spritesDef.sprites.push_back(spr);
+
+ def.particleDef.colorDef.color = Color(255, 40, 40, 255);
+ def.particleDef.colorDef.overTime.enable = true;
+ def.particleDef.colorDef.overTime.value.addColor(Color(255, 100, 0, 255), 0);
+ //def.particleDef.colorDef.overTime.value.addColor(Color(255, 255, 0, 100), 0.3);
+ //def.particleDef.colorDef.overTime.value.addColor(Color(0, 255, 100, 100), 0.5);
+ def.particleDef.colorDef.overTime.value.addColor(Color(255, 0, 0, 0), 1);
+
+ def.particleDef.blendDef.additive = true;
+
+ def.particleDef.lifeTimeDef.enableRandom = true;
+ def.particleDef.lifeTimeDef.life.random.floor = 0.5;
+ def.particleDef.lifeTimeDef.life.random.ceil = 1.5;
+
+ def.particleDef.scaleDef.overTime.enable = true;
+ def.particleDef.scaleDef.overTime.value.addPoint(0, 1);
+ def.particleDef.scaleDef.overTime.value.addPoint(1, 0.7);
- def.particleDef.lifeTimeDef.life.life = 3;
p = new ParticleSystem(def);
- p->setSprite(spr);
+ //p->addSprite(spr);
}
void onEvent(Event* e)
diff --git a/src/3rdparty/buildvm/buildvm.exe b/src/3rdparty/buildvm/buildvm.exe
deleted file mode 100644
index 60809b0..0000000
--- a/src/3rdparty/buildvm/buildvm.exe
+++ /dev/null
Binary files differ
diff --git a/src/3rdparty/minilua/minilua.exe b/src/3rdparty/minilua/minilua.exe
deleted file mode 100644
index 50c80c1..0000000
--- a/src/3rdparty/minilua/minilua.exe
+++ /dev/null
Binary files differ
diff --git a/src/3rdparty/ogl/OpenGL.h b/src/3rdparty/ogl/OpenGL.h
deleted file mode 100644
index 3e416c7..0000000
--- a/src/3rdparty/ogl/OpenGL.h
+++ /dev/null
@@ -1,184 +0,0 @@
-#ifndef __OGL2D_H
-#define __OGL2D_H
-#include <vector>
-
-/* include gl.h before this file */
-namespace ogl2d
-{
- /* 2d wrap of opengl 3.0 */
- class OpenGL
- {
- public:
- OpenGL();
- ~OpenGL();
-
- inline void enable(GLenum cap)
- {
- glEnable(cap);
- }
-
- inline void disable(GLenum cap)
- {
- glDisable(cap);
- }
-
- inline void setBlendFunc(GLenum sfactor, GLenum dfactor)
- {
- glBlendFunc(sfactor, dfactor);
- }
-
- inline void setClearColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
- {
- glClearColor(r / 255.f, g / 255.f, b / 255.f, a / 255.f);
- }
-
- void pushColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a = 255);
- void popColor();
- void flushError();
- GLuint genTexture();
- void deleteTexture(GLuint texture);
- void bindTexture(GLuint texture = 0);
- inline GLuint curTexture()
- {
- return _texture;
- }
- void setTexParameter(GLenum pname, GLint param);
- void texImage(GLint internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels = NULL);
- void texSubImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
- void activeTexUnit(unsigned int unit = 0);
-
- inline void drawArrays(GLenum mode, GLint first, GLsizei count)
- {
- glDrawArrays(mode, first, count);
- }
-
- inline void drawBuffer(GLenum mode)
- {
-
- }
-
- inline void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
- {
-
- }
-
- inline void enableClientState(GLenum arr)
- {
- glEnableClientState(arr);
- }
-
- inline void disableClientState(GLenum arr)
- {
- glDisableClientState(arr);
- }
-
- inline GLuint genFrameBuffer()
- {
- GLuint fbo;
- glGenFramebuffers(1, &fbo);
- return fbo;
- }
-
- inline void bindFrameBuffer(GLuint fbo)
- {
- glBindFramebuffer(GL_FRAMEBUFFER, fbo);
- }
-
- // Ļһ
- inline void ortho(int w, float radio)
- {
- glOrtho(0, w, w*radio, 0, -1, 1);
- }
-
- inline void orthox(int w, int h)
- {
- glOrtho(0, w, h, 0, -1, 1);
- }
-
- protected:
- struct { GLubyte r, g, b, a; } _color; // current draw color
- struct { GLubyte r, g, b, a; } _precolor; // previous draw color
- GLuint _texture; // current binded texture
-
- };
-
- ///* OpenGL instance singleton */
- extern OpenGL gl;
-
-#if defined(OGL2D_IMPLEMENT)
-
- OpenGL gl;
-
- OpenGL::OpenGL()
- {
- memset(&_color, 0xff, sizeof(_color));
- memset(&_precolor, 0xff, sizeof(_precolor));
- }
-
- OpenGL::~OpenGL()
- {
- }
-
- void OpenGL::pushColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
- {
- memcpy(&_precolor, &_color, sizeof(_precolor));
- _color.r = r;
- _color.g = g;
- _color.b = b;
- _color.a = a;
- glColor4ub(r, g, b, a);
- }
-
- void OpenGL::popColor()
- {
- memcpy(&_color, &_precolor, sizeof(_precolor));
- glColor4ub(_color.r, _color.g, _color.b, _color.a);
- }
-
- void OpenGL::flushError()
- {
- while (glGetError() != GL_NO_ERROR);
- }
-
- GLuint OpenGL::genTexture()
- {
- GLuint t;
- glGenTextures(1, &t);
- return t;
- }
-
- void OpenGL::bindTexture(GLuint texture)
- {
- glBindTexture(GL_TEXTURE_2D, texture);
- }
-
- void OpenGL::deleteTexture(GLuint texture)
- {
- glDeleteTextures(1, &texture);
- }
-
- void OpenGL::setTexParameter(GLenum pname, GLint param)
- {
- glTexParameteri(GL_TEXTURE_2D, pname, param);
- }
-
- void OpenGL::texImage(GLint internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
- {
- glTexImage2D(GL_TEXTURE_2D, 0, internalformat, width, height, 0, format, type, pixels);
- }
-
- void OpenGL::texSubImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
- {
- glTexSubImage2D(GL_TEXTURE_2D, 0, xoffset, yoffset, width, height, format, type, pixels);
- }
-
- void OpenGL::activeTexUnit(unsigned int unit)
- {
- // glActiveTexture selects which texture unit subsequent texture state calls will affect.
- glActiveTexture(GL_TEXTURE0 + unit);
- }
-
-#endif // OGL2D_IMPLEMENT
-}
-
-#endif \ No newline at end of file
diff --git a/src/libjin/ai/je_behavior_tree.h b/src/libjin/ai/je_behavior_tree.h
index 173df80..982e89e 100644
--- a/src/libjin/ai/je_behavior_tree.h
+++ b/src/libjin/ai/je_behavior_tree.h
@@ -14,12 +14,12 @@ namespace JinEngine
///
///
///
- class BehaviorTree
+ class BehaviorTree : public Object
{
public:
BehaviorTree(void* userData) : mUserData(userData){}
- class Node
+ class Node : public Object
{
public:
enum Type
diff --git a/src/libjin/audio/SDL/je_sdl_source.h b/src/libjin/audio/SDL/je_sdl_source.h
index bbc8c7a..07333ae 100644
--- a/src/libjin/audio/SDL/je_sdl_source.h
+++ b/src/libjin/audio/SDL/je_sdl_source.h
@@ -189,7 +189,7 @@ namespace JinEngine
///
/// Source manager.
///
- class SDLSourceManager
+ class SDLSourceManager : public Object
{
public:
///
@@ -255,7 +255,7 @@ namespace JinEngine
};
- class SourceException : public std::exception
+ class SourceException : public Object, public std::exception
{
const char* what() const throw ()
{
diff --git a/src/libjin/audio/je_source.h b/src/libjin/audio/je_source.h
index f60daf9..9b7bff0 100644
--- a/src/libjin/audio/je_source.h
+++ b/src/libjin/audio/je_source.h
@@ -3,6 +3,8 @@
#include "../core/je_configuration.h"
#if defined(jin_audio)
+#include "../common/je_object.h"
+
#include "SDL2/SDL.h"
namespace JinEngine
@@ -23,7 +25,7 @@ namespace JinEngine
///
/// Audio source.
///
- class Source
+ class Source : public Object
{
public:
///
diff --git a/src/libjin/common/je_exception.h b/src/libjin/common/je_exception.h
index c319ebd..71caa5a 100644
--- a/src/libjin/common/je_exception.h
+++ b/src/libjin/common/je_exception.h
@@ -4,16 +4,17 @@
#include <exception>
#include <string>
+#include "je_object.h"
+
namespace JinEngine
{
///
/// Jin Exception.
///
- class Exception : public std::exception
+ class Exception : public Object, public std::exception
{
public:
-
///
/// Creates a new Exception according to printf-rules.
///
diff --git a/src/libjin/common/je_noncopyable.h b/src/libjin/common/je_noncopyable.h
index eff7121..dab74a4 100644
--- a/src/libjin/common/je_noncopyable.h
+++ b/src/libjin/common/je_noncopyable.h
@@ -1,13 +1,15 @@
#ifndef __JE_NONCOPYABLE_H__
#define __JE_NONCOPYABLE_H__
+#include "je_object.h"
+
namespace JinEngine
{
///
/// Class inherites this could not be copied.
///
- class Noncopyable
+ class Noncopyable : public Object
{
public:
Noncopyable(void) { }
diff --git a/src/libjin/common/je_object.h b/src/libjin/common/je_object.h
index fb8221f..677b474 100644
--- a/src/libjin/common/je_object.h
+++ b/src/libjin/common/je_object.h
@@ -5,10 +5,12 @@ namespace JinEngine
{
///
- /// Base class of all objects in Jin.
+ /// Base class of all classes in libjin.
///
class Object
{
+ public:
+ virtual ~Object() {};
};
} // namespace JinEngine
diff --git a/src/libjin/common/je_pool.hpp b/src/libjin/common/je_pool.hpp
index cb96c5b..0758b97 100644
--- a/src/libjin/common/je_pool.hpp
+++ b/src/libjin/common/je_pool.hpp
@@ -12,7 +12,7 @@
namespace JinEngine
{
- class DefaultMemoryAllocator
+ class DefaultMemoryAllocator : public Object
{
public:
static inline void *Allocate(size_t size)
@@ -26,7 +26,7 @@ namespace JinEngine
};
template<typename T, class TMemoryAllocator = DefaultMemoryAllocator>
- class Pool
+ class Pool : public Object
{
private:
struct _Node
diff --git a/src/libjin/common/je_singleton.hpp b/src/libjin/common/je_singleton.hpp
index 2f387df..ba13b80 100644
--- a/src/libjin/common/je_singleton.hpp
+++ b/src/libjin/common/je_singleton.hpp
@@ -1,6 +1,8 @@
#ifndef __JE_SINGLETON_H__
#define __JE_SINGLETON_H__
+#include "je_object.h"
+
namespace JinEngine
{
@@ -8,7 +10,7 @@ namespace JinEngine
/// Singleton base class.
///
template<class T>
- class Singleton
+ class Singleton : public Object
{
public:
///
diff --git a/src/libjin/common/je_stringmap.hpp b/src/libjin/common/je_stringmap.hpp
index 7a3bd80..b4cdccf 100644
--- a/src/libjin/common/je_stringmap.hpp
+++ b/src/libjin/common/je_stringmap.hpp
@@ -1,11 +1,13 @@
#ifndef __JE_COMMON_SREINGMAP_H__
#define __JE_COMMON_SREINGMAP_H__
+#include "je_object.h"
+
namespace JinEngine
{
template<typename T, unsigned SIZE>
- class StringMap
+ class StringMap : public Object
{
private:
diff --git a/src/libjin/common/je_temporary.h b/src/libjin/common/je_temporary.h
index 647bfba..b89a601 100644
--- a/src/libjin/common/je_temporary.h
+++ b/src/libjin/common/je_temporary.h
@@ -1,13 +1,15 @@
#ifndef __JE_TEMPORARY_H__
#define __JE_TEMPORARY_H__
+#include "je_object.h"
+
namespace JinEngine
{
///
/// Class inherites this clound only be created on stack or static zone.
///
- class Temporary
+ class Temporary : public Object
{
public:
Temporary() {};
diff --git a/src/libjin/common/je_utf8.h b/src/libjin/common/je_utf8.h
index d840b75..a720640 100644
--- a/src/libjin/common/je_utf8.h
+++ b/src/libjin/common/je_utf8.h
@@ -31,4 +31,4 @@ namespace JinEngine
#endif // jin_os == jin_os_windows
-#endif // __JE_COMMON_UTF8_H__
+#endif // __JE_COMMON_UTF8_H__ \ No newline at end of file
diff --git a/src/libjin/filesystem/je_asset_database.h b/src/libjin/filesystem/je_asset_database.h
index e8b1bd1..2e029ff 100644
--- a/src/libjin/filesystem/je_asset_database.h
+++ b/src/libjin/filesystem/je_asset_database.h
@@ -18,7 +18,7 @@ namespace JinEngine
///
/// Assets managment.
///
- class AssetDatabase
+ class AssetDatabase : public Object
{
public:
///
diff --git a/src/libjin/game/je_entity.cpp b/src/libjin/game/je_entity.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/game/je_entity.cpp
+++ /dev/null
diff --git a/src/libjin/game/je_entity.h b/src/libjin/game/je_entity.h
deleted file mode 100644
index 80c6ff3..0000000
--- a/src/libjin/game/je_entity.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef __JE_ENTITY_H__
-#define __JE_ENTITY_H__
-
-#include "je_gameobject.h"
-
-namespace JinEngine
-{
- namespace Game
- {
-/*
- ///
- ///
- ///
- class Entity : public GameObject
- {
- public:
- Entity();
-
- private:
-
-
- };
-*/
- } // namespace Game
-} // namespace JinEngine
-
-#endif \ No newline at end of file
diff --git a/src/libjin/game/je_gameobject.cpp b/src/libjin/game/je_gameobject.cpp
index 1396518..731f3a7 100644
--- a/src/libjin/game/je_gameobject.cpp
+++ b/src/libjin/game/je_gameobject.cpp
@@ -1,4 +1,4 @@
-#include "je_entity.h"
+#include "je_gameobject.h"
namespace JinEngine
{
diff --git a/src/libjin/game/je_gameobject.h b/src/libjin/game/je_gameobject.h
index 7c6ec2b..e434caf 100644
--- a/src/libjin/game/je_gameobject.h
+++ b/src/libjin/game/je_gameobject.h
@@ -9,14 +9,13 @@
#include <set>
#include "../common/je_object.h"
-#include "../common/je_types.h"
-#include "../graphics/je_sprite.h"
+#include "../math/je_transform.h"
namespace JinEngine
{
namespace Game
{
- /*
+
///
/// Game object base class.
///
@@ -27,54 +26,13 @@ namespace JinEngine
///
///
///
- virtual ~GameObject();
-
- ///
- ///
- ///
- void lifecycle();
-
- ///
- ///
- ///
- void setVisible(bool isVisible);
-
- ///
- ///
- ///
- void setActive(bool isActive);
-
- ///
- ///
- ///
- void setOrder(uint32 order);
+ virtual ~GameObject() {};
protected:
- virtual void onAlive();
- virtual void onUpdate(float dt);
- virtual void onDraw();
- virtual void onDestroy();
-
- uint32 mLayer; // layer where entity belongs
- uint32 mOrder; // render index in layer
- uint32 mTag; // tag of entity, support 32 tags now
- bool mIsVisible; // if the entity is visible or not
- bool mIsActive; // if the entity is joined into the logic
-
Math::Transform mTransform;
};
- ///
- /// Entity list. For quickly adding and removing entities.
- ///
- typedef std::list<GameObject*> EntityList;
-
- ///
- /// Entity set. For searching and keeps entities unique and sorted.
- ///
- typedef std::set<GameObject*> EntitySet;
- */
} // namespace Game
} // namespace JinEngine
diff --git a/src/libjin/game/je_scene.cpp b/src/libjin/game/je_scene.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/game/je_scene.cpp
+++ /dev/null
diff --git a/src/libjin/game/je_scene.h b/src/libjin/game/je_scene.h
deleted file mode 100644
index 811d1a8..0000000
--- a/src/libjin/game/je_scene.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef __JE_GAME_SCENE_H__
-#define __JE_GAME_SCENE_H__
-
-#include "../core/je_configuration.h"
-#if defined(jin_game)
-
-#include <map>
-#include <list>
-
-#include "je_entity.h"
-
-namespace JinEngine
-{
- namespace Game
- {
-
- ///
- /// Handle all entities.
- ///
- class Scene
- {
- public:
- ///
- ///
- ///
- void addEntity(Entity* entity);
-
- ///
- ///
- ///
- EntityList& getEntitiesByTag(uint32 tag);
-
- ///
- ///
- ///
- EntityList& getEntitiesByLayer(uint32 layer);
-
- ///
- ///
- ///
- void setEntitiesActiveByTag(uint32 tag);
-
- ///
- ///
- ///
- void setEntitiesActiveByLayer(uint32 layer);
-
- ///
- ///
- ///
- void removeEntitiesByLayer(uint32 layer);
-
- ///
- ///
- ///
- void removeEntitiesByTag(uint32 tag);
-
- protected:
- // all entities
- EntitySet entities;
- // all entities grouped by layer, render order
- std::map<uint32, EntityList> layers;
- // all entities grouped by tag
- std::map<uint32, EntityList> tags;
-
- };
-
- } // namespace Game
-} // namespace JinEngine
-
-#endif // jin_game
-
-#endif \ No newline at end of file
diff --git a/src/libjin/graphics/animations/je_animation.h b/src/libjin/graphics/animations/je_animation.h
index 4037721..fd22049 100644
--- a/src/libjin/graphics/animations/je_animation.h
+++ b/src/libjin/graphics/animations/je_animation.h
@@ -4,6 +4,8 @@
#include <vector>
#include <string>
+#include "../../common/je_object.h"
+
#include "../je_sprite.h"
namespace JinEngine
@@ -16,7 +18,7 @@ namespace JinEngine
///
/// Animation clip with key.
///
- class Animation
+ class Animation : public Object
{
public:
Animation();
diff --git a/src/libjin/graphics/animations/je_animator.h b/src/libjin/graphics/animations/je_animator.h
index d3fdbae..bee3d7d 100644
--- a/src/libjin/graphics/animations/je_animator.h
+++ b/src/libjin/graphics/animations/je_animator.h
@@ -3,6 +3,7 @@
#include <string>
+#include "../../common/je_object.h"
#include "../../utils/je_log.h"
#include "je_animation.h"
@@ -14,7 +15,7 @@ namespace JinEngine
namespace Animations
{
- class Animator : public IRenderable
+ class Animator : public Object, public IRenderable
{
public:
Animator();
diff --git a/src/libjin/graphics/fonts/je_decoder.h b/src/libjin/graphics/fonts/je_decoder.h
index 840cada..0c785af 100644
--- a/src/libjin/graphics/fonts/je_decoder.h
+++ b/src/libjin/graphics/fonts/je_decoder.h
@@ -3,6 +3,8 @@
#include <vector>
+#include "../../common/je_object.h"
+
#include "je_text.h"
namespace JinEngine
@@ -15,7 +17,7 @@ namespace JinEngine
///
/// Text decoder.
///
- class Decoder
+ class Decoder : public Object
{
public:
diff --git a/src/libjin/graphics/fonts/je_font.h b/src/libjin/graphics/fonts/je_font.h
index e72ef6b..3f72a13 100644
--- a/src/libjin/graphics/fonts/je_font.h
+++ b/src/libjin/graphics/fonts/je_font.h
@@ -25,7 +25,7 @@ namespace JinEngine
///
/// Base Font class.
///
- class Font : public IRenderable
+ class Font : public Object, public IRenderable
{
public:
///
diff --git a/src/libjin/graphics/fonts/je_text.h b/src/libjin/graphics/fonts/je_text.h
index 6e6f8b0..319ee4d 100644
--- a/src/libjin/graphics/fonts/je_text.h
+++ b/src/libjin/graphics/fonts/je_text.h
@@ -3,6 +3,8 @@
#include <vector>
+#include "../../common/je_object.h"
+
namespace JinEngine
{
namespace Graphics
@@ -30,7 +32,7 @@ namespace JinEngine
///
/// Decoded text. Saved as unicode codepoints.
///
- class Text
+ class Text : public Object
{
public:
///
diff --git a/src/libjin/graphics/fonts/je_ttf.h b/src/libjin/graphics/fonts/je_ttf.h
index 28260f6..c2766b4 100644
--- a/src/libjin/graphics/fonts/je_ttf.h
+++ b/src/libjin/graphics/fonts/je_ttf.h
@@ -34,7 +34,7 @@ namespace JinEngine
// .
// .
//
- class TTFData
+ class TTFData : public Object
{
public:
@@ -289,4 +289,4 @@ namespace JinEngine
#endif // defined(jin_graphics)
-#endif // __JE_FONT_H__
+#endif // __JE_FONT_H__ \ No newline at end of file
diff --git a/src/libjin/graphics/je_bitmap.h b/src/libjin/graphics/je_bitmap.h
index 5ab11ca..e9c214e 100644
--- a/src/libjin/graphics/je_bitmap.h
+++ b/src/libjin/graphics/je_bitmap.h
@@ -24,7 +24,7 @@ namespace JinEngine
/// texture is a renderable hard ware side structure which could be handled with GPU. For instance, opengl
/// create texture and store it in GPU memory for rendering them onto hdc.
///
- class Bitmap
+ class Bitmap : public Object
{
public:
///
diff --git a/src/libjin/graphics/je_gl.cpp b/src/libjin/graphics/je_gl.cpp
index c58f0ac..68678e2 100644
--- a/src/libjin/graphics/je_gl.cpp
+++ b/src/libjin/graphics/je_gl.cpp
@@ -12,14 +12,80 @@ namespace JinEngine
OpenGL gl;
OpenGL::OpenGL()
- : ogl2d::OpenGL()
+ : mBlendMode(BlendMode::NONE)
{
+ memset(&mColor, 0xff, sizeof(mColor));
+ memset(&mPrecolor, 0xff, sizeof(mPrecolor));
+ // Set default modelview matrix.
mModelViewMatrices.push_back(Matrix());
mModelViewMatrix.setIdentity();
for (Matrix& m : mModelViewMatrices)
mModelViewMatrix *= m;
}
+ OpenGL::~OpenGL()
+ {
+ }
+
+ void OpenGL::pushColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
+ {
+ memcpy(&mPrecolor, &mColor, sizeof(mPrecolor));
+ mColor.r = r;
+ mColor.g = g;
+ mColor.b = b;
+ mColor.a = a;
+ glColor4ub(r, g, b, a);
+ }
+
+ void OpenGL::popColor()
+ {
+ memcpy(&mColor, &mPrecolor, sizeof(mPrecolor));
+ glColor4ub(mColor.r, mColor.g, mColor.b, mColor.a);
+ }
+
+ void OpenGL::flushError()
+ {
+ while (glGetError() != GL_NO_ERROR);
+ }
+
+ GLuint OpenGL::genTexture()
+ {
+ GLuint t;
+ glGenTextures(1, &t);
+ return t;
+ }
+
+ void OpenGL::bindTexture(GLuint texture)
+ {
+ glBindTexture(GL_TEXTURE_2D, texture);
+ }
+
+ void OpenGL::deleteTexture(GLuint texture)
+ {
+ glDeleteTextures(1, &texture);
+ }
+
+ void OpenGL::setTexParameter(GLenum pname, GLint param)
+ {
+ glTexParameteri(GL_TEXTURE_2D, pname, param);
+ }
+
+ void OpenGL::texImage(GLint internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
+ {
+ glTexImage2D(GL_TEXTURE_2D, 0, internalformat, width, height, 0, format, type, pixels);
+ }
+
+ void OpenGL::texSubImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
+ {
+ glTexSubImage2D(GL_TEXTURE_2D, 0, xoffset, yoffset, width, height, format, type, pixels);
+ }
+
+ void OpenGL::activeTexUnit(unsigned int unit)
+ {
+ // glActiveTexture selects which texture unit subsequent texture state calls will affect.
+ glActiveTexture(GL_TEXTURE0 + unit);
+ }
+
void OpenGL::setColor(Channel r, Channel g, Channel b, Channel a)
{
setColor(Color(r, g, b, a));
@@ -43,12 +109,12 @@ namespace JinEngine
mModelViewMatrix.setIdentity();
}
- void OpenGL::push()
+ void OpenGL::pushMatrix()
{
mModelViewMatrices.push_back(Matrix());
}
- void OpenGL::pop()
+ void OpenGL::popMatrix()
{
if (mModelViewMatrices.size() == 1)
return;
@@ -112,5 +178,43 @@ namespace JinEngine
mProjectionMatrix.setOrtho(l, r, b, t, n, f);
}
+ OpenGL::BlendMode OpenGL::getBlendMode()
+ {
+ return mBlendMode;
+ }
+
+ void OpenGL::setBlendMode(BlendMode mode)
+ {
+ if (mBlendMode == mode)
+ return;
+ mBlendMode = mode;
+
+ GLenum func = GL_FUNC_ADD;
+ GLenum srcRGB = GL_ONE;
+ GLenum srcA = GL_ONE;
+ GLenum dstRGB = GL_ZERO;
+ GLenum dstA = GL_ZERO;
+
+ switch (mode)
+ {
+ case BlendMode::ADDITIVE:
+ srcRGB = GL_SRC_ALPHA;
+ dstRGB = GL_ONE;
+ break;
+ case BlendMode::PREMULTIPLIEDALPHA:
+ srcRGB = srcA = GL_ONE;
+ dstRGB = dstA = GL_ONE_MINUS_SRC_ALPHA;
+ break;
+ case BlendMode::ALPHA:
+ default:
+ srcRGB = srcA = GL_SRC_ALPHA;
+ dstRGB = dstA = GL_ONE_MINUS_SRC_ALPHA;
+ break;
+ }
+
+ glBlendEquation(func);
+ glBlendFuncSeparate(srcRGB, dstRGB, srcA, dstA);
+ }
+
} // namespace Graphics
} // namespace JinEngine \ No newline at end of file
diff --git a/src/libjin/graphics/je_gl.h b/src/libjin/graphics/je_gl.h
index 134cfee..60b2396 100644
--- a/src/libjin/graphics/je_gl.h
+++ b/src/libjin/graphics/je_gl.h
@@ -7,7 +7,6 @@
#include "../math/je_transform.h"
#include "GLee/GLee.h"
-#include "ogl/OpenGL.h"
#include "je_color.h"
@@ -16,18 +15,112 @@ namespace JinEngine
namespace Graphics
{
- /*class Canvas;
+ // Wrap OpenGL API.
+/*
+ class Canvas;
class Shader;
class Font;
*/
- class OpenGL
- : public ogl2d::OpenGL
+
+ class OpenGL
{
public:
///
+ /// Blend mode.
+ /// https://www.andersriggelsen.dk/glblendfunc.php
///
- ///
+ enum class BlendMode
+ {
+ NONE = 0,
+ ALPHA,
+ ADDITIVE,
+ PREMULTIPLIEDALPHA,
+ };
+
OpenGL();
+ ~OpenGL();
+
+ inline void enable(GLenum cap)
+ {
+ glEnable(cap);
+ }
+
+ inline void disable(GLenum cap)
+ {
+ glDisable(cap);
+ }
+/*
+ inline void setBlendFunc(GLenum sfactor, GLenum dfactor)
+ {
+ glBlendFunc(sfactor, dfactor);
+ }
+*/
+ inline void setClearColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
+ {
+ glClearColor(r / 255.f, g / 255.f, b / 255.f, a / 255.f);
+ }
+
+ void pushColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a = 255);
+ void popColor();
+ void flushError();
+ GLuint genTexture();
+ void deleteTexture(GLuint texture);
+ void bindTexture(GLuint texture = 0);
+ inline GLuint curTexture()
+ {
+ return mTexture;
+ }
+ void setTexParameter(GLenum pname, GLint param);
+ void texImage(GLint internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels = NULL);
+ void texSubImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+ void activeTexUnit(unsigned int unit = 0);
+
+ inline void drawArrays(GLenum mode, GLint first, GLsizei count)
+ {
+ glDrawArrays(mode, first, count);
+ }
+
+ inline void drawBuffer(GLenum mode)
+ {
+
+ }
+
+ inline void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
+ {
+
+ }
+
+ inline void enableClientState(GLenum arr)
+ {
+ glEnableClientState(arr);
+ }
+
+ inline void disableClientState(GLenum arr)
+ {
+ glDisableClientState(arr);
+ }
+
+ inline GLuint genFrameBuffer()
+ {
+ GLuint fbo;
+ glGenFramebuffers(1, &fbo);
+ return fbo;
+ }
+
+ inline void bindFrameBuffer(GLuint fbo)
+ {
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+ }
+
+ inline void ortho(int w, float radio)
+ {
+ glOrtho(0, w, w*radio, 0, -1, 1);
+ }
+
+ inline void orthox(int w, int h)
+ {
+ glOrtho(0, w, h, 0, -1, 1);
+ }
void setColor(Channel r, Channel g, Channel b, Channel a);
@@ -37,7 +130,7 @@ namespace JinEngine
void clearMatrix();
- void push();
+ void pushMatrix();
void translate(float x, float y);
@@ -45,7 +138,7 @@ namespace JinEngine
void rotate(float r);
- void pop();
+ void popMatrix();
///
///
@@ -92,6 +185,16 @@ namespace JinEngine
///
void unUseShader();
+ ///
+ ///
+ ///
+ void setBlendMode(BlendMode mode);
+
+ ///
+ ///
+ ///
+ BlendMode getBlendMode();
+
private:
///
@@ -113,6 +216,16 @@ namespace JinEngine
///
///
Color mCurrentColor;
+
+ ///
+ ///
+ ///
+ BlendMode mBlendMode;
+
+ struct { GLubyte r, g, b, a; } mColor; // current draw color
+ struct { GLubyte r, g, b, a; } mPrecolor; // previous draw color
+ GLuint mTexture; // current binded texture
+
/*
///
///
diff --git a/src/libjin/graphics/je_graphic.h b/src/libjin/graphics/je_graphic.h
index 58de7ec..d48ba3c 100644
--- a/src/libjin/graphics/je_graphic.h
+++ b/src/libjin/graphics/je_graphic.h
@@ -3,6 +3,7 @@
#include "../core/je_configuration.h"
#if defined(jin_graphics)
+#include "../common/je_object.h"
#include "../math/je_quad.h"
#include "../math/je_vector2.hpp"
#include "../math/je_transform.h"
@@ -20,7 +21,7 @@ namespace JinEngine
/// Class inherites Graphic doesn't keep any state such as origin, scale and other properties. Very low
/// level visualized resources.
///
- class Graphic : public IRenderable
+ class Graphic : public Object, public IRenderable
{
public:
///
diff --git a/src/libjin/graphics/je_image.h b/src/libjin/graphics/je_image.h
index 971ac18..15baed3 100644
--- a/src/libjin/graphics/je_image.h
+++ b/src/libjin/graphics/je_image.h
@@ -13,8 +13,7 @@ namespace JinEngine
///
/// Just like bitmap but only from image file. The pixels data is readonly.
///
- class Image
- : public Bitmap
+ class Image : public Bitmap
{
public:
///
diff --git a/src/libjin/graphics/je_mesh.h b/src/libjin/graphics/je_mesh.h
index 27c0cb7..4327424 100644
--- a/src/libjin/graphics/je_mesh.h
+++ b/src/libjin/graphics/je_mesh.h
@@ -20,7 +20,6 @@ namespace JinEngine
private:
const Graphic* mGraphic;
-
};
} // namespace Graphics
diff --git a/src/libjin/graphics/je_sprite.h b/src/libjin/graphics/je_sprite.h
index c7c5a8b..de2117e 100644
--- a/src/libjin/graphics/je_sprite.h
+++ b/src/libjin/graphics/je_sprite.h
@@ -16,7 +16,7 @@ namespace JinEngine
///
/// A sprite is unit of rendering. Animation is based on sprite, but not texture or other graphic stuff.
///
- class Sprite : public IRenderable
+ class Sprite : public Object, public IRenderable
{
public:
diff --git a/src/libjin/graphics/je_sprite_batch.h b/src/libjin/graphics/je_sprite_batch.h
index 64f9805..d58489c 100644
--- a/src/libjin/graphics/je_sprite_batch.h
+++ b/src/libjin/graphics/je_sprite_batch.h
@@ -1,12 +1,14 @@
#ifndef __JE_GRAPHICS_SPRITE_BATCH_H__
#define __JE_GRAPHICS_SPRITE_BATCH_H__
+#include "../common/je_object.h"
+
namespace JinEngine
{
namespace Graphics
{
- class SpriteBatch
+ class SpriteBatch : public Object
{
public:
diff --git a/src/libjin/graphics/je_window.cpp b/src/libjin/graphics/je_window.cpp
index c14d290..f08e816 100644
--- a/src/libjin/graphics/je_window.cpp
+++ b/src/libjin/graphics/je_window.cpp
@@ -86,20 +86,21 @@ namespace JinEngine
return false;
SDL_GL_SetSwapInterval(vsync ? 1 : 0);
SDL_GL_MakeCurrent(mWnd, ctx);
- // Default configuration
+ // Default configuration.
gl.setClearColor(0, 0, 0, 0xff);
glClear(GL_COLOR_BUFFER_BIT);
gl.pushColor(0xff, 0xff, 0xff, 0xff);
gl.enable(GL_BLEND);
gl.enable(GL_TEXTURE_2D);
- gl.setBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- // Bind to default canvas
+ // Default blend function.
+ gl.setBlendMode(OpenGL::BlendMode::ALPHA);
+ // Bind to default canvas.
Canvas::unbind();
Shader::unuse();
// Avoid white blinnk.
swapBuffers();
- return true;
+ return true;
}
void Window::quitSystem()
diff --git a/src/libjin/math/je_percentage.h b/src/libjin/math/je_percentage.h
new file mode 100644
index 0000000..2440072
--- /dev/null
+++ b/src/libjin/math/je_percentage.h
@@ -0,0 +1,36 @@
+#ifndef __JE_PERCENTAGE_H__
+#define __JE_PERCENTAGE_H__
+
+#include "je_math.h"
+
+namespace JinEngine
+{
+ namespace Math
+ {
+
+ class Percentage
+ {
+ public:
+ Percentage(float v)
+ {
+ value = clamp<float>(v, 0, 1);
+ }
+
+ Percentage(const Percentage& p)
+ {
+ value = p.value;
+ }
+
+ void operator = (const Percentage& p)
+ {
+ value = p.value;
+ }
+
+ float value;
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/src/libjin/math/je_ranged_value.cpp b/src/libjin/math/je_ranged_value.cpp
new file mode 100644
index 0000000..b28e72b
--- /dev/null
+++ b/src/libjin/math/je_ranged_value.cpp
@@ -0,0 +1,71 @@
+#include "je_ranged_value.h"
+
+namespace JinEngine
+{
+ namespace Math
+ {
+
+ RangedValue::RangedValue()
+ : mCount(0)
+ {
+ }
+
+ RangedValue::RangedValue(float* points, uint n)
+ : mCount(n)
+ {
+ for (uint i = 0; i < n; ++i)
+ {
+ float x = points[2*i];
+ float y = points[2*i + 1];
+ mXAxis.push_back(x);
+ mYAxis.push_back(y);
+ }
+ }
+
+ void RangedValue::addPoint(float x, float y)
+ {
+ mXAxis.push_back(x);
+ mYAxis.push_back(y);
+ ++mCount;
+ }
+
+ void RangedValue::removePoint(uint i)
+ {
+ mXAxis.erase(mXAxis.begin() + i);
+ mYAxis.erase(mYAxis.begin() + i);
+ --mCount;
+ }
+
+ void RangedValue::insertPoint(uint i, float x, float y)
+ {
+ mXAxis.insert(mXAxis.begin() + i, x);
+ mYAxis.insert(mYAxis.begin() + i, y);
+ ++mCount;
+ }
+
+ float RangedValue::getValue(float x)
+ {
+ int endIndex = -1;
+ int n = mCount;
+ for (int i = 1; i < n; i++) {
+ float t = mXAxis[i];
+ if (t > x) {
+ endIndex = i;
+ break;
+ }
+ }
+ if (endIndex == -1) return mYAxis[n - 1];
+ int startIndex = endIndex - 1;
+ float startValue = mYAxis[startIndex];
+ float startX = mXAxis[startIndex];
+ return startValue + (mYAxis[endIndex] - startValue) * ((x - startX) / (mXAxis[endIndex] - startX));
+ }
+
+ void RangedValue::clear()
+ {
+ mXAxis.clear();
+ mYAxis.clear();
+ }
+
+ }
+} \ No newline at end of file
diff --git a/src/libjin/math/je_ranged_value.h b/src/libjin/math/je_ranged_value.h
new file mode 100644
index 0000000..4749e91
--- /dev/null
+++ b/src/libjin/math/je_ranged_value.h
@@ -0,0 +1,57 @@
+#ifndef __JE_RANGED_VALUE_H__
+#define __JE_RANGED_VALUE_H__
+
+#include "../common/je_types.h"
+
+#include <vector>
+
+namespace JinEngine
+{
+ namespace Math
+ {
+ /*
+ * y ^
+ * |-------- _
+ * | \ / \
+ * | --- \
+ * | \
+ * | \
+ * +----------------------> x
+ */
+ class RangedValue
+ {
+ public:
+ RangedValue();
+
+ ///
+ /// Points of ranged value.
+ ///
+ /// @param points Points.
+ /// @param n Number of points.
+ ///
+ RangedValue(float* points, uint n);
+
+ virtual ~RangedValue() {}
+
+ virtual void addPoint(float x, float y);
+
+ virtual void removePoint(uint i);
+
+ virtual void insertPoint(uint i, float x, float y);
+
+ virtual float getValue(float x);
+
+ virtual void clear();
+
+ private:
+ std::vector<float> mXAxis;
+ std::vector<float> mYAxis;
+
+ uint mCount;
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/src/libjin/math/je_transform.h b/src/libjin/math/je_transform.h
index 45f26e0..35a1a13 100644
--- a/src/libjin/math/je_transform.h
+++ b/src/libjin/math/je_transform.h
@@ -40,7 +40,7 @@ namespace JinEngine
Vector2<float> mPosition;
Vector2<float> mOrigin;
Vector2<float> mScale;
- float mRotation;
+ float mRotation;
};
diff --git a/src/libjin/math/je_vector2.hpp b/src/libjin/math/je_vector2.hpp
index b4cab44..0a1a1e8 100644
--- a/src/libjin/math/je_vector2.hpp
+++ b/src/libjin/math/je_vector2.hpp
@@ -48,6 +48,11 @@ namespace JinEngine
data[1] = _y;
}
+ bool isZero()
+ {
+ return data[0] == 0 && data[1] == 0;
+ }
+
T &x = data[0], &y = data[1]; // xy
T &w = data[0], &h = data[1]; // wh
T &colum = data[0], &row = data[1]; // colum row
diff --git a/src/lua/common/je_lua.h b/src/lua/common/je_lua.h
index b6fc878..66647aa 100644
--- a/src/lua/common/je_lua.h
+++ b/src/lua/common/je_lua.h
@@ -15,6 +15,8 @@ namespace JinEngine
namespace Lua
{
+ // Extends luax.h library.
+
///
///
///
diff --git a/src/lua/common/je_lua_reference.cpp b/src/lua/common/je_lua_reference.cpp
index 37ed441..72c1c3e 100644
--- a/src/lua/common/je_lua_reference.cpp
+++ b/src/lua/common/je_lua_reference.cpp
@@ -10,7 +10,9 @@ namespace JinEngine
LuaRef::LuaRef(lua_State* L, int i)
: mL(L)
{
+ // Get value.
luax_pushvalue(mL, i);
+ // Set reference.
luax_getreferencestable(L);
luax_pushvalue(mL, -2);
mIndex = luax_ref(mL, -2);
diff --git a/src/lua/common/je_lua_shared.cpp b/src/lua/common/je_lua_shared.cpp
index 55832fd..acf1494 100644
--- a/src/lua/common/je_lua_shared.cpp
+++ b/src/lua/common/je_lua_shared.cpp
@@ -36,7 +36,7 @@ namespace JinEngine
{
if (!isDependOn(key))
return;
- std::map<int, SharedBase*>::iterator it = mDependencies.find(key);
+ DepsMap::iterator it = mDependencies.find(key);
SharedBase* dep = it->second;
// Remove lua reference.
luax_removereference(mL, this, dep);
@@ -46,7 +46,7 @@ namespace JinEngine
void SharedBase::removeDependency(SharedBase* dependency)
{
- for (std::map<int, SharedBase*>::iterator it = mDependencies.begin(); it != mDependencies.end();)
+ for (DepsMap::iterator it = mDependencies.begin(); it != mDependencies.end();)
{
SharedBase* dep = it->second;
if (dep == dependency)
diff --git a/src/lua/common/je_lua_shared.hpp b/src/lua/common/je_lua_shared.hpp
index 2f1e18b..579a38e 100644
--- a/src/lua/common/je_lua_shared.hpp
+++ b/src/lua/common/je_lua_shared.hpp
@@ -1,8 +1,6 @@
#ifndef __JIN_COMMON_SHARED_H__
#define __JIN_COMMON_SHARED_H__
-//#include "je_lua.h"
-
#include <map>
#include <vector>
#include <functional>
@@ -59,10 +57,13 @@ namespace JinEngine
clearDependencies();
}
- void* mObject;
- int mCount;
+ using DepsMap = std::map<int, SharedBase*>;
+
+ void* mObject;
+ int mCount;
lua_State* mL;
- std::map<int, SharedBase*> mDependencies;
+ DepsMap mDependencies;
+
};
template<class T>
diff --git a/src/lua/embed/embed.h b/src/lua/embed/embed.h
index 7172a2c..a063e65 100644
--- a/src/lua/embed/embed.h
+++ b/src/lua/embed/embed.h
@@ -7,10 +7,6 @@ namespace JinEngine
namespace Embed
{
- #define embed(L, script, name)\
- if(luax_loadbuffer(L, script, strlen(script), name) == 0)\
- lua_call(L, 0, 0);
-
// Embed structure.
struct jin_Embed
{
@@ -24,7 +20,7 @@ namespace JinEngine
#include "scripts/boot.lua.h"
// In order.
- const jin_Embed scripts[] = {
+ static const jin_Embed scripts[] = {
{ "graphics.lua", graphics_lua },
{ "keyboard.lua", keyboard_lua },
{ "mouse.lua", mouse_lua },
diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp
index 36829ab..d2f663d 100644
--- a/src/lua/modules/graphics/je_lua_graphics.cpp
+++ b/src/lua/modules/graphics/je_lua_graphics.cpp
@@ -888,6 +888,17 @@ namespace JinEngine
return 1;
}
+ LUA_IMPLEMENT int l_newParticleSystem(lua_State* L)
+ {
+ // Definition table.
+ if (!luax_istable(L, 1))
+ {
+ luax_typerror(L, 1, "particle system definition table");
+ return 1;
+ }
+
+ }
+
/* setFont(font) */
LUA_IMPLEMENT int l_setFont(lua_State* L)
{
@@ -920,13 +931,13 @@ namespace JinEngine
LUA_IMPLEMENT int l_pushMatrix(lua_State* L)
{
- gl.push();
+ gl.pushMatrix();
return 0;
}
LUA_IMPLEMENT int l_popMatrix(lua_State* L)
{
- gl.pop();
+ gl.popMatrix();
return 0;
}
@@ -971,59 +982,60 @@ namespace JinEngine
luaL_Reg methods[] = {
/* window */
- { "init", l_init },
- { "setTitle", l_setTitle },
- { "getSize", l_getSize },
- { "getWidth", l_getWidth },
- { "getHeight", l_getHeight },
- { "destroy", l_destroy },
- { "hideWindow", l_hideWindow },
- { "showWindow", l_showWindow },
- /* creators */
- { "newBitmap", l_newBitmap },
- { "newTexture", l_newTexture },
- { "newShader", l_newShader },
- { "newShaderf", l_newShaderf },
- { "newCanvas", l_newCanvas },
- { "newTTFData", l_newTTFData },
- { "newText", l_newText },
- { "newTextureFont", l_newTextureFont },
- { "newSprite", l_newSprite },
- { "newSpriteSheet", l_newSpriteSheet },
- { "newAnimation", l_newAnimation },
- { "newAnimator", l_newAnimator },
+ { "init", l_init },
+ { "setTitle", l_setTitle },
+ { "getSize", l_getSize },
+ { "getWidth", l_getWidth },
+ { "getHeight", l_getHeight },
+ { "destroy", l_destroy },
+ { "hideWindow", l_hideWindow },
+ { "showWindow", l_showWindow },
+ /* creators */
+ { "newBitmap", l_newBitmap },
+ { "newTexture", l_newTexture },
+ { "newShader", l_newShader },
+ { "newShaderf", l_newShaderf },
+ { "newCanvas", l_newCanvas },
+ { "newTTFData", l_newTTFData },
+ { "newText", l_newText },
+ { "newTextureFont", l_newTextureFont },
+ { "newSprite", l_newSprite },
+ { "newSpriteSheet", l_newSpriteSheet },
+ { "newAnimation", l_newAnimation },
+ { "newAnimator", l_newAnimator },
+ { "newParticleSystem", l_newParticleSystem },
/* render */
- { "setClearColor", l_setClearColor },
- { "clear", l_clear },
- { "draw", l_draw },
- { "print", l_print },
- { "drawq", l_drawq },
- { "setColor", l_setColor },
- { "getColor", l_getColor },
- { "present", l_present },
- /* canvas */
- { "bindCanvas", l_bindCanvas },
- { "unbindCanvas", l_unbindCanvas },
- /* shader */
- { "useShader", l_useShader },
- /* shapes */
- { "point", l_point },
- { "line", l_line },
- { "rect", l_rect },
- { "circle", l_circle },
- { "triangle", l_triangle },
- { "polygon", l_polygon },
- /* font */
- { "setFont", l_setFont },
- { "unsetFont", l_unsetFont },
- /* transform */
- { "pushMatrix", l_pushMatrix },
- { "clearMatrix", l_clearMatrix },
- { "popMatrix", l_popMatrix },
- { "translate", l_translate },
- { "rotate", l_rotate },
- { "scale", l_scale },
- { 0, 0 }
+ { "setClearColor", l_setClearColor },
+ { "clear", l_clear },
+ { "draw", l_draw },
+ { "print", l_print },
+ { "drawq", l_drawq },
+ { "setColor", l_setColor },
+ { "getColor", l_getColor },
+ { "present", l_present },
+ /* canvas */
+ { "bindCanvas", l_bindCanvas },
+ { "unbindCanvas", l_unbindCanvas },
+ /* shader */
+ { "useShader", l_useShader },
+ /* shapes */
+ { "point", l_point },
+ { "line", l_line },
+ { "rect", l_rect },
+ { "circle", l_circle },
+ { "triangle", l_triangle },
+ { "polygon", l_polygon },
+ /* font */
+ { "setFont", l_setFont },
+ { "unsetFont", l_unsetFont },
+ /* transform */
+ { "pushMatrix", l_pushMatrix },
+ { "clearMatrix", l_clearMatrix },
+ { "popMatrix", l_popMatrix },
+ { "translate", l_translate },
+ { "rotate", l_rotate },
+ { "scale", l_scale },
+ { 0, 0 }
};
// Load whole lib.
luax_newlib(L, methods);
diff --git a/src/lua/modules/graphics/je_lua_particle_system.cpp b/src/lua/modules/graphics/je_lua_particle_system.cpp
index 7099a5c..b0cb221 100644
--- a/src/lua/modules/graphics/je_lua_particle_system.cpp
+++ b/src/lua/modules/graphics/je_lua_particle_system.cpp
@@ -8,4 +8,4 @@ namespace JinEngine
} // Lua
-} // namespace JinEngine \ No newline at end of file
+} // namespace JinEngine \ No newline at end of file