aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/main.lua4
-rw-r--r--build/vs2015/jin.vcxproj4
-rw-r--r--src/libjin/Core/Game.cpp6
-rw-r--r--src/libjin/Core/Game.h2
-rw-r--r--src/libjin/core/game.cpp6
-rw-r--r--src/libjin/core/game.h2
-rw-r--r--src/libjin/modules.h12
-rw-r--r--src/lua/audio/luaopen_Source.cpp9
-rw-r--r--src/lua/embed/boot.lua.h65
-rw-r--r--src/lua/graphics/luaopen_Image.cpp2
-rw-r--r--src/lua/graphics/luaopen_graphics.cpp2
-rw-r--r--src/main.cpp4
12 files changed, 56 insertions, 62 deletions
diff --git a/bin/main.lua b/bin/main.lua
index d29d66b..6b3253f 100644
--- a/bin/main.lua
+++ b/bin/main.lua
@@ -110,13 +110,13 @@ local diffuse = jg.Image("treestump_diffuse.png")
local img = jg.Image("treestump.png")
local img2 = jg.Image("lightning.png")
local ww, wh = jg.size()
-local src = jin.audio.Source("a.wav")
+src = jin.audio.Source("a.ogg")
local scale = 2
ww = ww / scale
wh = wh / scale
src:play()
src:setLoop(true)
-src:setVolume(0.4)
+src:setVolume(1.0)
jin.core.onLoad = function()
jg.use(lightning)
lightning:send("vec2", "iResolution", ww, wh)
diff --git a/build/vs2015/jin.vcxproj b/build/vs2015/jin.vcxproj
index 1592cf6..19a3603 100644
--- a/build/vs2015/jin.vcxproj
+++ b/build/vs2015/jin.vcxproj
@@ -89,7 +89,7 @@
<Link>
<AdditionalDependencies>opengl32.lib;glu32.lib;SDL2main.lib;SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)libs\SDL2-2.0.5\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <SubSystem>Windows</SubSystem>
+ <SubSystem>Console</SubSystem>
<EntryPointSymbol>
</EntryPointSymbol>
</Link>
@@ -118,7 +118,7 @@
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>opengl32.lib;glu32.lib;SDL2main.lib;SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)libs\SDL2-2.0.5\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <SubSystem>Windows</SubSystem>
+ <SubSystem>Console</SubSystem>
<EntryPointSymbol>
</EntryPointSymbol>
</Link>
diff --git a/src/libjin/Core/Game.cpp b/src/libjin/Core/Game.cpp
index 929cc07..c5dd5a5 100644
--- a/src/libjin/Core/Game.cpp
+++ b/src/libjin/Core/Game.cpp
@@ -26,7 +26,7 @@ namespace core
_running = true;
Event e;
int previous = getMilliSecond();
- float dt = MS_PER_UPDATE / 1000.0f;
+ int dt = MS_PER_UPDATE;
while (_running)
{
while (jin::input::pollEvent(&e))
@@ -38,13 +38,13 @@ namespace core
SAFECALL(_onDraw);
wnd->swapBuffers();
const int current = getMilliSecond();
- dt = (current - previous) / 1000.0f;
+ dt = current - previous;
const int wait = MS_PER_UPDATE - (current - previous);
previous += MS_PER_UPDATE;
if (wait > 0)
{
sleep(wait);
- dt = MS_PER_UPDATE / 1000.0f;
+ dt = MS_PER_UPDATE;
}
else
previous = current;
diff --git a/src/libjin/Core/Game.h b/src/libjin/Core/Game.h
index 9359487..31f32d8 100644
--- a/src/libjin/Core/Game.h
+++ b/src/libjin/Core/Game.h
@@ -18,7 +18,7 @@ namespace core
typedef void(*onLoad)();
typedef void(*onEvent)(jin::input::Event* e);
- typedef void(*onUpdate)(float dt);
+ typedef void(*onUpdate)(int dt);
typedef void(*onDraw)();
struct Setting : SettingBase
diff --git a/src/libjin/core/game.cpp b/src/libjin/core/game.cpp
index 929cc07..c5dd5a5 100644
--- a/src/libjin/core/game.cpp
+++ b/src/libjin/core/game.cpp
@@ -26,7 +26,7 @@ namespace core
_running = true;
Event e;
int previous = getMilliSecond();
- float dt = MS_PER_UPDATE / 1000.0f;
+ int dt = MS_PER_UPDATE;
while (_running)
{
while (jin::input::pollEvent(&e))
@@ -38,13 +38,13 @@ namespace core
SAFECALL(_onDraw);
wnd->swapBuffers();
const int current = getMilliSecond();
- dt = (current - previous) / 1000.0f;
+ dt = current - previous;
const int wait = MS_PER_UPDATE - (current - previous);
previous += MS_PER_UPDATE;
if (wait > 0)
{
sleep(wait);
- dt = MS_PER_UPDATE / 1000.0f;
+ dt = MS_PER_UPDATE;
}
else
previous = current;
diff --git a/src/libjin/core/game.h b/src/libjin/core/game.h
index 9359487..31f32d8 100644
--- a/src/libjin/core/game.h
+++ b/src/libjin/core/game.h
@@ -18,7 +18,7 @@ namespace core
typedef void(*onLoad)();
typedef void(*onEvent)(jin::input::Event* e);
- typedef void(*onUpdate)(float dt);
+ typedef void(*onUpdate)(int dt);
typedef void(*onDraw)();
struct Setting : SettingBase
diff --git a/src/libjin/modules.h b/src/libjin/modules.h
index 2e8e36f..171c691 100644
--- a/src/libjin/modules.h
+++ b/src/libjin/modules.h
@@ -6,7 +6,7 @@
#define JIN_MODULES_AUDIO 1
#define JIN_AUDIO_SDLAUDIO 1
-#define JIN_AUDIO_OPENAL 0
+#define JIN_AUDIO_OPENAL 1
#define JIN_MODULES_RENDER 1
@@ -21,22 +21,22 @@
#define JIN_MODULES_NET 1
-#define JIN_MODULES_PHYSICS 0
+#define JIN_MODULES_PHYSICS 1
#define JIN_PHYSICS_BOX2D 1
#define JIN_PHYSICS_NEWTON 1
-#define JIN_MODULES_TILEMAP 0
+#define JIN_MODULES_TILEMAP 1
-#define JIN_MODULES_UI 0
+#define JIN_MODULES_UI 1
-#define JIN_MODULES_TOOLS 0
+#define JIN_MODULES_TOOLS 1
#define JIN_TOOLS_COMPONENT 1
#define JIN_TOOLS_EVENTMSGCENTER 1
#define JIN_TOOLS_XML 1
#define JIN_TOOLS_CSV 1
#define JIN_TOOLS_JSON 1
-#define JIN_MODULES_THREAD 0
+#define JIN_MODULES_THREAD 1
#define JIN_MODULES_TIME 1
#define JIN_TIME_SDL 1
diff --git a/src/lua/audio/luaopen_Source.cpp b/src/lua/audio/luaopen_Source.cpp
index 0b8391a..d147e5e 100644
--- a/src/lua/audio/luaopen_Source.cpp
+++ b/src/lua/audio/luaopen_Source.cpp
@@ -84,7 +84,16 @@ namespace lua
return 0;
}
+ static int l_gc(lua_State* L)
+ {
+ SDLSource* src = checkSource(L);
+ src->stop();
+ delete src;
+ return 0;
+ }
+
static const luaL_Reg f[] = {
+ { "__gc", l_gc },
{ "play", l_play },
{ "stop", l_stop },
{ "pause", l_pause },
diff --git a/src/lua/embed/boot.lua.h b/src/lua/embed/boot.lua.h
index 1ba613b..c73e9f9 100644
--- a/src/lua/embed/boot.lua.h
+++ b/src/lua/embed/boot.lua.h
@@ -31,60 +31,41 @@ local function safecall(func, ...)
end
function jin.core.run()
- local load = jin.core.load
- local running = jin.core.running
- local second = jin.time.second
- local sleep = jin.time.sleep
- local poll = jin.event.poll
- local unbind = jin.graphics.unbind
- local clear = jin.graphics.clear
- local color = jin.graphics.color
- local study = jin.graphics.study
- local onDraw = jin.core.onDraw
- local onUpdate = jin.core.onUpdate
- local onEvent = jin.core.onEvent
- local present = jin.graphics.present
- local setkey = jin.keyboard.set
- local dstatus = jin.debug.status
- local drender = jin.debug.render
-
- local fps = conf.fps
-
- safecall(load)
- local previous = second()
- local SEC_PER_UPDATE = 1 / fps
+ safecall(jin.core.load)
+ local previous = jin.time.second()
+ local SEC_PER_UPDATE = 1 / conf.fps
local dt = SEC_PER_UPDATE
- while(running()) do
- for _, e in pairs(poll()) do
+ while(jin.core.running()) do
+ for _, e in pairs(jin.event.poll()) do
if e.type == "keydown" then
- setkey(e.key, true)
+ jin.keyboard.set(e.key, true)
elseif e.type == "keyup" then
- setkey(e.key, false)
+ jin.keyboard.set(e.key, false)
end
- safecall(onEvent, e)
+ safecall(jin.core.onEvent, e)
end
- if not running() then
+ if not jin.core.running() then
break
end
- safecall(onUpdate, dt)
- -- bind to default render buffer
- unbind()
- clear()
- color()
- study()
- safecall(onDraw)
- -- render debug window
- if dstatus() then
- drender()
+
+ safecall(jin.core.onUpdate, dt)
+
+ jin.graphics.unbind()
+ jin.graphics.clear()
+ jin.graphics.color()
+ jin.graphics.study()
+ safecall(jin.core.onDraw)
+ if jin.debug.status() then
+ jin.debug.render()
end
- present()
- -- frame control
- local current = second()
+ jin.graphics.present()
+
+ local current = jin.time.second()
dt = current - previous
local wait = SEC_PER_UPDATE - dt
previous = previous + SEC_PER_UPDATE
if wait > 0 then
- sleep(wait)
+ jin.time.sleep(wait)
dt = SEC_PER_UPDATE
else
previous = current
diff --git a/src/lua/graphics/luaopen_Image.cpp b/src/lua/graphics/luaopen_Image.cpp
index 5fc9aea..546e6b1 100644
--- a/src/lua/graphics/luaopen_Image.cpp
+++ b/src/lua/graphics/luaopen_Image.cpp
@@ -12,7 +12,7 @@ namespace lua
static inline Texture* checkTexture(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, TYPE_IMAGE);
- if (proxy != 0 && proxy != nullptr)
+ if (proxy != nullptr)
return (Texture*)proxy->object;
return nullptr;
}
diff --git a/src/lua/graphics/luaopen_graphics.cpp b/src/lua/graphics/luaopen_graphics.cpp
index a394cc3..2aa68e8 100644
--- a/src/lua/graphics/luaopen_graphics.cpp
+++ b/src/lua/graphics/luaopen_graphics.cpp
@@ -500,7 +500,7 @@ namespace lua
{"circle", l_drawCircle},
{"triangle", l_drawTriangle},
{"polygon", l_drawPolygon},
- //
+ // quit window
{"destroy", l_destroy},
{0, 0}
};
diff --git a/src/main.cpp b/src/main.cpp
index 256f39d..50d4ef0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -10,6 +10,7 @@
#include "libjin/jin.h"
+#include <iostream>
#include <Windows.h>
int main(int argc, char* argv[])
@@ -43,6 +44,9 @@ int main(int argc, char* argv[])
#undef BUFFER_SIZE
luax_setfield_string(L, "_dir", buffer);
+ short a = -9;
+ std::cout << (a << 8);
+
// boot
jin::lua::boot(L);