aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-10-21 16:21:16 +0800
committerchai <chaifix@163.com>2018-10-21 16:21:16 +0800
commit07770f3ad369ff47386310b731d349f7af1fe0d9 (patch)
tree7547b1a8b2beaceb31ea1b62edbdaa5cd6a1b247
parent066e5987c515dfc34537d73ca9d2a81ddd1f9e1b (diff)
*修改编译控制
-rw-r--r--bin/Jin.exebin478720 -> 487936 bytes
-rw-r--r--bin/jin.exebin478720 -> 487936 bytes
-rw-r--r--bin/main.lua4
-rw-r--r--build/vc++/jin.vcxproj4
-rw-r--r--src/libjin/Audio/SDL/je_sdl_audio.cpp6
-rw-r--r--src/libjin/Audio/SDL/je_sdl_audio.h4
-rw-r--r--src/libjin/Audio/SDL/je_sdl_source.cpp4
-rw-r--r--src/libjin/Audio/SDL/je_sdl_source.h4
-rw-r--r--src/libjin/Audio/je_audio_manager.cpp4
-rw-r--r--src/libjin/Audio/je_audio_manager.h4
-rw-r--r--src/libjin/Audio/je_source.cpp4
-rw-r--r--src/libjin/Audio/je_source.h4
-rw-r--r--src/libjin/Common/je_utf8.cpp4
-rw-r--r--src/libjin/Common/je_utf8.h4
-rw-r--r--src/libjin/Filesystem/je_asset_database.cpp7
-rw-r--r--src/libjin/Filesystem/je_asset_database.h8
-rw-r--r--src/libjin/Filesystem/je_buffer.h7
-rw-r--r--src/libjin/Game/je_entity.h5
-rw-r--r--src/libjin/Game/je_game.cpp7
-rw-r--r--src/libjin/Game/je_game.h5
-rw-r--r--src/libjin/Game/je_scene.h5
-rw-r--r--src/libjin/Graphics/Font/je_font.h2
-rw-r--r--src/libjin/Graphics/Font/je_page.h2
-rw-r--r--src/libjin/Graphics/Font/je_texture_font.cpp29
-rw-r--r--src/libjin/Graphics/Font/je_ttf.cpp11
-rw-r--r--src/libjin/Graphics/Font/je_ttf.h4
-rw-r--r--src/libjin/Graphics/Shader/je_jsl_compiler.cpp7
-rw-r--r--src/libjin/Graphics/Shader/je_jsl_compiler.h11
-rw-r--r--src/libjin/Graphics/Shader/je_shader.cpp5
-rw-r--r--src/libjin/Graphics/Shader/je_shader.h4
-rw-r--r--src/libjin/Graphics/je_bitmap.cpp11
-rw-r--r--src/libjin/Graphics/je_bitmap.h10
-rw-r--r--src/libjin/Graphics/je_canvas.cpp14
-rw-r--r--src/libjin/Graphics/je_canvas.h4
-rw-r--r--src/libjin/Graphics/je_drawable.cpp4
-rw-r--r--src/libjin/Graphics/je_drawable.h4
-rw-r--r--src/libjin/Graphics/je_gl.h2
-rw-r--r--src/libjin/Graphics/je_graphics.h4
-rw-r--r--src/libjin/Graphics/je_shapes.cpp4
-rw-r--r--src/libjin/Graphics/je_texture.cpp14
-rw-r--r--src/libjin/Graphics/je_texture.h13
-rw-r--r--src/libjin/Graphics/je_window.cpp6
-rw-r--r--src/libjin/Input/je_event.h8
-rw-r--r--src/libjin/Input/je_mouse.cpp8
-rw-r--r--src/libjin/Input/je_mouse.h4
-rw-r--r--src/libjin/Net/je_net_manager.cpp2
-rw-r--r--src/libjin/Net/je_net_manager.h4
-rw-r--r--src/libjin/Net/je_socket.cpp104
-rw-r--r--src/libjin/Net/je_socket.h10
-rw-r--r--src/libjin/Time/je_timer.cpp4
-rw-r--r--src/libjin/Time/je_timer.h10
-rw-r--r--src/libjin/Utils/je_endian.h14
-rw-r--r--src/libjin/Utils/je_log.h4
-rw-r--r--src/libjin/ai/je_behavior_tree.h5
-rw-r--r--src/libjin/ai/je_state_machine.h5
-rw-r--r--src/libjin/core/je_configuration.h111
-rw-r--r--src/libjin/core/je_version.h32
-rw-r--r--src/libjin/jin.h11
-rw-r--r--src/libjin/multithread/je_thread.cpp36
-rw-r--r--src/libjin/multithread/je_thread.h12
-rw-r--r--src/lua/embed/boot.lua.h20
-rw-r--r--src/lua/modules/graphics/graphics.cpp33
62 files changed, 401 insertions, 295 deletions
diff --git a/bin/Jin.exe b/bin/Jin.exe
index 88b82c6..8e3c89f 100644
--- a/bin/Jin.exe
+++ b/bin/Jin.exe
Binary files differ
diff --git a/bin/jin.exe b/bin/jin.exe
index 88b82c6..8e3c89f 100644
--- a/bin/jin.exe
+++ b/bin/jin.exe
Binary files differ
diff --git a/bin/main.lua b/bin/main.lua
index 7d3d4ae..a54235c 100644
--- a/bin/main.lua
+++ b/bin/main.lua
@@ -18,7 +18,7 @@ function jin.core.onLoad()
bitmap = nil
-- local ttfdata = jin.graphics.newTTFData("font_pixel.ttf")
-- ttf = ttfdata:newTTF(22);
- bitmap = jin.graphics.newBitmap("font2.png")
+ bitmap = jin.graphics.newBitmap(1,"font2.png")
tf = jin.graphics.newTextureFont(bitmap, [[<=>?.'^@abcdefghijklmnopqrstuvwxyz|~[\]_]], {255, 0, 0, 255}, 16)
end
@@ -50,6 +50,6 @@ end
function jin.core.onDraw()
jin.graphics.setColor(255, 255, 255)
jin.graphics.draw(sprites, 10, 10, 1, 1)
- jin.graphics.setFont(tf)
+ -- jin.graphics.setFont(tf)
jin.graphics.print("this is a demo")
end \ No newline at end of file
diff --git a/build/vc++/jin.vcxproj b/build/vc++/jin.vcxproj
index 2febc9b..28ab8ce 100644
--- a/build/vc++/jin.vcxproj
+++ b/build/vc++/jin.vcxproj
@@ -82,7 +82,6 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
- <Optimization>MinSpace</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src\;$(SolutionDir)libs\SDL2-2.0.5\include;$(SolutionDir)libs\LuaJIT-2.0.5\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -90,6 +89,7 @@
<ObjectFileName>$(IntDir)/%(RelativeDir)/</ObjectFileName>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<IntrinsicFunctions>true</IntrinsicFunctions>
+ <Optimization>MinSpace</Optimization>
</ClCompile>
<Link>
<AdditionalDependencies>opengl32.lib;glu32.lib;lua51.lib;SDL2main.lib;SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -124,7 +124,7 @@
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>opengl32.lib;glu32.lib;lua51.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)libs\SDL2-2.0.5\lib\x86;$(SolutionDir)libs\LuaJIT-2.0.5\src;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <SubSystem>Console</SubSystem>
+ <SubSystem>Windows</SubSystem>
<EntryPointSymbol>
</EntryPointSymbol>
</Link>
diff --git a/src/libjin/Audio/SDL/je_sdl_audio.cpp b/src/libjin/Audio/SDL/je_sdl_audio.cpp
index cd79bed..96df17f 100644
--- a/src/libjin/Audio/SDL/je_sdl_audio.cpp
+++ b/src/libjin/Audio/SDL/je_sdl_audio.cpp
@@ -1,5 +1,5 @@
#include "../../core/je_configuration.h"
-#if LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO
+#if defined(jin_audio) && (jin_audio == jin_audio_sdl)
#include <iostream>
@@ -31,7 +31,7 @@ namespace JinEngine
/*call only once*/ bool SDLAudio::initSystem(const SettingBase* s)
{
- #if LIBJIN_DEBUG
+ #if defined(jin_debug)
Loghelper::log(Loglevel::LV_INFO, "Init AudioManager System");
#endif
@@ -140,4 +140,4 @@ namespace JinEngine
} // namespace Audio
} // namespace JinEngine
-#endif // LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO
+#endif // (jin_audio) && (jin_audio == jin_audio_sdl) \ No newline at end of file
diff --git a/src/libjin/Audio/SDL/je_sdl_audio.h b/src/libjin/Audio/SDL/je_sdl_audio.h
index b13dc10..57fee5b 100644
--- a/src/libjin/Audio/SDL/je_sdl_audio.h
+++ b/src/libjin/Audio/SDL/je_sdl_audio.h
@@ -1,7 +1,7 @@
#ifndef __JE_AUDIO_SDL_H
#define __JE_AUDIO_SDL_H
#include "../../core/je_configuration.h"
-#if LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO
+#if defined(jin_audio) && (jin_audio == jin_audio_sdl)
#include <vector>
@@ -130,6 +130,6 @@ namespace JinEngine
} // namespace Audio
} // namespace JinEngine
-#endif // LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO
+#endif // (jin_audio) && (jin_audio == jin_audio_sdl)
#endif // __JE_AUDIO_SDL_H \ No newline at end of file
diff --git a/src/libjin/Audio/SDL/je_sdl_source.cpp b/src/libjin/Audio/SDL/je_sdl_source.cpp
index 8f4a2dc..72607dd 100644
--- a/src/libjin/Audio/SDL/je_sdl_source.cpp
+++ b/src/libjin/Audio/SDL/je_sdl_source.cpp
@@ -1,5 +1,5 @@
#include "../../core/je_configuration.h"
-#if LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO
+#if defined(jin_audio) && (jin_audio == jin_audio_sdl)
#include <exception>
#include <fstream>
@@ -397,4 +397,4 @@ namespace JinEngine
} // namespace Audio
} // namespace JinEngine
-#endif // LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO
+#endif // (jin_audio) && (jin_audio == jin_audio_sdl)
diff --git a/src/libjin/Audio/SDL/je_sdl_source.h b/src/libjin/Audio/SDL/je_sdl_source.h
index fe6abc3..78cae80 100644
--- a/src/libjin/Audio/SDL/je_sdl_source.h
+++ b/src/libjin/Audio/SDL/je_sdl_source.h
@@ -1,7 +1,7 @@
#ifndef __JE_SOURCE_SDL_H
#define __JE_SOURCE_SDL_H
#include "../../core/je_configuration.h"
-#if LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO
+#if defined(jin_audio) && (jin_audio == jin_audio_sdl)
#include <vector>
#include <queue>
@@ -264,6 +264,6 @@ namespace JinEngine
} // namespace Audio
} // namespace JinEngine
-#endif // LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO
+#endif // (jin_audio) && (jin_audio == jin_audio_sdl)
#endif // __JE_SOURCE_SDL_H \ No newline at end of file
diff --git a/src/libjin/Audio/je_audio_manager.cpp b/src/libjin/Audio/je_audio_manager.cpp
index 4b56132..e451aa3 100644
--- a/src/libjin/Audio/je_audio_manager.cpp
+++ b/src/libjin/Audio/je_audio_manager.cpp
@@ -1,5 +1,5 @@
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_AUDIO
+#if jin_audio
#include "SDL2/SDL.h"
#include "je_audio_manager.h"
@@ -12,4 +12,4 @@ namespace JinEngine
} // namespace Audio
} // namespace JinEngine
-#endif // LIBJIN_MODULES_AUDIO
+#endif // jin_audio
diff --git a/src/libjin/Audio/je_audio_manager.h b/src/libjin/Audio/je_audio_manager.h
index 10df08c..00b531a 100644
--- a/src/libjin/Audio/je_audio_manager.h
+++ b/src/libjin/Audio/je_audio_manager.h
@@ -2,7 +2,7 @@
#define __JE_AUDIO_H
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_AUDIO
+#if defined(jin_audio)
#include "../utils/je_macros.h"
#include "../common/je_subsystem.hpp"
@@ -82,6 +82,6 @@ namespace JinEngine
} // namespace Audio
} // namespace JinEngine
-#endif // LIBJIN_MODULES_AUDIO
+#endif // jin_audio
#endif // __JE_AUDIO_H \ No newline at end of file
diff --git a/src/libjin/Audio/je_source.cpp b/src/libjin/Audio/je_source.cpp
index 573366d..6bc1f4f 100644
--- a/src/libjin/Audio/je_source.cpp
+++ b/src/libjin/Audio/je_source.cpp
@@ -1,5 +1,5 @@
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_AUDIO
+#if defined(jin_audio)
#include <cstring>
@@ -27,4 +27,4 @@ namespace JinEngine
} // namespace Audio
} // namespace JinEngine
-#endif // LIBJIN_MODULES_AUDIO
+#endif // jin_audio
diff --git a/src/libjin/Audio/je_source.h b/src/libjin/Audio/je_source.h
index ac87c07..519d39f 100644
--- a/src/libjin/Audio/je_source.h
+++ b/src/libjin/Audio/je_source.h
@@ -1,7 +1,7 @@
#ifndef __JE_AUDIO_SOURCE_H
#define __JE_AUDIO_SOURCE_H
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_AUDIO
+#if defined(jin_audio)
#include "SDL2/SDL.h"
@@ -111,6 +111,6 @@ namespace JinEngine
} // namespace Audio
} // namespace JinEngine
-#endif // LIBJIN_MODULES_AUDIO
+#endif // jin_audio
#endif // __JE_AUDIO_SOURCE_H \ No newline at end of file
diff --git a/src/libjin/Common/je_utf8.cpp b/src/libjin/Common/je_utf8.cpp
index 012bf5e..bd7ce94 100644
--- a/src/libjin/Common/je_utf8.cpp
+++ b/src/libjin/Common/je_utf8.cpp
@@ -1,5 +1,5 @@
#include "../core/je_configuration.h"
-#if LIBJIN_OS == LIBJIN_WINDOWS
+#if jin_os == jin_os_windows
#include "je_utf8.h"
@@ -39,4 +39,4 @@ namespace JinEngine
} // namespace JinEngine
-#endif // LIBJIN_OS == LIBJIN_WINDOWS \ No newline at end of file
+#endif // jin_os == jin_os_windows \ No newline at end of file
diff --git a/src/libjin/Common/je_utf8.h b/src/libjin/Common/je_utf8.h
index 72a11af..a11850c 100644
--- a/src/libjin/Common/je_utf8.h
+++ b/src/libjin/Common/je_utf8.h
@@ -2,7 +2,7 @@
#define __JE_COMMON_UTF8_H
#include "../core/je_configuration.h"
-#if LIBJIN_OS == LIBJIN_WINDOWS
+#if jin_os == jin_os_windows
#include <string>
#include <windows.h>
@@ -29,6 +29,6 @@ namespace JinEngine
} // namespace JinEngine
-#endif // LIBJIN_OS == LIBJIN_WINDOWS
+#endif // jin_os == jin_os_windows
#endif // __JE_COMMON_UTF8_H \ No newline at end of file
diff --git a/src/libjin/Filesystem/je_asset_database.cpp b/src/libjin/Filesystem/je_asset_database.cpp
index edc3661..738b18f 100644
--- a/src/libjin/Filesystem/je_asset_database.cpp
+++ b/src/libjin/Filesystem/je_asset_database.cpp
@@ -1,3 +1,6 @@
+#include "../core/je_configuration.h"
+#if defined(jin_filesystem)
+
#include <string.h>
#include <stdlib.h>
#include <stdio.h> /* defines FILENAME_MAX */
@@ -72,4 +75,6 @@ namespace JinEngine
}
} // namespace Filesystem
-} // namespace JinEngine \ No newline at end of file
+} // namespace JinEngine
+
+#endif // jin_filesystem \ 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 81cce64..3d47f15 100644
--- a/src/libjin/Filesystem/je_asset_database.h
+++ b/src/libjin/Filesystem/je_asset_database.h
@@ -1,9 +1,13 @@
#ifndef __JE_ASSET_DATABASE_H
#define __JE_ASSET_DATABASE_H
-#include "je_buffer.h"
+#include "../core/je_configuration.h"
+#if defined(jin_filesystem)
+
#include "../3rdparty/smount/smount.h"
+#include "je_buffer.h"
+
namespace JinEngine
{
namespace Filesystem
@@ -92,4 +96,6 @@ namespace JinEngine
} // namespace Filesystem
} // namespace JinEngine
+#endif // jin_filesystem
+
#endif \ No newline at end of file
diff --git a/src/libjin/Filesystem/je_buffer.h b/src/libjin/Filesystem/je_buffer.h
index 18a381d..a2f4deb 100644
--- a/src/libjin/Filesystem/je_buffer.h
+++ b/src/libjin/Filesystem/je_buffer.h
@@ -1,6 +1,9 @@
#ifndef __JE_BUFFER_H
#define __JE_BUFFER_H
+#include "../core/je_configuration.h"
+#if defined(jin_filesystem)
+
#include <string.h>
#include <stdlib.h>
@@ -164,4 +167,6 @@ namespace JinEngine
} // namespace Filesystem
} // namespace JinEngine
-#endif \ No newline at end of file
+#endif // jin_filesystem
+
+#endif \ No newline at end of file
diff --git a/src/libjin/Game/je_entity.h b/src/libjin/Game/je_entity.h
index 29fe8be..41a3c10 100644
--- a/src/libjin/Game/je_entity.h
+++ b/src/libjin/Game/je_entity.h
@@ -1,6 +1,9 @@
#ifndef __JE_GAME_OBJECT_H
#define __JE_GAME_OBJECT_H
+#include "../core/je_configuration.h"
+#if defined(jin_game)
+
#include <map>
#include <set>
@@ -48,4 +51,6 @@ namespace JinEngine
} // namespace Game
} // namespace JinEngine
+#endif // jin_game
+
#endif \ No newline at end of file
diff --git a/src/libjin/Game/je_game.cpp b/src/libjin/Game/je_game.cpp
index 3052bc2..6eb1d3f 100644
--- a/src/libjin/Game/je_game.cpp
+++ b/src/libjin/Game/je_game.cpp
@@ -1,3 +1,6 @@
+#include "../core/je_configuration.h"
+#if defined(jin_game)
+
#include <iostream>
#include "../time/je_timer.h"
@@ -71,4 +74,6 @@ namespace JinEngine
}
} // namespace Core
-} // namespace JinEngine \ No newline at end of file
+} // namespace JinEngine
+
+#endif // jin_game \ No newline at end of file
diff --git a/src/libjin/Game/je_game.h b/src/libjin/Game/je_game.h
index 6f7ad6d..78c3385 100644
--- a/src/libjin/Game/je_game.h
+++ b/src/libjin/Game/je_game.h
@@ -1,6 +1,9 @@
#ifndef __JE_CORE_GAME_H
#define __JE_CORE_GAME_H
+#include "../core/je_configuration.h"
+#if defined(jin_game)
+
#include "../common/je_subsystem.hpp"
#include "../utils/je_macros.h"
#include "../input/je_Event.h"
@@ -80,4 +83,6 @@ namespace JinEngine
} // namespace Core
} // namespace JinEngine
+#endif // jin_game
+
#endif // __JE_CORE_GAME_H \ No newline at end of file
diff --git a/src/libjin/Game/je_scene.h b/src/libjin/Game/je_scene.h
index 388b047..34d4569 100644
--- a/src/libjin/Game/je_scene.h
+++ b/src/libjin/Game/je_scene.h
@@ -1,6 +1,9 @@
#ifndef __JE_GAME_SCENE_H
#define __JE_GAME_SCENE_H
+#include "../core/je_configuration.h"
+#if defined(jin_game)
+
#include <map>
#include <list>
@@ -65,4 +68,6 @@ namespace JinEngine
}
}
+#endif // jin_game
+
#endif \ No newline at end of file
diff --git a/src/libjin/Graphics/Font/je_font.h b/src/libjin/Graphics/Font/je_font.h
index 75dd4c5..4529902 100644
--- a/src/libjin/Graphics/Font/je_font.h
+++ b/src/libjin/Graphics/Font/je_font.h
@@ -97,4 +97,4 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif \ No newline at end of file
+#endif // __JE_FONT_H \ No newline at end of file
diff --git a/src/libjin/Graphics/Font/je_page.h b/src/libjin/Graphics/Font/je_page.h
index 7df2784..fbc297e 100644
--- a/src/libjin/Graphics/Font/je_page.h
+++ b/src/libjin/Graphics/Font/je_page.h
@@ -48,4 +48,4 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif \ No newline at end of file
+#endif // __JE_PAGE_H \ No newline at end of file
diff --git a/src/libjin/Graphics/Font/je_texture_font.cpp b/src/libjin/Graphics/Font/je_texture_font.cpp
index 81ac343..f85a8ce 100644
--- a/src/libjin/Graphics/Font/je_texture_font.cpp
+++ b/src/libjin/Graphics/Font/je_texture_font.cpp
@@ -72,19 +72,27 @@ namespace JinEngine
for (Codepoint c : text)
{
+ // return
if (c == 0x0D) continue;
+ // newline
if (c == 0x0A)
{
- /* new line */
p.y += lineheight;
p.x = 0;
continue;
}
+ if (c == 0x09)
+ {
+ // tab = 4*space
+ unsigned cw = getCharWidth(0x20);
+ p.x += cw * 4;
+ continue;
+ }
glyph = findGlyph(c);
if (glyph == nullptr) continue;
- if (texture != this->texture)
+ if (texture != mTexture)
{
- texture = this->texture;
+ texture = mTexture;
GlyphArrayDrawInfo info;
info.start = i;
info.count = 0;
@@ -93,8 +101,8 @@ namespace JinEngine
}
glyphinfolist[glyphinfolist.size() - 1].count += 4;
// normalized
- float nx = glyph->x / (float)size.w, ny = glyph->y / (float)size.h;
- float nw = glyph->w / (float)size.w, nh = glyph->h / (float)size.h;
+ float nx = glyph->x / (float)mSize.w, ny = glyph->y / (float)mSize.h;
+ float nw = glyph->w / (float)mSize.w, nh = glyph->h / (float)mSize.h;
glyphvertices_push(p.x, p.y, nx, ny);
glyphvertices_push(p.x, p.y + glyph->h, nx, ny + nh);
glyphvertices_push(p.x + glyph->w, p.y + glyph->h, nx + nw, ny + nh);
@@ -139,9 +147,16 @@ namespace JinEngine
tmp = 0;
continue;
}
+ if (c == 0x09)
+ {
+ // tab = 4*space
+ unsigned cw = getCharWidth(0x20);
+ tmp += cw * 4;
+ if (tmp > res) res = tmp;
+ continue;
+ }
tmp += getCharWidth(c) + spacing;
- if (tmp > res)
- res = tmp;
+ if (tmp > res) res = tmp;
}
return res;
}
diff --git a/src/libjin/Graphics/Font/je_ttf.cpp b/src/libjin/Graphics/Font/je_ttf.cpp
index 0ee02ab..a11efb0 100644
--- a/src/libjin/Graphics/Font/je_ttf.cpp
+++ b/src/libjin/Graphics/Font/je_ttf.cpp
@@ -1,5 +1,5 @@
#include "../../core/je_configuration.h"
-#if LIBJIN_MODULES_RENDER
+#if defined(jin_graphics)
#include <stdio.h>
@@ -279,6 +279,13 @@ namespace JinEngine
p.x = 0;
continue;
}
+ if (c == 0x09)
+ {
+ // tab = 4*space
+ unsigned cw = getCharWidth(0x20);
+ p.x += cw * 4;
+ continue;
+ }
glyphlize(c);
p.x += glyph->width + spacing;
i += 4;
@@ -453,4 +460,4 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif // LIBJIN_MODULES_RENDER \ No newline at end of file
+#endif // defined(jin_graphics) \ No newline at end of file
diff --git a/src/libjin/Graphics/Font/je_ttf.h b/src/libjin/Graphics/Font/je_ttf.h
index 9acb07e..7bc6934 100644
--- a/src/libjin/Graphics/Font/je_ttf.h
+++ b/src/libjin/Graphics/Font/je_ttf.h
@@ -1,7 +1,7 @@
#ifndef __JETTF_H
#define __JE_TTF_H
#include "../../core/je_configuration.h"
-#if LIBJIN_MODULES_RENDER
+#if defined(jin_graphics)
#include <vector>
#include <map>
@@ -283,6 +283,6 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif // LIBJIN_MODULES_RENDER
+#endif // defined(jin_graphics)
#endif // __JE_FONT_H \ No newline at end of file
diff --git a/src/libjin/Graphics/Shader/je_jsl_compiler.cpp b/src/libjin/Graphics/Shader/je_jsl_compiler.cpp
index 490caea..2683969 100644
--- a/src/libjin/Graphics/Shader/je_jsl_compiler.cpp
+++ b/src/libjin/Graphics/Shader/je_jsl_compiler.cpp
@@ -1,3 +1,6 @@
+#include "../../core/je_configuration.h"
+#if defined(jin_graphics) && (jin_graphics & jin_graphics_shader)
+
#include "je_jsl_compiler.h"
namespace JinEngine
@@ -8,4 +11,6 @@ namespace JinEngine
} // namespace Graphics
-} // namespace JinEngine \ No newline at end of file
+} // namespace JinEngine
+
+#endif // (jin_graphics) && (jin_graphics & jin_graphics_shader) \ No newline at end of file
diff --git a/src/libjin/Graphics/Shader/je_jsl_compiler.h b/src/libjin/Graphics/Shader/je_jsl_compiler.h
index b530466..1817a7b 100644
--- a/src/libjin/Graphics/Shader/je_jsl_compiler.h
+++ b/src/libjin/Graphics/Shader/je_jsl_compiler.h
@@ -1,6 +1,9 @@
#ifndef __JE_JSL_COMPILER_H
#define __JE_JSL_COMPILER_H
+#include "../../core/je_configuration.h"
+#if defined(jin_graphics) && (jin_graphics & jin_graphics_shader)
+
#include "../../common/je_singleton.hpp"
namespace JinEngine
@@ -21,7 +24,9 @@ namespace JinEngine
};
- }
-}
+ } // namespace Graphics
+} // namespace JinEngine
+
+#endif // (jin_graphics) && (jin_graphics & jin_graphics_shader)
-#endif \ No newline at end of file
+#endif // __JE_JSL_COMPILER_H \ No newline at end of file
diff --git a/src/libjin/Graphics/Shader/je_shader.cpp b/src/libjin/Graphics/Shader/je_shader.cpp
index 6066864..6c8076a 100644
--- a/src/libjin/Graphics/Shader/je_shader.cpp
+++ b/src/libjin/Graphics/Shader/je_shader.cpp
@@ -1,6 +1,5 @@
-#include <regex>
#include "../../core/je_configuration.h"
-#if defined(jin_graphics_shader)
+#if defined(jin_graphics) && (jin_graphics & jin_graphics_shader)
#include <iostream>
@@ -285,4 +284,4 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif // jin_graphics_shader \ No newline at end of file
+#endif // (jin_graphics) && (jin_graphics & jin_graphics_shader) \ No newline at end of file
diff --git a/src/libjin/Graphics/Shader/je_shader.h b/src/libjin/Graphics/Shader/je_shader.h
index 69746de..928fb0a 100644
--- a/src/libjin/Graphics/Shader/je_shader.h
+++ b/src/libjin/Graphics/Shader/je_shader.h
@@ -2,7 +2,7 @@
#define __JE_SHADER_H
#include "../../core/je_configuration.h"
-#if defined(jin_graphics) && defined(jin_graphics_shader)
+#if defined(jin_graphics) && (jin_graphics & jin_graphics_shader)
#include <string>
#include <map>
@@ -195,6 +195,6 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif // jin_graphics && jin_graphics_shader
+#endif // (jin_graphics) && (jin_graphics & jin_graphics_shader)
#endif // __JE_SHADER_H \ No newline at end of file
diff --git a/src/libjin/Graphics/je_bitmap.cpp b/src/libjin/Graphics/je_bitmap.cpp
index 5269606..0747f0b 100644
--- a/src/libjin/Graphics/je_bitmap.cpp
+++ b/src/libjin/Graphics/je_bitmap.cpp
@@ -1,9 +1,12 @@
#define STB_IMAGE_IMPLEMENTATION
#include "../3rdparty/stb/stb_image.h"
+
+#include "../filesystem/je_asset_database.h"
#include "../math/je_math.h"
#include "je_bitmap.h"
+using namespace JinEngine::Filesystem;
using namespace JinEngine::Math;
namespace JinEngine
@@ -11,6 +14,14 @@ namespace JinEngine
namespace Graphics
{
+ Bitmap* Bitmap::createBitmap(const char* path)
+ {
+ AssetDatabase* ad = AssetDatabase::get();
+ Buffer buffer;
+ ad->read(path, buffer);
+ return createBitmap(&buffer, buffer.size());
+ }
+
/* pixelbitmap */
Bitmap* Bitmap::createBitmap(const void* pixel, unsigned width, unsigned height)
{
diff --git a/src/libjin/Graphics/je_bitmap.h b/src/libjin/Graphics/je_bitmap.h
index d9d0981..445bf91 100644
--- a/src/libjin/Graphics/je_bitmap.h
+++ b/src/libjin/Graphics/je_bitmap.h
@@ -1,7 +1,7 @@
#ifndef __JE_BITMAP_H
#define __JE_BITMAP_H
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_RENDER
+#if defined(jin_graphics)
#include "../3rdparty/GLee/GLee.h"
#include "../common/je_types.h"
@@ -22,6 +22,14 @@ namespace JinEngine
class Bitmap
{
public:
+ ///
+ /// Create bitmap from given file.
+ ///
+ /// @param path Path of image file.
+ /// @return Bitmap if create successful, otherwise retrun false.
+ ///
+ static Bitmap* createBitmap(const char* path);
+
///
/// Create bitmap by pixels data.
///
diff --git a/src/libjin/Graphics/je_canvas.cpp b/src/libjin/Graphics/je_canvas.cpp
index b8553b5..6406e5f 100644
--- a/src/libjin/Graphics/je_canvas.cpp
+++ b/src/libjin/Graphics/je_canvas.cpp
@@ -1,5 +1,5 @@
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_RENDER
+#if defined(jin_graphics)
#include "../utils/je_macros.h"
#include "je_canvas.h"
@@ -34,13 +34,13 @@ namespace JinEngine
gl.bindFrameBuffer(fbo);
// generate texture save target
- texture = gl.genTexture();
- gl.bindTexture(texture);
+ mTexture = gl.genTexture();
+ gl.bindTexture(mTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl.texImage(GL_RGBA8, w, h, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
gl.bindTexture(0);
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexture, 0);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
@@ -65,8 +65,8 @@ namespace JinEngine
if (isBinded(canvas)) return;
current = canvas;
gl.bindFrameBuffer(canvas->fbo);
- int w = canvas->size.w;
- int h = canvas->size.h;
+ int w = canvas->mSize.w;
+ int h = canvas->mSize.h;
/* set view port to canvas */
glViewport(0, 0, w, h);
gl.ProjectionMatrix.setOrtho(0, w, 0, h, -1, 1);
@@ -99,4 +99,4 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif // LIBJIN_MODULES_RENDER \ No newline at end of file
+#endif // defined(jin_graphics) \ No newline at end of file
diff --git a/src/libjin/Graphics/je_canvas.h b/src/libjin/Graphics/je_canvas.h
index 9839899..a4c0330 100644
--- a/src/libjin/Graphics/je_canvas.h
+++ b/src/libjin/Graphics/je_canvas.h
@@ -1,7 +1,7 @@
#ifndef __JE_CANVAS_H
#define __JE_CANVAS_H
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_RENDER
+#if defined(jin_graphics)
#include "je_drawable.h"
@@ -63,6 +63,6 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif // LIBJIN_MODULES_RENDER
+#endif // defined(jin_graphics)
#endif // __JE_CANVAS_H \ No newline at end of file
diff --git a/src/libjin/Graphics/je_drawable.cpp b/src/libjin/Graphics/je_drawable.cpp
index af9e4d8..7480a32 100644
--- a/src/libjin/Graphics/je_drawable.cpp
+++ b/src/libjin/Graphics/je_drawable.cpp
@@ -1,5 +1,5 @@
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_RENDER
+#if defined(jin_graphics)
#include <stdlib.h>
@@ -122,4 +122,4 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif // LIBJIN_MODULES_RENDER \ No newline at end of file
+#endif // defined(jin_graphics) \ No newline at end of file
diff --git a/src/libjin/Graphics/je_drawable.h b/src/libjin/Graphics/je_drawable.h
index 1b739cb..fdf9ea2 100644
--- a/src/libjin/Graphics/je_drawable.h
+++ b/src/libjin/Graphics/je_drawable.h
@@ -1,7 +1,7 @@
#ifndef __JE_DRAWABLE
#define __JE_DRAWABLE
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_RENDER
+#if defined(jin_graphics)
#include "../math/je_quad.h"
#include "../math/je_vector2.hpp"
@@ -84,6 +84,6 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif // LIBJIN_MODULES_RENDER
+#endif // defined(jin_graphics)
#endif // __JE_DRAWABLE \ No newline at end of file
diff --git a/src/libjin/Graphics/je_gl.h b/src/libjin/Graphics/je_gl.h
index 846b90a..cda8bf9 100644
--- a/src/libjin/Graphics/je_gl.h
+++ b/src/libjin/Graphics/je_gl.h
@@ -37,4 +37,4 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif \ No newline at end of file
+#endif // __JE_OPENGL_H \ No newline at end of file
diff --git a/src/libjin/Graphics/je_graphics.h b/src/libjin/Graphics/je_graphics.h
index 8c964c3..2ba003d 100644
--- a/src/libjin/Graphics/je_graphics.h
+++ b/src/libjin/Graphics/je_graphics.h
@@ -1,7 +1,7 @@
#ifndef __JE_GRAPHICS_H
#define __JE_GRAPHICS_H
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_RENDER
+#if defined(jin_graphics)
#include "je_canvas.h"
#include "je_color.h"
@@ -17,5 +17,5 @@
#include "font/je_text.h"
#include "font/je_texture_font.h"
-#endif // LIBJIN_MODULES_RENDER
+#endif // defined(jin_graphics)
#endif // __JE_GRAPHICS_H \ No newline at end of file
diff --git a/src/libjin/Graphics/je_shapes.cpp b/src/libjin/Graphics/je_shapes.cpp
index 5a6dee8..3146f31 100644
--- a/src/libjin/Graphics/je_shapes.cpp
+++ b/src/libjin/Graphics/je_shapes.cpp
@@ -1,5 +1,5 @@
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_RENDER
+#if defined(jin_graphics)
#include <string>
@@ -125,4 +125,4 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif // LIBJIN_MODULES_RENDER \ No newline at end of file
+#endif // defined(jin_graphics) \ No newline at end of file
diff --git a/src/libjin/Graphics/je_texture.cpp b/src/libjin/Graphics/je_texture.cpp
index da56047..d191c8b 100644
--- a/src/libjin/Graphics/je_texture.cpp
+++ b/src/libjin/Graphics/je_texture.cpp
@@ -1,5 +1,5 @@
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_RENDER
+#if defined(jin_graphics)
#include <fstream>
@@ -8,12 +8,20 @@
#include "je_texture.h"
+using namespace JinEngine::Math;
+
namespace JinEngine
{
namespace Graphics
{
- using namespace JinEngine::Math;
+ Texture* Texture::createTexture(const char* path)
+ {
+ Bitmap* bitmap = Bitmap::createBitmap(path);
+ Texture* texture = createTexture(bitmap);
+ delete bitmap;
+ return texture;
+ }
/*static*/ Texture* Texture::createTexture(Bitmap* bitmap)
{
@@ -33,4 +41,4 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif // LIBJIN_MODULES_RENDER \ No newline at end of file
+#endif // defined(jin_graphics) \ No newline at end of file
diff --git a/src/libjin/Graphics/je_texture.h b/src/libjin/Graphics/je_texture.h
index e5c9cff..5238aa1 100644
--- a/src/libjin/Graphics/je_texture.h
+++ b/src/libjin/Graphics/je_texture.h
@@ -13,6 +13,7 @@ namespace JinEngine
{
namespace Graphics
{
+
///
///
///
@@ -22,7 +23,17 @@ namespace JinEngine
///
///
///
- static Texture* createTexture(Bitmap* bitmap);
+ static Texture* createTexture(const char* path);
+
+ ///
+ ///
+ ///
+ static Texture* createTexture(Bitmap* bitmap);
+
+ ///
+ ///
+ ///
+ static Texture* createTexture();
///
///
diff --git a/src/libjin/Graphics/je_window.cpp b/src/libjin/Graphics/je_window.cpp
index 163aa36..8c36c85 100644
--- a/src/libjin/Graphics/je_window.cpp
+++ b/src/libjin/Graphics/je_window.cpp
@@ -1,5 +1,5 @@
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_RENDER
+#if defined(jin_graphics)
#include <iostream>
@@ -19,7 +19,7 @@ namespace JinEngine
bool Window::initSystem(const SettingBase* s)
{
- #if LIBJIN_DEBUG
+ #if defined(jin_debug)
Loghelper::log(Loglevel::LV_INFO, "Init window system");
#endif
@@ -108,4 +108,4 @@ namespace JinEngine
} // namespace Graphics
} // namespace JinEngine
-#endif // LIBJIN_MODULES_RENDER \ No newline at end of file
+#endif // defined(jin_graphics) \ No newline at end of file
diff --git a/src/libjin/Input/je_event.h b/src/libjin/Input/je_event.h
index 2e87dc9..126d0f6 100644
--- a/src/libjin/Input/je_event.h
+++ b/src/libjin/Input/je_event.h
@@ -1,13 +1,13 @@
#ifndef __JE_EVENT_H
#define __JE_EVENT_H
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_INPUT
+#if defined(jin_input)
namespace JinEngine
{
namespace Input
{
- #if LIBJIN_INPUT_SDL
+ #if jin_input == jin_input_sdl
#include "SDL.h"
typedef SDL_Event Event;
@@ -112,10 +112,10 @@ namespace JinEngine
}
*/
- #endif // LIBJIN_INPUT_SDL
+ #endif // jin_input == jin_input_sdl
} // namespace Input
} // namespace JinEngine
-#endif // LIBJIN_MODULES_INPUT
+#endif // defined(jin_input)
#endif // __JE_EVENT_H \ No newline at end of file
diff --git a/src/libjin/Input/je_mouse.cpp b/src/libjin/Input/je_mouse.cpp
index 45fb8df..476b1a2 100644
--- a/src/libjin/Input/je_mouse.cpp
+++ b/src/libjin/Input/je_mouse.cpp
@@ -1,5 +1,5 @@
#include "../core/je_configuration.h"
-#ifdef LIBJIN_MODULES_INPUT
+#if defined(jin_input)
#include "SDL.h"
@@ -12,9 +12,9 @@ namespace JinEngine
void Mouse::getState(int* x, int* y)
{
- #ifdef LIBJIN_INPUT_SDL
+ #ifdef jin_input == jin_input_sdl
SDL_GetMouseState(x, y);
- #endif // LIBJIN_INPUT_SDL
+ #endif
}
void Mouse::setVisible(bool visible)
@@ -25,4 +25,4 @@ namespace JinEngine
} // namespace Input
} // namespace JinEngine
-#endif // LIBJIN_MODULES_INPUT \ No newline at end of file
+#endif // defined(jin_input) \ No newline at end of file
diff --git a/src/libjin/Input/je_mouse.h b/src/libjin/Input/je_mouse.h
index bd25e9c..29038ec 100644
--- a/src/libjin/Input/je_mouse.h
+++ b/src/libjin/Input/je_mouse.h
@@ -1,7 +1,7 @@
#ifndef __JE_MOUSE_H
#define __JE_MOUSE_H
#include "../core/je_configuration.h"
-#ifdef LIBJIN_MODULES_INPUT
+#if defined(jin_input)
#include "../common/je_singleton.hpp"
@@ -44,6 +44,6 @@ namespace JinEngine
} // namespace Input
} // namespace JinEngine
-#endif // LIBJIN_MODULES_INPUT
+#endif // defined(jin_input)
#endif // __JE_MOUSE_H \ No newline at end of file
diff --git a/src/libjin/Net/je_net_manager.cpp b/src/libjin/Net/je_net_manager.cpp
index 36021f1..c4f822e 100644
--- a/src/libjin/Net/je_net_manager.cpp
+++ b/src/libjin/Net/je_net_manager.cpp
@@ -8,7 +8,7 @@ namespace JinEngine
bool NetManager::initSystem(const SettingBase* setting)
{
#ifdef _WIN32
- #if LIBJIN_NET_TEKCOS
+ #if jin_net == jin_net_tekcos
tk_init();
#endif
#endif
diff --git a/src/libjin/Net/je_net_manager.h b/src/libjin/Net/je_net_manager.h
index 05c3fe3..8f72b73 100644
--- a/src/libjin/Net/je_net_manager.h
+++ b/src/libjin/Net/je_net_manager.h
@@ -1,7 +1,7 @@
#ifndef __JE_NET_H
#define __JE_NET_H
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_NET
+#if defined(jin_net)
#include "../common/je_subsystem.hpp"
@@ -45,6 +45,6 @@ namespace JinEngine
} // namespace Net
} // namespace JinEngine
-#endif // LIBJIN_MODULES_NET
+#endif // defined(jin_net)
#endif // __JE_NET_H \ No newline at end of file
diff --git a/src/libjin/Net/je_socket.cpp b/src/libjin/Net/je_socket.cpp
index 0137df2..1810601 100644
--- a/src/libjin/Net/je_socket.cpp
+++ b/src/libjin/Net/je_socket.cpp
@@ -5,90 +5,90 @@ namespace JinEngine
namespace Net
{
Socket::Socket(const Socket& socket)
- : handle(socket.handle)
- , type(socket.type)
+ : mHandle(socket.mHandle)
+ , mType(socket.mType)
{
}
Socket::Socket(const SocketInformation& info)
- : type(info.type)
+ : mType(info.type)
{
- if (type == SocketType::TCP)
+ if (mType == SocketType::TCP)
{
tk_IPaddress ip;
ip.host = info.address;
ip.port = info.port;
- handle.tcpHandle = tk_tcp_open(ip);
+ mHandle.tcpHandle = tk_tcp_open(ip);
}
- else if (type == SocketType::UDP)
+ else if (mType == SocketType::UDP)
{
- handle.udpHandle = tk_udp_open(info.port);
+ mHandle.udpHandle = tk_udp_open(info.port);
}
}
Socket::Socket(SocketType type, const char* address, unsigned short port)
{
- this->type = type;
- if (type == SocketType::TCP)
+ mType = type;
+ if (mType == SocketType::TCP)
{
tk_IPaddress ip;
- #if LIBJIN_NET_TEKCOS
+ #if jin_net == jin_net_tekcos
ip.host = tk_strtohl(address);
ip.port = port;
- handle.tcpHandle = tk_tcp_open(ip);
+ mHandle.tcpHandle = tk_tcp_open(ip);
#endif
}
- else if (type == SocketType::UDP)
+ else if (mType == SocketType::UDP)
{
- handle.udpHandle = tk_udp_open(port);
+ mHandle.udpHandle = tk_udp_open(port);
}
}
Socket::Socket(SocketType type, unsigned int address, unsigned short port)
{
- this->type = type;
- if (type == SocketType::TCP)
+ mType = type;
+ if (mType == SocketType::TCP)
{
tk_IPaddress ip;
ip.host = address;
ip.port = port;
- handle.tcpHandle = tk_tcp_open(ip);
+ mHandle.tcpHandle = tk_tcp_open(ip);
}
- else if (type == SocketType::UDP)
+ else if (mType == SocketType::UDP)
{
- handle.udpHandle = tk_udp_open(port);
+ mHandle.udpHandle = tk_udp_open(port);
}
}
Socket::Socket(SocketType type, unsigned short port)
{
- this->type = type;
- if (type == SocketType::TCP)
+ mType = type;
+ if (mType == SocketType::TCP)
{
tk_IPaddress ip;
ip.host = 0;
ip.port = port;
- handle.tcpHandle = tk_tcp_open(ip);
+ mHandle.tcpHandle = tk_tcp_open(ip);
}
- else if (type == SocketType::UDP)
+ else if (mType == SocketType::UDP)
{
- handle.udpHandle = tk_udp_open(port);
+ mHandle.udpHandle = tk_udp_open(port);
}
}
- #if LIBJIN_NET_TEKCOS
+ #if jin_net == jin_net_tekcos
Socket::Socket(const tk_TCPsocket& tcphandle)
{
- handle.tcpHandle = tcphandle;
+ mHandle.tcpHandle = tcphandle;
}
Socket::Socket(const tk_UDPsocket& udphandle)
{
- handle.udpHandle = udphandle;
+ mHandle.udpHandle = udphandle;
}
- #endif // LIBJIN_NET_TEKCOS
+ #endif // jin_net == jin_net_tekcos
Socket::~Socket()
{
@@ -96,23 +96,23 @@ namespace JinEngine
void Socket::configureBlocking(bool blocking)
{
- if (type != SocketType::TCP)
+ if (mType != SocketType::TCP)
return;
- #if LIBJIN_NET_TEKCOS
+ #if jin_net == jin_net_tekcos
if (blocking)
- tk_tcp_blocking(&handle.tcpHandle);
+ tk_tcp_blocking(&mHandle.tcpHandle);
else
- tk_tcp_nonblocking(&handle.tcpHandle);
+ tk_tcp_nonblocking(&mHandle.tcpHandle);
#endif
}
Socket* Socket::accept()
{
- if (type != SocketType::TCP)
+ if (mType != SocketType::TCP)
return nullptr;
Socket* client;
- #if LIBJIN_NET_TEKCOS
- tk_TCPsocket socket = tk_tcp_accept(&handle.tcpHandle);
+ #if jin_net == jin_net_tekcos
+ tk_TCPsocket socket = tk_tcp_accept(&mHandle.tcpHandle);
client = new Socket(socket);
#endif
return client;
@@ -120,68 +120,68 @@ namespace JinEngine
int Socket::receive(char* buffer, int size)
{
- if (type != SocketType::TCP)
+ if (mType != SocketType::TCP)
return 0;
- #if LIBJIN_NET_TEKCOS
+ #if jin_net == jin_net_tekcos
int len;
- tk_tcp_recv(&handle.tcpHandle, buffer, size, &len);
+ tk_tcp_recv(&mHandle.tcpHandle, buffer, size, &len);
return len;
#endif
}
int Socket::send(char* buffer, int size)
{
- if (type != SocketType::TCP)
+ if (mType != SocketType::TCP)
return 0;
- #if LIBJIN_NET_TEKCOS
+ #if jin_net == jin_net_tekcos
int len;
- tk_tcp_send(&handle.tcpHandle, buffer, size, &len);
+ tk_tcp_send(&mHandle.tcpHandle, buffer, size, &len);
return len;
#endif
}
void Socket::sendTo(char* buffer, int size, unsigned int address, unsigned int port)
{
- if (type != SocketType::UDP)
+ if (mType != SocketType::UDP)
return;
- #if LIBJIN_NET_TEKCOS
+ #if jin_net == jin_net_tekcos
tk_UDPpack pack;
pack.data = buffer;
pack.len = size;
pack.ip.host = address;
pack.ip.port = port;
- tk_udp_sendto(&handle.udpHandle, &pack);
+ tk_udp_sendto(&mHandle.udpHandle, &pack);
#endif
}
int Socket::receiveFrom(char* buffer, int size, unsigned int address, unsigned int port)
{
- if (type != SocketType::UDP)
+ if (mType != SocketType::UDP)
return 0;
int len;
- #if LIBJIN_NET_TEKCOS
+ #if jin_net == jin_net_tekcos
tk_UDPpack pack;
pack.data = buffer;
pack.len = size;
pack.ip.host = address;
pack.ip.port = port;
- tk_udp_recvfrom(&handle.udpHandle, &pack);
+ tk_udp_recvfrom(&mHandle.udpHandle, &pack);
return pack.len;
#endif
}
void Socket::close()
{
- if (type == SocketType::TCP)
+ if (mType == SocketType::TCP)
{
- #if LIBJIN_NET_TEKCOS
- tk_tcp_close(&handle.tcpHandle);
+ #if jin_net == jin_net_tekcos
+ tk_tcp_close(&mHandle.tcpHandle);
#endif
}
- else if (type == SocketType::UDP)
+ else if (mType == SocketType::UDP)
{
- #if LIBJIN_NET_TEKCOS
- tk_udp_close(&handle.udpHandle);
+ #if jin_net == jin_net_tekcos
+ tk_udp_close(&mHandle.udpHandle);
#endif
}
}
diff --git a/src/libjin/Net/je_socket.h b/src/libjin/Net/je_socket.h
index cfe904f..d496fcb 100644
--- a/src/libjin/Net/je_socket.h
+++ b/src/libjin/Net/je_socket.h
@@ -1,7 +1,7 @@
#ifndef __JE_NET_SOCKET_H
#define __JE_NET_SOCKET_H
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_NET
+#if defined(jin_net)
#include "../3rdparty/tekcos/tekcos.h"
@@ -107,7 +107,7 @@ namespace JinEngine
void close();
protected:
- #if LIBJIN_NET_TEKCOS
+ #if jin_net == jin_net_tekcos
///
///
@@ -126,19 +126,19 @@ namespace JinEngine
{
tk_TCPsocket tcpHandle;
tk_UDPsocket udpHandle;
- } handle;
+ } mHandle;
#endif
///
///
///
- SocketType type;
+ SocketType mType;
};
} // namespace Net
} // namespace JinEngine
-#endif // LIBJIN_MODULES_NET
+#endif // defined(jin_net)
#endif // __JE_NET_SOCKET_H \ No newline at end of file
diff --git a/src/libjin/Time/je_timer.cpp b/src/libjin/Time/je_timer.cpp
index 6e8350b..a2f2486 100644
--- a/src/libjin/Time/je_timer.cpp
+++ b/src/libjin/Time/je_timer.cpp
@@ -1,5 +1,5 @@
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_TIME
+#if defined(jin_time)
#include "je_timer.h"
@@ -97,4 +97,4 @@ namespace JinEngine
} // namespace Time
} // namespace JinEngine
-#endif // LIBJIN_MODULES_TIME
+#endif // defined(jin_time)
diff --git a/src/libjin/Time/je_timer.h b/src/libjin/Time/je_timer.h
index 82b4b52..b6b4b9e 100644
--- a/src/libjin/Time/je_timer.h
+++ b/src/libjin/Time/je_timer.h
@@ -1,7 +1,7 @@
#ifndef __JE_TIMER_H
#define __JE_TIMER_H
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_TIME
+#if defined(jin_time)
#include <vector>
#include "SDL2/SDL.h"
@@ -84,7 +84,7 @@ namespace JinEngine
///
inline void sleep(int ms)
{
- #if LIBJIN_TIME_SDL
+ #if jin_time == jin_time_sdl
SDL_Delay(ms);
#endif
}
@@ -94,7 +94,7 @@ namespace JinEngine
///
inline double getSecond()
{
- #if LIBJIN_TIME_SDL
+ #if jin_time == jin_time_sdl
return SDL_GetTicks() / 1000.f;
#endif
}
@@ -104,7 +104,7 @@ namespace JinEngine
///
inline double getMilliSecond()
{
- #if LIBJIN_TIME_SDL
+ #if jin_time == jin_time_sdl
return SDL_GetTicks();
#endif
}
@@ -112,6 +112,6 @@ namespace JinEngine
} // namespace Time
} // namespace JinEngine
-#endif // LIBJIN_MODULES_TIME
+#endif // defined(jin_time)
#endif // __JE_TIMER_H \ No newline at end of file
diff --git a/src/libjin/Utils/je_endian.h b/src/libjin/Utils/je_endian.h
index 01def88..db8c8fd 100644
--- a/src/libjin/Utils/je_endian.h
+++ b/src/libjin/Utils/je_endian.h
@@ -1,23 +1,23 @@
-#ifndef LIBJIN_LIL_ENDIAN && LIBJIN_BIG_ENDIAN
+#ifndef jin_endian_lil && jin_endian_big
-#define LIBJIN_LIL_ENDIAN 2
-#define LIBJIN_BIG_ENDIAN 4
+#define jin_endian_lil 2
+#define jin_endian_big 4
#endif
-#ifndef LIBJIN_BYTEORDER
+#ifndef jin_byte_order
#ifdef __linux__
#include <endian.h>
-#define LIBJIN_BYTEORDER __BYTE_ORDER
+#define jin_byte_order __BYTE_ORDER
#else /* __linux__ */
#if defined(__hppa__) || \
defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
(defined(__MIPS__) && defined(__MISPEB__)) || \
defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \
defined(__sparc__)
-#define LIBJIN_BYTEORDER LIBJIN_BIG_ENDIAN
+#define jin_byte_order jin_endian_big
#else
-#define LIBJIN_BYTEORDER LIBJIN_LIL_ENDIAN
+#define jin_byte_order jin_endian_lil
#endif
#endif /* __linux__ */
#endif /* !SDL_BYTEORDER */ \ No newline at end of file
diff --git a/src/libjin/Utils/je_log.h b/src/libjin/Utils/je_log.h
index 8e4bf61..928a009 100644
--- a/src/libjin/Utils/je_log.h
+++ b/src/libjin/Utils/je_log.h
@@ -1,7 +1,3 @@
-/**
-* Single.h/loghelper.h
-* Copyright (C) 2017~2018 chai
-*/
#ifndef __LOG_HELPER_H
#define __LOG_HELPER_H
diff --git a/src/libjin/ai/je_behavior_tree.h b/src/libjin/ai/je_behavior_tree.h
index 0654849..6e276b6 100644
--- a/src/libjin/ai/je_behavior_tree.h
+++ b/src/libjin/ai/je_behavior_tree.h
@@ -1,6 +1,9 @@
#ifndef __JE_BEHAVIOR_TREE_H
#define __JE_BEHAVIOR_TREE_H
+#include "../core/je_configuration.h"
+#if defined(jin_ai)
+
namespace JinEngine
{
namespace AI
@@ -17,4 +20,6 @@ namespace JinEngine
}
}
+#endif // jin_ai
+
#endif \ No newline at end of file
diff --git a/src/libjin/ai/je_state_machine.h b/src/libjin/ai/je_state_machine.h
index 4e80da3..7869925 100644
--- a/src/libjin/ai/je_state_machine.h
+++ b/src/libjin/ai/je_state_machine.h
@@ -1,6 +1,9 @@
#ifndef __JE_STATEMACHINE_TREE_H
#define __JE_STATEMACHINE_TREE_H
+#include "../core/je_configuration.h"
+#if defined(jin_ai)
+
namespace JinEngine
{
namespace AI
@@ -17,4 +20,6 @@ namespace JinEngine
}
}
+#endif // jin_ai
+
#endif \ No newline at end of file
diff --git a/src/libjin/core/je_configuration.h b/src/libjin/core/je_configuration.h
index f70ae5a..167ffd0 100644
--- a/src/libjin/core/je_configuration.h
+++ b/src/libjin/core/je_configuration.h
@@ -1,72 +1,22 @@
#ifndef __JE_COMMON_MODULES_H
#define __JE_COMMON_MODULES_H
-/*
-* ģģı룬Ҫģرղ
-*/
-
-#define LIBJIN_MODULES_AUDIO 1
-#define LIBJIN_AUDIO_SDLAUDIO 1
-#define LIBJIN_AUDIO_OPENAL 1
-
-#define LIBJIN_MODULES_RENDER 1
-
-#define LIBJIN_MODULES_DEBUG 1
-
-#define LIBJIN_MODULES_FILESYSTEM 1
-
-#define LIBJIN_MODULES_INPUT 1
-#define LIBJIN_INPUT_SDL 1
-
-#define LIBJIN_MODULES_MATH 1
-
-#define LIBJIN_MODULES_NET 1
-#define LIBJIN_NET_TEKCOS 1
-
-#define LIBJIN_MODULES_PHYSICS 0
-#define LIBJIN_PHYSICS_BOX2D 1
-#define LIBJIN_PHYSICS_NEWTON 1
-
-#define LIBJIN_MODULES_TILEMAP 1
-
-#define LIBJIN_MODULES_UI 1
-
-#define LIBJIN_MODULES_TOOLS 0
-#define LIBJIN_TOOLS_COMPONENT 1
-#define LIBJIN_TOOLS_EVENTMSGCENTER 1
-#define LIBJIN_TOOLS_XML 1
-#define LIBJIN_TOOLS_CSV 1
-#define LIBJIN_TOOLS_JSON 1
-
-#define LIBJIN_MODULES_THREAD 1
-#define LIBJIN_THREAD_SDL 1
-#define LIBJIN_THREAD_CPP 0
-#define LIBJIN_THREAD_PTHREAD 0
-
-#define LIBJIN_MODULES_TIME 1
-#define LIBJIN_TIME_SDL 1
-
-/*
-* Open libjin debug
-*/
-
-#define LIBJIN_DEBUG 0
-
-/*
-* Operating system
-*/
-
-#define LIBJIN_WINDOWS 1
-#define LIBJIN_MACOS 2
-#define LIBJIN_LINUX 3
-
-#define LIBJIN_OS LIBJIN_WINDOWS
-
-/// ģ
-#define jin_graphics
-#define jin_graphics_font
-#define jin_graphics_shader
-
-#define jin_audio
+
+#define jin_debug
+
+#define jin_os_windows 0x01
+#define jin_os_mac 0x02
+#define jin_os_linux 0x03
+#define jin_os jin_os_windows
+
+#define jin_graphics_font 0x02
+#define jin_graphics_shader 0x04
+#define jin_graphics_particle 0x08
+#define jin_graphics_animation 0x10
+#define jin_graphics (jin_graphics_font|jin_graphics_shader)
+
+#define jin_audio_sdl 0x01
+#define jin_audio_openal 0x02
+#define jin_audio jin_audio_sdl
#define jin_filesystem
@@ -74,4 +24,29 @@
#define jin_core
-#endif \ No newline at end of file
+#define jin_filesystem
+
+#define jin_input_sdl 0x01
+#define jin_input jin_input_sdl
+
+#define jin_math
+
+#define jin_net_tekcos 0x01
+#define jin_net jin_net_tekcos
+
+#define jin_physics_newton 0x01
+#define jin_physics_box2d 0x02
+//#define jin_physics jin_physics_newton
+
+#define jin_thread_sdl 0x01
+#define jin_thread_cpp 0x02
+#define jin_thread_pthread 0x03
+#define jin_thread jin_thread_sdl
+
+#define jin_time_sdl 0x01
+#define jin_time_cpp 0x02
+#define jin_time jin_time_sdl
+
+#define jin_ai
+
+#endif // __JE_COMMON_MODULES_H \ No newline at end of file
diff --git a/src/libjin/core/je_version.h b/src/libjin/core/je_version.h
index 6a91797..77302c6 100644
--- a/src/libjin/core/je_version.h
+++ b/src/libjin/core/je_version.h
@@ -11,16 +11,42 @@ namespace JinEngine
///
/// @return Version of Jin.
///
- int getVersion();
+ const char* getVersion()
+ {
+ return "Jin 0.1";
+ }
///
/// Get author of Jin.
///
/// @return Author of Jin.
///
- int getAuthor();
+ const char* getAuthor()
+ {
+ return "Chai";
+ }
+
+ ///
+ /// Get release of Jin.
+ ///
+ /// @return release string of Jin.
+ ///
+ const char* getRelease()
+ {
+ return "Jin 0.1.1";
+ }
+
+ ///
+ /// Get release of Jin.
+ ///
+ /// @return Revision of Jin.
+ ///
+ int getRevision()
+ {
+ return 101;
+ }
} // namespace Core
} // namespace JinEngine
-#endif \ No newline at end of file
+#endif // __JE_CORE_VERSION_H \ No newline at end of file
diff --git a/src/libjin/jin.h b/src/libjin/jin.h
index 53b61fb..b47a56d 100644
--- a/src/libjin/jin.h
+++ b/src/libjin/jin.h
@@ -4,9 +4,9 @@
#include "core/je_configuration.h"
#include "utils/je_utils.h"
-#ifdef LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO
-#include "audio/sdl/je_sdl_audio.h"
-#endif // LIBJIN_MODULES_AUDIO && LIBJIN_AUDIO_SDLAUDIO
+#if jin_audio == jin_audio_sdl
+ #include "audio/sdl/je_sdl_audio.h"
+#endif
#include "game/je_game.h"
#include "filesystem/je_asset_database.h"
#include "filesystem/je_buffer.h"
@@ -17,9 +17,4 @@
#include "multithread/je_thread.h"
#include "common/je_common.h"
-#define LIBJIN_VERSION "Jin 0.1";
-#define LIBJIN_AUTHOR "Chai";
-#define LIBJIN_RELEASE "Jin 0.1.1";
-#define LIBJIN_VERSION_NUM 101;
-
#endif // __JE_H \ No newline at end of file
diff --git a/src/libjin/multithread/je_thread.cpp b/src/libjin/multithread/je_thread.cpp
index 3c18657..0c528bf 100644
--- a/src/libjin/multithread/je_thread.cpp
+++ b/src/libjin/multithread/je_thread.cpp
@@ -1,5 +1,5 @@
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_THREAD
+#if defined(jin_thread)
#include "je_thread.h"
@@ -17,7 +17,7 @@ namespace JinEngine
void lock();
void unlock();
private:
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
SDL_mutex* mutex;
#endif
friend class Conditional;
@@ -33,7 +33,7 @@ namespace JinEngine
void broadcast();
bool wait(Mutex* mutex, int timeout = -1);
private:
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
SDL_cond* cond;
#endif
};
@@ -63,28 +63,28 @@ namespace JinEngine
Mutex::Mutex()
{
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
mutex = SDL_CreateMutex();
#endif
}
Mutex::~Mutex()
{
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
SDL_DestroyMutex(mutex);
#endif
}
void Mutex::lock()
{
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
SDL_LockMutex(mutex);
#endif
}
void Mutex::unlock()
{
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
SDL_UnlockMutex(mutex);
#endif
}
@@ -93,35 +93,35 @@ namespace JinEngine
Conditional::Conditional()
{
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
cond = SDL_CreateCond();
#endif
}
Conditional::~Conditional()
{
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
SDL_DestroyCond(cond);
#endif
}
void Conditional::signal()
{
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
SDL_CondSignal(cond);
#endif
}
void Conditional::broadcast()
{
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
SDL_CondBroadcast(cond);
#endif
}
bool Conditional::wait(Mutex* mutex, int timeout)
{
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
if (timeout < 0)
return !SDL_CondWait(cond, mutex->mutex);
else
@@ -183,7 +183,7 @@ namespace JinEngine
Thread::~Thread()
{
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
#endif
}
@@ -206,13 +206,13 @@ namespace JinEngine
return false;
if (handle)
{
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
SDL_WaitThread(handle, nullptr);
#endif
}
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
handle = SDL_CreateThread(threadRunner, name.c_str(), p);
- #elif LIBJIN_THREAD_CPP
+ #elif jin_thread == jin_thread_cpp
handle = new std::thread();
#endif
return (running = (handle != nullptr));
@@ -225,7 +225,7 @@ namespace JinEngine
if (!handle)
return;
}
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
SDL_WaitThread(handle, nullptr);
#endif
Lock l(mutex);
@@ -298,4 +298,4 @@ namespace JinEngine
} // namespace MultiThread
} // namespace JinEngine
-#endif // LIBJIN_MODULES_THREAD \ No newline at end of file
+#endif // defined(jin_thread) \ No newline at end of file
diff --git a/src/libjin/multithread/je_thread.h b/src/libjin/multithread/je_thread.h
index b3a3e2e..353690c 100644
--- a/src/libjin/multithread/je_thread.h
+++ b/src/libjin/multithread/je_thread.h
@@ -1,13 +1,13 @@
#ifndef __JE_THREAD_H
#define __JE_THREAD_H
#include "../core/je_configuration.h"
-#if LIBJIN_MODULES_THREAD
+#if defined(jin_thread)
#include <string>
#include <map>
-#if LIBJIN_THREAD_SDL
+#if jin_thread == jin_thread_sdl
#include "SDL2/SDL_thread.h"
-#elif LIBJIN_THREAD_CPP
+#elif jin_thread == jin_thread_cpp
#include <thread>
#include <mutex>
#include <condition_variable>
@@ -116,9 +116,9 @@ namespace JinEngine
void unlock();
protected:
- #if LIBJIN_THREAD_SDL
+ #if jin_thread == jin_thread_sdl
SDL_Thread* handle; // SDL thread
- #elif LIBJIN_THREAD_CPP
+ #elif jin_thread == jin_thread_cpp
std::thread* handle; // cpp thread
#endif
Mutex* mutex; // mutex variable
@@ -162,6 +162,6 @@ namespace JinEngine
} // namespace MultiThread
} // namespace JinEngine
-#endif // LIBJIN_MODULES_THREAD
+#endif // defined(jin_thread)
#endif // __JE_THREAD_H \ No newline at end of file
diff --git a/src/lua/embed/boot.lua.h b/src/lua/embed/boot.lua.h
index f41ba3b..055a653 100644
--- a/src/lua/embed/boot.lua.h
+++ b/src/lua/embed/boot.lua.h
@@ -138,27 +138,29 @@ jin.nogame = {
-------------------------------------------------------------------------
local function onError(msg)
- local tab = ' '
print("Error:\n" .. msg)
function jin.core.onEvent(e)
- if e.type == 'quit' then
+ if e.type == "Quit" then
jin.core.stop()
end
end
- local ww, wh = jin.graphics.getSize()
function jin.core.onDraw()
- jin.graphics.write("Error: ", 10, 10, 30, 3, 30)
- jin.graphics.write(msg, 10, 50)
+ jin.graphics.unsetFont()
+ jin.graphics.print("Error:\n" .. msg .. "\n" .. debug.traceback(), 5, 5)
end
+ jin.graphics.setClearColor(100, 100, 100, 255)
+ jin.core.onLoad = nil
+ jin.core.run()
+ jin.core.quit()
end
local function boot()
if jin.filesystem.exist("main.lua") then
- -- require main game script
+ -- Require main game script
xpcall(function() require"main" end, onError)
- jin.core.run()
+ xpcall(function() jin.core.run() end, onError)
else
- -- no game
+ -- No game
jin.core.setHandler(jin.nogame)
jin.core.run()
end
@@ -169,4 +171,4 @@ end
xpcall(boot, onError)
-)";
+)"; \ No newline at end of file
diff --git a/src/lua/modules/graphics/graphics.cpp b/src/lua/modules/graphics/graphics.cpp
index 4ff0dfc..5ba8c13 100644
--- a/src/lua/modules/graphics/graphics.cpp
+++ b/src/lua/modules/graphics/graphics.cpp
@@ -125,25 +125,13 @@ namespace JinEngine
error(L, "No such image file %s", f);
goto fail;
}
- Buffer b = {};
+ Buffer b;
if (!fs->read(f, b))
{
error(L, "Failed to read image %s", f);
goto fail;
}
bitmap = Bitmap::createBitmap(&b, b.size());
- //const Color* col = bitmap->getPixels();
- //ofstream o = ofstream("img.txt", ios_base::app);
- //for (int i = 0; i < bitmap->getWidth() * bitmap->getHeight(); ++i)
- //{
- // Color c = col[i];
- // o << (int)c.r << ',';
- // o << (int)c.g << ',';
- // o << (int)c.b << ',';
- // o << (int)c.a << ',';
- // if ((i + 1) % 10 == 0)
- // o << endl;
- //}
if (bitmap == nullptr)
{
error(L, "Failed to decode image file %s", f);
@@ -161,12 +149,21 @@ namespace JinEngine
/* jin.graphics.newTexture(bitmap) */
static int l_newTexture(lua_State* L)
{
- Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_BITMAP);
- Ref<Bitmap>& refBitmap = p->getRef<Bitmap>();
- Bitmap* bitmap = refBitmap.getObject();
+ Texture* texture = nullptr;
+ if (luax_istype(L, 1, JIN_GRAPHICS_BITMAP))
+ {
+ Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_BITMAP);
+ Ref<Bitmap>& refBitmap = p->getRef<Bitmap>();
+ Bitmap* bitmap = refBitmap.getObject();
+ texture = Texture::createTexture(bitmap);
+ }
+ else if (luax_isstring(L, 1))
+ {
+ const char* path = luax_checkstring(L, 1);
+ texture = Texture::createTexture(path);
+ }
Proxy* proxy = (Proxy*)luax_newinstance(L, JIN_GRAPHICS_TEXTURE, sizeof(Proxy));
- Texture* tex = Texture::createTexture(bitmap);
- proxy->bind(new Ref<Texture>(tex, JIN_GRAPHICS_TEXTURE));
+ proxy->bind(new Ref<Texture>(texture, JIN_GRAPHICS_TEXTURE));
return 1;
}