aboutsummaryrefslogtreecommitdiff
path: root/src/lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/common/je_lua.h2
-rw-r--r--src/lua/common/je_lua_reference.cpp2
-rw-r--r--src/lua/common/je_lua_shared.cpp4
-rw-r--r--src/lua/common/je_lua_shared.hpp11
-rw-r--r--src/lua/embed/embed.h6
-rw-r--r--src/lua/modules/graphics/je_lua_graphics.cpp120
-rw-r--r--src/lua/modules/graphics/je_lua_particle_system.cpp2
7 files changed, 80 insertions, 67 deletions
diff --git a/src/lua/common/je_lua.h b/src/lua/common/je_lua.h
index b6fc878..66647aa 100644
--- a/src/lua/common/je_lua.h
+++ b/src/lua/common/je_lua.h
@@ -15,6 +15,8 @@ namespace JinEngine
namespace Lua
{
+ // Extends luax.h library.
+
///
///
///
diff --git a/src/lua/common/je_lua_reference.cpp b/src/lua/common/je_lua_reference.cpp
index 37ed441..72c1c3e 100644
--- a/src/lua/common/je_lua_reference.cpp
+++ b/src/lua/common/je_lua_reference.cpp
@@ -10,7 +10,9 @@ namespace JinEngine
LuaRef::LuaRef(lua_State* L, int i)
: mL(L)
{
+ // Get value.
luax_pushvalue(mL, i);
+ // Set reference.
luax_getreferencestable(L);
luax_pushvalue(mL, -2);
mIndex = luax_ref(mL, -2);
diff --git a/src/lua/common/je_lua_shared.cpp b/src/lua/common/je_lua_shared.cpp
index 55832fd..acf1494 100644
--- a/src/lua/common/je_lua_shared.cpp
+++ b/src/lua/common/je_lua_shared.cpp
@@ -36,7 +36,7 @@ namespace JinEngine
{
if (!isDependOn(key))
return;
- std::map<int, SharedBase*>::iterator it = mDependencies.find(key);
+ DepsMap::iterator it = mDependencies.find(key);
SharedBase* dep = it->second;
// Remove lua reference.
luax_removereference(mL, this, dep);
@@ -46,7 +46,7 @@ namespace JinEngine
void SharedBase::removeDependency(SharedBase* dependency)
{
- for (std::map<int, SharedBase*>::iterator it = mDependencies.begin(); it != mDependencies.end();)
+ for (DepsMap::iterator it = mDependencies.begin(); it != mDependencies.end();)
{
SharedBase* dep = it->second;
if (dep == dependency)
diff --git a/src/lua/common/je_lua_shared.hpp b/src/lua/common/je_lua_shared.hpp
index 2f1e18b..579a38e 100644
--- a/src/lua/common/je_lua_shared.hpp
+++ b/src/lua/common/je_lua_shared.hpp
@@ -1,8 +1,6 @@
#ifndef __JIN_COMMON_SHARED_H__
#define __JIN_COMMON_SHARED_H__
-//#include "je_lua.h"
-
#include <map>
#include <vector>
#include <functional>
@@ -59,10 +57,13 @@ namespace JinEngine
clearDependencies();
}
- void* mObject;
- int mCount;
+ using DepsMap = std::map<int, SharedBase*>;
+
+ void* mObject;
+ int mCount;
lua_State* mL;
- std::map<int, SharedBase*> mDependencies;
+ DepsMap mDependencies;
+
};
template<class T>
diff --git a/src/lua/embed/embed.h b/src/lua/embed/embed.h
index 7172a2c..a063e65 100644
--- a/src/lua/embed/embed.h
+++ b/src/lua/embed/embed.h
@@ -7,10 +7,6 @@ namespace JinEngine
namespace Embed
{
- #define embed(L, script, name)\
- if(luax_loadbuffer(L, script, strlen(script), name) == 0)\
- lua_call(L, 0, 0);
-
// Embed structure.
struct jin_Embed
{
@@ -24,7 +20,7 @@ namespace JinEngine
#include "scripts/boot.lua.h"
// In order.
- const jin_Embed scripts[] = {
+ static const jin_Embed scripts[] = {
{ "graphics.lua", graphics_lua },
{ "keyboard.lua", keyboard_lua },
{ "mouse.lua", mouse_lua },
diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp
index 36829ab..d2f663d 100644
--- a/src/lua/modules/graphics/je_lua_graphics.cpp
+++ b/src/lua/modules/graphics/je_lua_graphics.cpp
@@ -888,6 +888,17 @@ namespace JinEngine
return 1;
}
+ LUA_IMPLEMENT int l_newParticleSystem(lua_State* L)
+ {
+ // Definition table.
+ if (!luax_istable(L, 1))
+ {
+ luax_typerror(L, 1, "particle system definition table");
+ return 1;
+ }
+
+ }
+
/* setFont(font) */
LUA_IMPLEMENT int l_setFont(lua_State* L)
{
@@ -920,13 +931,13 @@ namespace JinEngine
LUA_IMPLEMENT int l_pushMatrix(lua_State* L)
{
- gl.push();
+ gl.pushMatrix();
return 0;
}
LUA_IMPLEMENT int l_popMatrix(lua_State* L)
{
- gl.pop();
+ gl.popMatrix();
return 0;
}
@@ -971,59 +982,60 @@ namespace JinEngine
luaL_Reg methods[] = {
/* window */
- { "init", l_init },
- { "setTitle", l_setTitle },
- { "getSize", l_getSize },
- { "getWidth", l_getWidth },
- { "getHeight", l_getHeight },
- { "destroy", l_destroy },
- { "hideWindow", l_hideWindow },
- { "showWindow", l_showWindow },
- /* creators */
- { "newBitmap", l_newBitmap },
- { "newTexture", l_newTexture },
- { "newShader", l_newShader },
- { "newShaderf", l_newShaderf },
- { "newCanvas", l_newCanvas },
- { "newTTFData", l_newTTFData },
- { "newText", l_newText },
- { "newTextureFont", l_newTextureFont },
- { "newSprite", l_newSprite },
- { "newSpriteSheet", l_newSpriteSheet },
- { "newAnimation", l_newAnimation },
- { "newAnimator", l_newAnimator },
+ { "init", l_init },
+ { "setTitle", l_setTitle },
+ { "getSize", l_getSize },
+ { "getWidth", l_getWidth },
+ { "getHeight", l_getHeight },
+ { "destroy", l_destroy },
+ { "hideWindow", l_hideWindow },
+ { "showWindow", l_showWindow },
+ /* creators */
+ { "newBitmap", l_newBitmap },
+ { "newTexture", l_newTexture },
+ { "newShader", l_newShader },
+ { "newShaderf", l_newShaderf },
+ { "newCanvas", l_newCanvas },
+ { "newTTFData", l_newTTFData },
+ { "newText", l_newText },
+ { "newTextureFont", l_newTextureFont },
+ { "newSprite", l_newSprite },
+ { "newSpriteSheet", l_newSpriteSheet },
+ { "newAnimation", l_newAnimation },
+ { "newAnimator", l_newAnimator },
+ { "newParticleSystem", l_newParticleSystem },
/* render */
- { "setClearColor", l_setClearColor },
- { "clear", l_clear },
- { "draw", l_draw },
- { "print", l_print },
- { "drawq", l_drawq },
- { "setColor", l_setColor },
- { "getColor", l_getColor },
- { "present", l_present },
- /* canvas */
- { "bindCanvas", l_bindCanvas },
- { "unbindCanvas", l_unbindCanvas },
- /* shader */
- { "useShader", l_useShader },
- /* shapes */
- { "point", l_point },
- { "line", l_line },
- { "rect", l_rect },
- { "circle", l_circle },
- { "triangle", l_triangle },
- { "polygon", l_polygon },
- /* font */
- { "setFont", l_setFont },
- { "unsetFont", l_unsetFont },
- /* transform */
- { "pushMatrix", l_pushMatrix },
- { "clearMatrix", l_clearMatrix },
- { "popMatrix", l_popMatrix },
- { "translate", l_translate },
- { "rotate", l_rotate },
- { "scale", l_scale },
- { 0, 0 }
+ { "setClearColor", l_setClearColor },
+ { "clear", l_clear },
+ { "draw", l_draw },
+ { "print", l_print },
+ { "drawq", l_drawq },
+ { "setColor", l_setColor },
+ { "getColor", l_getColor },
+ { "present", l_present },
+ /* canvas */
+ { "bindCanvas", l_bindCanvas },
+ { "unbindCanvas", l_unbindCanvas },
+ /* shader */
+ { "useShader", l_useShader },
+ /* shapes */
+ { "point", l_point },
+ { "line", l_line },
+ { "rect", l_rect },
+ { "circle", l_circle },
+ { "triangle", l_triangle },
+ { "polygon", l_polygon },
+ /* font */
+ { "setFont", l_setFont },
+ { "unsetFont", l_unsetFont },
+ /* transform */
+ { "pushMatrix", l_pushMatrix },
+ { "clearMatrix", l_clearMatrix },
+ { "popMatrix", l_popMatrix },
+ { "translate", l_translate },
+ { "rotate", l_rotate },
+ { "scale", l_scale },
+ { 0, 0 }
};
// Load whole lib.
luax_newlib(L, methods);
diff --git a/src/lua/modules/graphics/je_lua_particle_system.cpp b/src/lua/modules/graphics/je_lua_particle_system.cpp
index 7099a5c..b0cb221 100644
--- a/src/lua/modules/graphics/je_lua_particle_system.cpp
+++ b/src/lua/modules/graphics/je_lua_particle_system.cpp
@@ -8,4 +8,4 @@ namespace JinEngine
} // Lua
-} // namespace JinEngine \ No newline at end of file
+} // namespace JinEngine \ No newline at end of file