aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/script')
-rw-r--r--src/script/embed/boot.lua.h26
-rw-r--r--src/script/graphics/luaopen_graphics.cpp23
2 files changed, 22 insertions, 27 deletions
diff --git a/src/script/embed/boot.lua.h b/src/script/embed/boot.lua.h
index 822e1cf..ee1cbd3 100644
--- a/src/script/embed/boot.lua.h
+++ b/src/script/embed/boot.lua.h
@@ -26,14 +26,15 @@ jin.filesystem.mount(jin._argv[2])
local conf = {}
if jin.filesystem.exist("config.lua") then
conf = require "config"
-end
-conf.width = conf.width or 600
+end
+conf.width = conf.width or 600
conf.height = conf.height or 500
-conf.fps = conf.fps or 60
-conf.title = conf.title or ("jin v" .. jin.version())
+conf.fps = conf.fps or 60
+conf.vsync = conf.vsync or false
+conf.title = conf.title or ("jin v" .. jin.version())
--- init video subsystem
-jin.graphics.init(conf.width,conf.height,conf.title)
+-- init video subsystem
+jin.graphics.init(conf)
-- open debug mode, must after jin.graphics.init
if jin._argv[3] == '-d' then
@@ -54,13 +55,18 @@ function jin.core.run()
local onUpdate = jin.core.onUpdate
local present = jin.graphics.present
+ local dstatus = jin.debug.status
+ local drender = jin.debug.render
+
+ local fps = conf.fps
+
if load then
load()
end
local now = second()
local last = now
- local fsec = 1/conf.fps
+ local fsec = 1/fps
local dt = 0
while(running()) do
@@ -71,7 +77,7 @@ function jin.core.run()
sleep(fsec - now + last)
end
- -- handle events
+ -- handle events
for _, e in pairs(poll()) do
if _onEvent then
_onEvent(e)
@@ -99,8 +105,8 @@ function jin.core.run()
end
-- render debug window
- if jin.debug.status() then
- jin.debug.render()
+ if dstatus() then
+ drender()
end
-- swap window buffer
diff --git a/src/script/graphics/luaopen_graphics.cpp b/src/script/graphics/luaopen_graphics.cpp
index 0d240fe..50b1921 100644
--- a/src/script/graphics/luaopen_graphics.cpp
+++ b/src/script/graphics/luaopen_graphics.cpp
@@ -18,13 +18,10 @@ namespace lua
*/
static struct
{
- // current render color
color curRenderColor;
- // currently used font
Font* curFont = 0;
- // default ingame font
Font* defaultFont = 0;
} context;
@@ -35,21 +32,13 @@ namespace lua
*/
static int l_init(lua_State* L)
{
- int w = luax_checknumber(L, 1);
- int h = luax_checknumber(L, 2);
- const char* t = luaL_checkstring(L, 3);
-
- // init video subsystem
- if (SDL_Init(SDL_INIT_VIDEO) < 0)
- {
- luax_error(L, "could not init video");
- luax_pushboolean(L, false);
- return 1;
- }
-
- // init window system
Window* wnd = Window::get();
- wnd->init(w, h, t);
+ Window::Setting setting;
+ setting.width = luax_getfield_integer(L, 1, "width");
+ setting.height = luax_getfield_integer(L, 1, "height");
+ setting.title = luax_getfield_string(L, 1, "title");
+ setting.vsync = luax_getfield_bool(L, 1, "vsync");
+ wnd->init(setting);
// set default blend method
glEnable(GL_BLEND);