aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-12-07 08:46:17 +0800
committerchai <chaifix@163.com>2018-12-07 08:46:17 +0800
commitb4bd76b8b02996767798b76cc65dee9ea27f1167 (patch)
treed20e1b31032b4908b95b2e0d0612ae1ad18d19ee /src
parentafc5ebdeece428d4ef72f4f1f4b178a92d1b9cba (diff)
*misc
Diffstat (limited to 'src')
-rw-r--r--src/jin/main.cpp2
-rw-r--r--src/libjin/graphics/je_window.cpp5
-rw-r--r--src/lua/embed/embed.h26
-rw-r--r--src/lua/jin.cpp3
-rw-r--r--src/lua/modules/graphics/je_lua_graphics.cpp2
5 files changed, 22 insertions, 16 deletions
diff --git a/src/jin/main.cpp b/src/jin/main.cpp
index f76bda7..e2f5763 100644
--- a/src/jin/main.cpp
+++ b/src/jin/main.cpp
@@ -17,7 +17,7 @@ using namespace JinEngine::Filesystem;
// Load game under cwd.
static void load(const char* cwd)
{
- // Global lua runtime.
+ // Main thread lua runtime.
lua_State* L = luax_newstate();
// Open lua standard module.
diff --git a/src/libjin/graphics/je_window.cpp b/src/libjin/graphics/je_window.cpp
index 148f1b9..e7cdf06 100644
--- a/src/libjin/graphics/je_window.cpp
+++ b/src/libjin/graphics/je_window.cpp
@@ -68,7 +68,7 @@ namespace JinEngine
if (mWnd == NULL)
return false;
- // Set window icon
+ // Set window icon.
try
{
Bitmap* bitmap = new Bitmap(icon);
@@ -97,9 +97,6 @@ namespace JinEngine
// Bind to default canvas.
gl.unbindCanvas();
gl.unuseShader();
- //Shader::unuse();
- // Avoid white blinnk.
- swapBuffers();
return true;
}
diff --git a/src/lua/embed/embed.h b/src/lua/embed/embed.h
index a063e65..4b1c6d9 100644
--- a/src/lua/embed/embed.h
+++ b/src/lua/embed/embed.h
@@ -14,30 +14,38 @@ namespace JinEngine
};
// Embed scripts.
-#include "scripts/graphics.lua.h"
-#include "scripts/keyboard.lua.h"
-#include "scripts/mouse.lua.h"
-#include "scripts/boot.lua.h"
+ #include "scripts/graphics.lua.h"
+ #include "scripts/keyboard.lua.h"
+ #include "scripts/mouse.lua.h"
+ #include "scripts/boot.lua.h"
// In order.
- static const jin_Embed scripts[] = {
+ static const jin_Embed modules[] = {
{ "graphics.lua", graphics_lua },
{ "keyboard.lua", keyboard_lua },
{ "mouse.lua", mouse_lua },
- { "boot.lua", boot_lua },
{ 0, 0 }
};
- static void boot(lua_State* L)
+ static const jin_Embed boot_script = { "boot", boot_lua };
+
+ static void load(lua_State* L)
{
- for (int i = 0; scripts[i].file; ++i)
+ for (int i = 0; modules[i].file; ++i)
{
- const char* file = scripts[i].file, *source = scripts[i].source;
+ const char* file = modules[i].file, *source = modules[i].source;
if (luax_loadbuffer(L, source, strlen(source), file) == 0)
lua_call(L, 0, 0);
}
}
+ static void run(lua_State* L)
+ {
+ const char* file = boot_script.file, *source = boot_script.source;
+ if (luax_loadbuffer(L, source, strlen(source), file) == 0)
+ lua_call(L, 0, 0);
+ }
+
} // namespace Embed
} // namespace JinEngine
diff --git a/src/lua/jin.cpp b/src/lua/jin.cpp
index b11488b..79a7bf8 100644
--- a/src/lua/jin.cpp
+++ b/src/lua/jin.cpp
@@ -95,8 +95,9 @@ namespace JinEngine
luax_newtable(L);
luax_setfieldstring(L, "cwd", cwd);
luax_setfield(L, -2, "args");
+ Embed::load(L);
luax_clearstack(L);
- JinEngine::Embed::boot(L);
+ Embed::run(L);
}
} // namespace Lua
diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp
index 8ace62c..981e30f 100644
--- a/src/lua/modules/graphics/je_lua_graphics.cpp
+++ b/src/lua/modules/graphics/je_lua_graphics.cpp
@@ -34,7 +34,7 @@ namespace JinEngine
namespace Lua
{
-#include "../../resources/font.ttf.h"
+ #include "../../resources/font.ttf.h"
static struct
{