From 8ad6a7f955182955aec1fff0ed367f564f31e46a Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 19 May 2018 09:15:28 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AA=97=E5=8F=A3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/script/embed/boot.lua.h | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/script/embed/boot.lua.h') 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 -- cgit v1.1-26-g67d0