aboutsummaryrefslogtreecommitdiff
path: root/src/lua/modules/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/modules/graphics')
-rw-r--r--src/lua/modules/graphics/je_lua_animation.cpp36
-rw-r--r--src/lua/modules/graphics/je_lua_animator.cpp37
-rw-r--r--src/lua/modules/graphics/je_lua_bitmap.cpp35
-rw-r--r--src/lua/modules/graphics/je_lua_canvas.cpp20
-rw-r--r--src/lua/modules/graphics/je_lua_graphics.cpp80
-rw-r--r--src/lua/modules/graphics/je_lua_page.cpp2
-rw-r--r--src/lua/modules/graphics/je_lua_particle_system.cpp62
-rw-r--r--src/lua/modules/graphics/je_lua_shader.cpp32
-rw-r--r--src/lua/modules/graphics/je_lua_sprite.cpp10
-rw-r--r--src/lua/modules/graphics/je_lua_spritesheet.cpp10
-rw-r--r--src/lua/modules/graphics/je_lua_texture.cpp12
-rw-r--r--src/lua/modules/graphics/je_lua_texture_font.cpp5
-rw-r--r--src/lua/modules/graphics/je_lua_ttf.cpp5
-rw-r--r--src/lua/modules/graphics/je_lua_ttf_data.cpp7
14 files changed, 163 insertions, 190 deletions
diff --git a/src/lua/modules/graphics/je_lua_animation.cpp b/src/lua/modules/graphics/je_lua_animation.cpp
index bdba10d..2bb635a 100644
--- a/src/lua/modules/graphics/je_lua_animation.cpp
+++ b/src/lua/modules/graphics/je_lua_animation.cpp
@@ -20,12 +20,10 @@ namespace JinEngine
{
const char* Jin_Lua_Animation = "Animation";
- typedef Shared<Animation>& SharedAnimation;
-
- LUA_IMPLEMENT inline SharedAnimation checkAnimation(lua_State* L)
+ LUA_IMPLEMENT inline Animation* checkAnimation(lua_State* L)
{
- LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
- return luaObj->getShared<Animation>();
+ LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Animation);
+ return luaObj->getObject<Animation>();
}
LUA_IMPLEMENT int l_gc(lua_State* L)
@@ -39,12 +37,12 @@ namespace JinEngine
LUA_IMPLEMENT int l_addFrame(lua_State* L)
{
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
- SharedAnimation shrAnimation = luaObj->getShared<Animation>();
+ Animation* animation = luaObj->getObject<Animation>();
LuaObject* luaSprite = (LuaObject*)luax_checktype(L, 2, Jin_Lua_Sprite);
- Shared<Sprite>& shrSprite = luaSprite->getShared<Sprite>();
- shrAnimation->addFrame(shrSprite.getObject());
- int i = shrAnimation->getFrameCount() - 1;
- luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + i, &shrSprite);
+ Sprite* sprite = luaSprite->getObject<Sprite>();
+ animation->addFrame(sprite);
+ int i = animation->getFrameCount() - 1;
+ luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + i, luaSprite->getShared());
return 0;
}
@@ -52,7 +50,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_addFrames(lua_State* L)
{
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
- SharedAnimation shrAnimation = luaObj->getShared<Animation>();
+ Animation* shrAnimation = luaObj->getObject<Animation>();
if (!luax_istable(L, 2))
{
luax_typerror(L, 2, "sprites table");
@@ -63,17 +61,17 @@ namespace JinEngine
{
luax_rawgeti(L, 2, i);
LuaObject* luaSprite = (LuaObject*)luax_checktype(L, -1, Jin_Lua_Sprite);
- Shared<Sprite>& shrSprite = luaSprite->getShared<Sprite>();
- shrAnimation->addFrame(shrSprite.getObject());
+ Sprite* sprite = luaSprite->getObject<Sprite>();
+ shrAnimation->addFrame(sprite);
int index = shrAnimation->getFrameCount() - 1;
- luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + index, &shrSprite);
+ luaObj->setDependency((int)AnimationDependency::DEP_SPRITES + index, luaSprite->getShared());
}
return 0;
}
LUA_IMPLEMENT int l_isLoop(lua_State* L)
{
- SharedAnimation shrAnimation = checkAnimation(L);
+ Animation* shrAnimation = checkAnimation(L);
bool loop = shrAnimation->isLoop();
luax_pushboolean(L, loop);
return 1;
@@ -81,7 +79,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_getSpeed(lua_State* L)
{
- SharedAnimation shrAnimation = checkAnimation(L);
+ Animation* shrAnimation = checkAnimation(L);
float speed = shrAnimation->getSpeed();
luax_pushnumber(L, speed);
return 1;
@@ -90,16 +88,16 @@ namespace JinEngine
LUA_IMPLEMENT int l_getFrame(lua_State* L)
{
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
- SharedAnimation shrAnimation = luaObj->getShared<Animation>();
+ Animation* shrAnimation = luaObj->getObject<Animation>();
int i = luax_checkinteger(L, 2);
- SharedBase* shrFrame = luaObj->getDependency((int)AnimationDependency::DEP_SPRITES + i);
+ Shared* shrFrame = luaObj->getDependency((int)AnimationDependency::DEP_SPRITES + i);
luax_getobject(L, shrFrame);
return 1;
}
LUA_IMPLEMENT int getFrameCount(lua_State* L)
{
- SharedAnimation shrAnimation = checkAnimation(L);
+ Animation* shrAnimation = checkAnimation(L);
int n = shrAnimation->getFrameCount();
luax_pushinteger(L, n);
return 1;
diff --git a/src/lua/modules/graphics/je_lua_animator.cpp b/src/lua/modules/graphics/je_lua_animator.cpp
index 360a276..b264c17 100644
--- a/src/lua/modules/graphics/je_lua_animator.cpp
+++ b/src/lua/modules/graphics/je_lua_animator.cpp
@@ -20,12 +20,10 @@ namespace JinEngine
{
const char* Jin_Lua_Animator = "Animator";
- typedef Shared<Animator>& SharedAnimator;
-
- LUA_IMPLEMENT inline SharedAnimator checkAnimator(lua_State* L)
+ LUA_IMPLEMENT inline Animator* checkAnimator(lua_State* L)
{
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animator);
- return luaObj->getShared<Animator>();
+ return luaObj->getObject<Animator>();
}
LUA_IMPLEMENT int l_gc(lua_State* L)
@@ -37,7 +35,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_update(lua_State* L)
{
- SharedAnimator animator = checkAnimator(L);
+ Animator* animator = checkAnimator(L);
float dt = luax_checknumber(L, 2);
animator->update(dt);
return 0;
@@ -45,35 +43,35 @@ namespace JinEngine
LUA_IMPLEMENT int l_play(lua_State* L)
{
- SharedAnimator animator = checkAnimator(L);
+ Animator* animator = checkAnimator(L);
animator->play();
return 0;
}
LUA_IMPLEMENT int l_pause(lua_State* L)
{
- SharedAnimator animator = checkAnimator(L);
+ Animator* animator = checkAnimator(L);
animator->pause();
return 0;
}
LUA_IMPLEMENT int l_resume(lua_State* L)
{
- SharedAnimator animator = checkAnimator(L);
+ Animator* animator = checkAnimator(L);
animator->resume();
return 0;
}
LUA_IMPLEMENT int l_rewind(lua_State* L)
{
- SharedAnimator animator = checkAnimator(L);
+ Animator* animator = checkAnimator(L);
animator->rewind();
return 0;
}
LUA_IMPLEMENT int l_render(lua_State* L)
{
- SharedAnimator animator = checkAnimator(L);
+ Animator* animator = checkAnimator(L);
float x = luax_checknumber(L, 2);
float y = luax_checknumber(L, 3);
float sx = luax_checknumber(L, 4);
@@ -86,17 +84,16 @@ namespace JinEngine
LUA_IMPLEMENT int l_setAnimation(lua_State* L)
{
LuaObject* luaAnimator = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animator);
- SharedAnimator shrAnimator = luaAnimator->getShared<Animator>();
+ Animator* animator = luaAnimator->getObject<Animator>();
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
- Shared<Animation>& shrAnimation = luaObj->getShared<Animation>();
- luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, &shrAnimation);
- shrAnimator->setAnimation(shrAnimation.getObject());
+ luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, luaObj->getShared());
+ animator->setAnimation(luaObj->getObject<Animation>());
return 0;
}
LUA_IMPLEMENT int l_forceToFrame(lua_State* L)
{
- SharedAnimator shrAnimator = checkAnimator(L);
+ Animator* shrAnimator = checkAnimator(L);
int index = luax_checkinteger(L, 2);
shrAnimator->forceToFrame(index);
return 0;
@@ -104,7 +101,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setSpeed(lua_State* L)
{
- SharedAnimator shrAnimator = checkAnimator(L);
+ Animator* shrAnimator = checkAnimator(L);
float fps = luax_checknumber(L, 2);
shrAnimator->setSpeed(fps);
return 0;
@@ -112,14 +109,14 @@ namespace JinEngine
LUA_IMPLEMENT int l_setDefaultSpeed(lua_State* L)
{
- SharedAnimator shrAnimator = checkAnimator(L);
+ Animator* shrAnimator = checkAnimator(L);
shrAnimator->setDefaultSpeed();
return 0;
}
LUA_IMPLEMENT int l_setLoop(lua_State* L)
{
- SharedAnimator shrAnimator = checkAnimator(L);
+ Animator* shrAnimator = checkAnimator(L);
bool loop = luax_checkbool(L, 2);
shrAnimator->setLoop(loop);
return 0;
@@ -127,14 +124,14 @@ namespace JinEngine
LUA_IMPLEMENT int l_setDefaultLoop(lua_State* L)
{
- SharedAnimator shrAnimator = checkAnimator(L);
+ Animator* shrAnimator = checkAnimator(L);
shrAnimator->setDefaultLoop();
return 0;
}
LUA_IMPLEMENT int l_getSpeed(lua_State* L)
{
- SharedAnimator shrAnimator = checkAnimator(L);
+ Animator* shrAnimator = checkAnimator(L);
float speed = shrAnimator->getSpeed();
luax_pushnumber(L, speed);
return 1;
diff --git a/src/lua/modules/graphics/je_lua_bitmap.cpp b/src/lua/modules/graphics/je_lua_bitmap.cpp
index 8d8b76e..cd0bb18 100644
--- a/src/lua/modules/graphics/je_lua_bitmap.cpp
+++ b/src/lua/modules/graphics/je_lua_bitmap.cpp
@@ -13,12 +13,10 @@ namespace JinEngine
const char* Jin_Lua_Bitmap = "Bitmap";
- typedef Shared<Bitmap>& SharedBitmap;
-
- LUA_IMPLEMENT inline SharedBitmap checkBitmap(lua_State* L)
+ LUA_IMPLEMENT inline Bitmap* checkBitmap(lua_State* L)
{
- LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap);
- return luaObj->getShared<Bitmap>();
+ LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Bitmap);
+ return luaObj->getObject<Bitmap>();
}
LUA_IMPLEMENT int l_gc(lua_State* L)
@@ -30,25 +28,25 @@ namespace JinEngine
LUA_IMPLEMENT int l_getWidth(lua_State* L)
{
- SharedBitmap shared = checkBitmap(L);
- int w = shared->getWidth();
+ Bitmap* bitmap = checkBitmap(L);
+ int w = bitmap->getWidth();
luax_pushinteger(L, w);
return 1;
}
LUA_IMPLEMENT int l_getHeight(lua_State* L)
{
- SharedBitmap shared = checkBitmap(L);
- int h = shared->getHeight();
+ Bitmap* bitmap = checkBitmap(L);
+ int h = bitmap->getHeight();
luax_pushinteger(L, h);
return 1;
}
LUA_IMPLEMENT int l_getSize(lua_State* L)
{
- SharedBitmap shared = checkBitmap(L);
- int w = shared->getWidth();
- int h = shared->getHeight();
+ Bitmap* bitmap = checkBitmap(L);
+ int w = bitmap->getWidth();
+ int h = bitmap->getHeight();
luax_pushinteger(L, w);
luax_pushinteger(L, h);
return 2;
@@ -56,10 +54,10 @@ namespace JinEngine
LUA_IMPLEMENT int l_getPixel(lua_State* L)
{
- SharedBitmap shared = checkBitmap(L);
+ Bitmap* bitmap = checkBitmap(L);
int x = luax_checkinteger(L, 2);
int y = luax_checkinteger(L, 3);
- Color col = shared->getPixel(x, y);
+ Color col = bitmap->getPixel(x, y);
luax_pushinteger(L, col.r);
luax_pushinteger(L, col.g);
luax_pushinteger(L, col.b);
@@ -69,7 +67,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setPixel(lua_State* L)
{
- SharedBitmap shared = checkBitmap(L);
+ Bitmap* bitmap = checkBitmap(L);
int x = luax_checkinteger(L, 2);
int y = luax_checkinteger(L, 3);
if (!luax_istable(L, 4))
@@ -81,16 +79,15 @@ namespace JinEngine
unsigned int g = luax_rawgetnumber(L, 4, 2);
unsigned int b = luax_rawgetnumber(L, 4, 3);
unsigned int a = luax_rawgetnumber(L, 4, 4);
- shared->setPixel(Color(r, g, b, a), x, y);
+ bitmap->setPixel(Color(r, g, b, a), x, y);
return 0;
}
LUA_IMPLEMENT int l_clone(lua_State* L)
{
- SharedBitmap shared = checkBitmap(L);
- Bitmap* bitmap = shared.getObject();
+ Bitmap* bitmap = checkBitmap(L);
Bitmap* b = bitmap->clone();
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared<Bitmap>(b, Jin_Lua_Bitmap));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(b, Jin_Lua_Bitmap));
return 1;
}
diff --git a/src/lua/modules/graphics/je_lua_canvas.cpp b/src/lua/modules/graphics/je_lua_canvas.cpp
index 261f940..0e884f8 100644
--- a/src/lua/modules/graphics/je_lua_canvas.cpp
+++ b/src/lua/modules/graphics/je_lua_canvas.cpp
@@ -12,33 +12,31 @@ namespace JinEngine
const char* Jin_Lua_Canvas = "Canvas";
- typedef Shared<Canvas>& SharedCanvas;
-
- LUA_IMPLEMENT inline SharedCanvas checkCanvas(lua_State* L)
+ LUA_IMPLEMENT inline Canvas* checkCanvas(lua_State* L)
{
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Canvas);
- return luaObj->getShared<Canvas>();
+ return luaObj->getObject<Canvas>();
}
LUA_IMPLEMENT int l_getWidth(lua_State* L)
{
- SharedCanvas shared = checkCanvas(L);
- luax_pushnumber(L, shared->getWidth());
+ Canvas* canvas = checkCanvas(L);
+ luax_pushnumber(L, canvas->getWidth());
return 1;
}
LUA_IMPLEMENT int l_getHeight(lua_State* L)
{
- SharedCanvas shared = checkCanvas(L);
- luax_pushnumber(L, shared->getHeight());
+ Canvas* canvas = checkCanvas(L);
+ luax_pushnumber(L, canvas->getHeight());
return 1;
}
LUA_IMPLEMENT int l_getSize(lua_State* L)
{
- SharedCanvas shared = checkCanvas(L);
- luax_pushnumber(L, shared->getWidth());
- luax_pushnumber(L, shared->getHeight());
+ Canvas* canvas = checkCanvas(L);
+ luax_pushnumber(L, canvas->getWidth());
+ luax_pushnumber(L, canvas->getHeight());
return 2;
}
diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp
index 40bb4fa..accd209 100644
--- a/src/lua/modules/graphics/je_lua_graphics.cpp
+++ b/src/lua/modules/graphics/je_lua_graphics.cpp
@@ -208,7 +208,7 @@ namespace JinEngine
return 1;
}
}
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared<Bitmap>(bitmap, Jin_Lua_Bitmap));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(bitmap, Jin_Lua_Bitmap));
return 1;
}
@@ -218,9 +218,8 @@ namespace JinEngine
Texture* texture = nullptr;
if (luax_istype(L, 1, Jin_Lua_Bitmap))
{
- LuaObject* p = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap);
- Shared<Bitmap>& refBitmap = p->getShared<Bitmap>();
- Bitmap* bitmap = refBitmap.getObject();
+ LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap);
+ Bitmap* bitmap = luaObj->getObject<Bitmap>();
texture = new Texture(bitmap);
}
else if (luax_isstring(L, 1))
@@ -228,7 +227,7 @@ namespace JinEngine
const char* path = luax_checkstring(L, 1);
texture = new Texture(path);
}
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Texture, new Shared<Texture>(texture, Jin_Lua_Texture));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Texture, new Shared(texture, Jin_Lua_Texture));
return 1;
}
@@ -242,7 +241,7 @@ namespace JinEngine
luax_pushnil(L);
return 1;
}
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared<Shader>(jsl, Jin_Lua_Shader));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared(jsl, Jin_Lua_Shader));
return 1;
}
@@ -265,7 +264,7 @@ namespace JinEngine
luax_pushnil(L);
return 1;
}
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared<Shader>(jsl, Jin_Lua_Shader));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Shader, new Shared(jsl, Jin_Lua_Shader));
return 1;
}
@@ -274,7 +273,7 @@ namespace JinEngine
int w = luax_checknumber(L, 1);
int h = luax_checknumber(L, 2);
Canvas* cvs = new Canvas(w, h);
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Canvas, new Shared<Canvas>(cvs, Jin_Lua_Canvas));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Canvas, new Shared(cvs, Jin_Lua_Canvas));
return 1;
}
@@ -322,7 +321,7 @@ namespace JinEngine
float ox = luax_optnumber(L, 7, 0);
float oy = luax_optnumber(L, 8, 0);
LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1);
- Shared<Texture>& tex = luaObj->getShared<Texture>();
+ Texture* tex = luaObj->getObject<Texture>();
tex->render(x, y, sx, sy, r, ox, oy);
}
@@ -338,8 +337,8 @@ namespace JinEngine
float ox = luax_optnumber(L, 7, 0);
float oy = luax_optnumber(L, 8, 0);
LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1);
- Shared<Canvas>& p = luaObj->getShared<Canvas>();
- p->render(x, y, sx, sy, r, ox, oy);
+ Canvas* canvas = luaObj->getObject<Canvas>();
+ canvas->render(x, y, sx, sy, r, ox, oy);
}
/* jin.graphics.draw(text, font, x, y) */
@@ -444,14 +443,14 @@ namespace JinEngine
if (luax_istype(L, 1, Jin_Lua_Texture))
{
LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1);
- Shared<Texture>& tex = luaObj->getShared<Texture>();
+ Texture* tex = luaObj->getObject<Texture>();
tex->render(q, x, y, sx, sy, r, ox, oy);
}
else if (luax_istype(L, 1, Jin_Lua_Canvas))
{
LuaObject* luaObj = (LuaObject*)luax_toudata(L, 1);
- Shared<Canvas>& p = luaObj->getShared<Canvas>();
- p->render(q, x, y, sx, sy, r, ox, oy);
+ Canvas* canvas = luaObj->getObject<Canvas>();
+ canvas->render(q, x, y, sx, sy, r, ox, oy);
}
else
{
@@ -514,8 +513,8 @@ namespace JinEngine
return 0;
}
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Canvas);
- Shared<Canvas>& shared = luaObj->getShared<Canvas>();
- gl.bindCanvas(shared.getObject());
+ Canvas* canvas = luaObj->getObject<Canvas>();
+ gl.bindCanvas(canvas);
return 0;
}
@@ -535,8 +534,8 @@ namespace JinEngine
if (luax_istype(L, 1, Jin_Lua_Shader))
{
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Shader);
- Shared<Shader>& shader = luaObj->getShared<Shader>();
- gl.useShader(shader.getObject());
+ Shader* shader = luaObj->getObject<Shader>();
+ gl.useShader(shader);
}
else
{
@@ -685,7 +684,7 @@ namespace JinEngine
fs->read(path, b);
fd = new TTFData(&b, b.size());
}
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TTFData, new Shared<TTFData>(fd, Jin_Lua_TTFData));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TTFData, new Shared(fd, Jin_Lua_TTFData));
return 1;
}
@@ -708,7 +707,7 @@ namespace JinEngine
unsigned length;
const char* data = luax_checklstring(L, 1, &length);
Text* text = new Text(encode, data, length);
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Text, new Shared<Text>(text, Jin_Lua_Text));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Text, new Shared(text, Jin_Lua_Text));
return 1;
}
@@ -736,7 +735,7 @@ namespace JinEngine
quad.h = luax_rawgetnumberthenpop(L, 2, 4);
int o = luax_checkinteger(L, 3);
Origin origin = static_cast<Origin>(o);
- LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared<Sprite>(new Sprite(graphic, quad, origin), Jin_Lua_Sprite));
+ LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, quad, origin), Jin_Lua_Sprite));
p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic->getShared());
}
else if (n == 4)
@@ -748,21 +747,21 @@ namespace JinEngine
quad.h = luax_rawgetnumberthenpop(L, 2, 4);
int ox = luax_checkinteger(L, 3);
int oy = luax_checkinteger(L, 4);
- LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared<Sprite>(new Sprite(graphic, quad, ox, oy), Jin_Lua_Sprite));
+ LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, quad, ox, oy), Jin_Lua_Sprite));
p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic->getShared());
}
else if (n == 2)
{
int o = luax_checkinteger(L, 2);
Origin origin = static_cast<Origin>(o);
- LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared<Sprite>(new Sprite(graphic, origin), Jin_Lua_Sprite));
+ LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, origin), Jin_Lua_Sprite));
p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic->getShared());
}
else if (n == 3)
{
int ox = luax_checkinteger(L, 2);
int oy = luax_checkinteger(L, 3);
- LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared<Sprite>(new Sprite(graphic, ox, oy), Jin_Lua_Sprite));
+ LuaObject* p = luax_newinstance(L, Jin_Lua_Sprite, new Shared(new Sprite(graphic, ox, oy), Jin_Lua_Sprite));
p->setDependency((int)SpriteDependency::DEP_GRAPHIC, objGraphic->getShared());
}
else
@@ -785,10 +784,10 @@ namespace JinEngine
if (objGraphic != nullptr)
{
Graphic* graphic = objGraphic->getObject<Graphic>();
- Shared<SpriteSheet>* shrSSheet = new Shared<SpriteSheet>(new SpriteSheet(graphic), Jin_Lua_SpriteSheet);
- Shared<Graphic>& shrGraphic = objGraphic->getShared<Graphic>();
+ Shared* shrSSheet = new Shared(new SpriteSheet(graphic), Jin_Lua_SpriteSheet);
+ Shared* shrGraphic = objGraphic->getShared();
LuaObject* luaSSheet = luax_newinstance(L, Jin_Lua_SpriteSheet, shrSSheet);
- luaSSheet->setDependency((int)SpriteSheetDependency::DEP_GRAPHIC, &shrGraphic);
+ luaSSheet->setDependency((int)SpriteSheetDependency::DEP_GRAPHIC, shrGraphic);
return 1;
}
else
@@ -799,7 +798,8 @@ namespace JinEngine
LUA_IMPLEMENT int l_newAnimation(lua_State* L)
{
int argc = luax_gettop(L);
- Shared<Animation>* shrAnimation = new Shared<Animation>(new Animation(), Jin_Lua_Animation);
+ Animation* animation = new Animation();
+ Shared* shrAnimation = new Shared(animation, Jin_Lua_Animation);
LuaObject* luaAnimation = luax_newinstance(L, Jin_Lua_Animation, shrAnimation);
if (argc >= 3)
{
@@ -815,13 +815,12 @@ namespace JinEngine
{
luax_rawgeti(L, 1, i);
LuaObject* luaSprite = (LuaObject*)luax_checktype(L, -1, Jin_Lua_Sprite);
- Shared<Sprite>& shrSprite = luaSprite->getShared<Sprite>();
- (*shrAnimation)->addFrame(shrSprite.getObject());
- int index = (*shrAnimation)->getFrameCount() - 1;
- luaAnimation->setDependency((int)AnimationDependency::DEP_SPRITES + index, &shrSprite);
+ animation->addFrame(luaSprite->getObject<Sprite>());
+ int index = animation->getFrameCount() - 1;
+ luaAnimation->setDependency((int)AnimationDependency::DEP_SPRITES + index, luaSprite->getShared());
}
- (*shrAnimation)->setLoop(loop);
- (*shrAnimation)->setSpeed(speed);
+ animation->setLoop(loop);
+ animation->setSpeed(speed);
}
luax_pushvalue(L, argc + 1);
return 1;
@@ -831,14 +830,15 @@ namespace JinEngine
LUA_IMPLEMENT int l_newAnimator(lua_State* L)
{
int argc = luax_gettop(L);
- Shared<Animator>* shrAniamtor = new Shared<Animator>(new Animator(), Jin_Lua_Animator);
+ Animator* animator = new Animator();
+ Shared* shrAniamtor = new Shared(animator, Jin_Lua_Animator);
if (argc >= 1)
{
LuaObject* luaAnimation = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Animation);
- Shared<Animation>& shrAnimtion = luaAnimation->getShared<Animation>();
- (*shrAniamtor)->setAnimation(shrAnimtion.getObject());
+ Shared* shrAnimtion = luaAnimation->getShared();
+ animator->setAnimation(shrAnimtion->getObject<Animation>());
LuaObject* luaAnimator = luax_newinstance(L, Jin_Lua_Animator, shrAniamtor);
- luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, &shrAnimtion);
+ luaAnimator->setDependency((int)AnimatorDependency::DEP_ANIMATION, shrAnimtion);
return 1;
}
LuaObject* luaAnimator = luax_newinstance(L, Jin_Lua_Animator, shrAniamtor);
@@ -892,13 +892,13 @@ namespace JinEngine
// Delete temporary text.
delete text;
}
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TextureFont, new Shared<TextureFont>(textureFont, Jin_Lua_TextureFont));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_TextureFont, new Shared(textureFont, Jin_Lua_TextureFont));
return 1;
}
LUA_IMPLEMENT int l_newParticleSystem(lua_State* L)
{
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_ParticleSystem, new Shared<ParticleSystem>(new ParticleSystem(), Jin_Lua_ParticleSystem));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_ParticleSystem, new Shared(new ParticleSystem(), Jin_Lua_ParticleSystem));
return 1;
}
diff --git a/src/lua/modules/graphics/je_lua_page.cpp b/src/lua/modules/graphics/je_lua_page.cpp
index 6234f3f..6d84c4f 100644
--- a/src/lua/modules/graphics/je_lua_page.cpp
+++ b/src/lua/modules/graphics/je_lua_page.cpp
@@ -15,8 +15,6 @@ namespace JinEngine
const char* Jin_Lua_Page = "Page";
- typedef Shared<Font>& SharedFont;
-
Page* getPage(lua_State* L)
{
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Page);
diff --git a/src/lua/modules/graphics/je_lua_particle_system.cpp b/src/lua/modules/graphics/je_lua_particle_system.cpp
index 05be4b7..0b348ad 100644
--- a/src/lua/modules/graphics/je_lua_particle_system.cpp
+++ b/src/lua/modules/graphics/je_lua_particle_system.cpp
@@ -19,12 +19,10 @@ namespace JinEngine
const char* Jin_Lua_ParticleSystem = "ParticleSystem";
- typedef Shared<ParticleSystem>& SharedParticleSystem;
-
- LUA_IMPLEMENT inline SharedParticleSystem checkPS(lua_State* L)
+ LUA_IMPLEMENT inline ParticleSystem* checkPS(lua_State* L)
{
LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem);
- return luaObj->getShared<ParticleSystem>();
+ return luaObj->getObject<ParticleSystem>();
}
LUA_IMPLEMENT int l_gc(lua_State* L)
@@ -36,7 +34,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_update(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
float dt = luax_checknumber(L, 2);
ps->update(dt);
return 0;
@@ -44,14 +42,14 @@ namespace JinEngine
LUA_IMPLEMENT int l_render(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
ps->render();
return 0;
}
LUA_IMPLEMENT int l_setPosition(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
float x = luax_checknumber(L, 2);
float y = luax_checknumber(L, 3);
ps->setPosition(x, y);
@@ -60,7 +58,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setScale(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
float sx = luax_checknumber(L, 2);
float sy = luax_checknumber(L, 3);
//ps->setScale(sx, sy);
@@ -69,7 +67,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_pause(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
bool b = luax_checkbool(L, 2);
//ps->pause(b);
return 0;
@@ -77,14 +75,14 @@ namespace JinEngine
LUA_IMPLEMENT int l_clear(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
//ps->clear();
return 0;
}
LUA_IMPLEMENT int l_setEmitRate(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
if (luax_gettop(L) >= 3)
{
float floor = luax_checknumber(L, 2);
@@ -101,7 +99,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setEmitForce(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
if (luax_gettop(L) >= 3)
{
float floor = luax_checknumber(L, 2);
@@ -118,7 +116,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setEmitDirection(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
if (luax_gettop(L) >= 3)
{
float floor = luax_checknumber(L, 2);
@@ -135,7 +133,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setEmitPosition(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
if (luax_gettop(L) >= 3)
{
if (!luax_istable(L, 2))
@@ -172,7 +170,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setParticleLife(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
if (luax_gettop(L) >= 3)
{
float floor = luax_checknumber(L, 2);
@@ -189,7 +187,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setParticleLinearAccelaration(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
if (!luax_istable(L, 2))
{
luax_typerror(L, 2, "table");
@@ -204,7 +202,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setParticleRadialAccelaration(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
float ra = luax_checknumber(L, 2);
ps->setParticleRadialAccelaration(ra);
return 0;
@@ -212,7 +210,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setParticleAngularSpeed(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
if (luax_gettop(L) >= 3)
{
float floor = luax_checknumber(L, 2);
@@ -229,7 +227,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setParticleSpritesMode(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
int n = luax_checkinteger(L, 2);
SpriteMode mode = static_cast<SpriteMode>(n);
ps->setParticleSpritesMode(mode);
@@ -239,7 +237,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_addParticleSprite(lua_State* L)
{
LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem);
- SharedParticleSystem ps = obj->getShared<ParticleSystem>();
+ ParticleSystem* ps = obj->getObject<ParticleSystem>();
LuaObject* objSpr = luax_checkobject(L, 2, Jin_Lua_Sprite);
Sprite* spr = objSpr->getObject<Sprite>();
ps->addParticleSprite(spr);
@@ -251,7 +249,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_addParticleSprites(lua_State* L)
{
LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem);
- SharedParticleSystem ps = obj->getShared<ParticleSystem>();
+ ParticleSystem* ps = obj->getObject<ParticleSystem>();
if (!luax_istable(L, 2))
{
luax_typerror(L, 2, "sprites table");
@@ -275,7 +273,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_removeParticleSprite(lua_State* L)
{
LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem);
- SharedParticleSystem ps = obj->getShared<ParticleSystem>();
+ ParticleSystem* ps = obj->getObject<ParticleSystem>();
int n = luax_checkinteger(L, 2);
ps->removeParticleSprite(n);
(*obj).removeDependency((int)ParticleSystemDependency::DEP_SPRITES + n);
@@ -284,7 +282,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_enableParticleBlendAdditive(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
bool enable = luax_checkbool(L, 2);
ps->enableParticleBlendAdditive(enable);
return 0;
@@ -292,7 +290,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setParticleScale(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
float scale = luax_checknumber(L, 2);
ps->setParticleScale(scale);
return 0;
@@ -300,7 +298,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_addParticleScalePoint(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
float scale = luax_checknumber(L, 2);
float t = luax_checknumber(L, 3);
ps->addParticleScalePoint(scale, t);
@@ -309,7 +307,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_removeParticleScalePoint(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
int i = luax_checkinteger(L, 2);
ps->removeParticleScalePoint(i);
return 0;
@@ -317,7 +315,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setParticleColor(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
if (!luax_istable(L, 2))
{
luax_typerror(L, 2, "color table");
@@ -334,7 +332,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_addParticleColorPoint(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
if (!luax_istable(L, 2))
{
luax_typerror(L, 2, "color table");
@@ -352,7 +350,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_removeParticleColorPoint(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
int i = luax_checkinteger(L, 2);
ps->removeParticleColorPoint(i);
return 0;
@@ -360,7 +358,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setParticleTransparency(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
float transparency = luax_checknumber(L, 2);
ps->setParticleTransparency(transparency);
return 0;
@@ -368,7 +366,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_addParticleTransparencyPoint(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
float transparency = luax_checknumber(L, 2);
float t = luax_checknumber(L, 3);
ps->addParticleTransparencyPoint(transparency, t);
@@ -377,7 +375,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_removeParticleTransparencyPoint(lua_State* L)
{
- SharedParticleSystem ps = checkPS(L);
+ ParticleSystem* ps = checkPS(L);
int i = luax_checkinteger(L, 2);
ps->removeParticleTransparencyPoint(i);
return 0;
diff --git a/src/lua/modules/graphics/je_lua_shader.cpp b/src/lua/modules/graphics/je_lua_shader.cpp
index f4a4231..9505444 100644
--- a/src/lua/modules/graphics/je_lua_shader.cpp
+++ b/src/lua/modules/graphics/je_lua_shader.cpp
@@ -16,12 +16,10 @@ namespace JinEngine
const char* Jin_Lua_Shader = "Shader";
- typedef Shared<Shader>& ShaderRef;
-
- static inline ShaderRef checkShader(lua_State* L)
+ static inline Shader* checkShader(lua_State* L)
{
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Shader);
- return luaObj->getShared<Shader>();
+ return luaObj->getObject<Shader>();
}
/**
@@ -29,36 +27,34 @@ namespace JinEngine
*/
LUA_IMPLEMENT int l_sendNumber(lua_State* L)
{
- ShaderRef shared = checkShader(L);
+ Shader* shader = checkShader(L);
const char* variable = luax_checkstring(L, 2);
float number = luax_checknumber(L, 3);
- shared->sendFloat(variable, number);
+ shader->sendFloat(variable, number);
return 0;
}
LUA_IMPLEMENT int l_sendTexture(lua_State* L)
{
- ShaderRef shared = checkShader(L);
+ Shader* shader = checkShader(L);
const char* variable = luax_checkstring(L, 2);
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 3, Jin_Lua_Texture);
- Shared<Texture>& tex = luaObj->getShared<Texture>();
- shared->sendTexture(variable, tex.getObject());
+ shader->sendTexture(variable, luaObj->getObject<Texture>());
return 0;
}
LUA_IMPLEMENT int l_sendCanvas(lua_State* L)
{
- ShaderRef shared = checkShader(L);
+ Shader* shader = checkShader(L);
const char* variable = luax_checkstring(L, 2);
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 3, Jin_Lua_Canvas);
- Shared<Canvas>& canvas = luaObj->getShared<Canvas>();
- shared->sendCanvas(variable, canvas.getObject());
+ shader->sendCanvas(variable, luaObj->getObject<Canvas>());
return 0;
}
LUA_IMPLEMENT int l_sendVec2(lua_State* L)
{
- ShaderRef shared = checkShader(L);
+ Shader* shader = checkShader(L);
const char* variable = luax_checkstring(L, 2);
if (!luax_istable(L, 3))
{
@@ -67,13 +63,13 @@ namespace JinEngine
}
float x = luax_rawgetnumber(L, 3, 1);
float y = luax_rawgetnumber(L, 3, 2);
- shared->sendVec2(variable, x, y);
+ shader->sendVec2(variable, x, y);
return 0;
}
LUA_IMPLEMENT int l_sendVec3(lua_State* L)
{
- ShaderRef shared = checkShader(L);
+ Shader* shader = checkShader(L);
const char* variable = luax_checkstring(L, 2);
if (!luax_istable(L, 3))
{
@@ -83,13 +79,13 @@ namespace JinEngine
float x = luax_rawgetnumber(L, 3, 1);
float y = luax_rawgetnumber(L, 3, 2);
float z = luax_rawgetnumber(L, 3, 3);
- shared->sendVec3(variable, x, y, z);
+ shader->sendVec3(variable, x, y, z);
return 0;
}
LUA_IMPLEMENT int l_sendVec4(lua_State* L)
{
- ShaderRef shared = checkShader(L);
+ Shader* shader = checkShader(L);
const char* variable = luax_checkstring(L, 2);
if (!luax_istable(L, 3))
{
@@ -100,7 +96,7 @@ namespace JinEngine
float y = luax_rawgetnumber(L, 3, 2);
float z = luax_rawgetnumber(L, 3, 3);
float w = luax_rawgetnumber(L, 3, 4);
- shared->sendVec4(variable, x, y, z, w);
+ shader->sendVec4(variable, x, y, z, w);
return 0;
}
diff --git a/src/lua/modules/graphics/je_lua_sprite.cpp b/src/lua/modules/graphics/je_lua_sprite.cpp
index f9f8b5d..f1bc6aa 100644
--- a/src/lua/modules/graphics/je_lua_sprite.cpp
+++ b/src/lua/modules/graphics/je_lua_sprite.cpp
@@ -17,12 +17,10 @@ namespace JinEngine
{
const char* Jin_Lua_Sprite = "Sprite";
- typedef Shared<Sprite>& SharedSprite;
-
- LUA_IMPLEMENT inline SharedSprite checkSprite(lua_State* L)
+ LUA_IMPLEMENT inline Sprite* checkSprite(lua_State* L)
{
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Sprite);
- return luaObj->getShared<Sprite>();
+ return luaObj->getObject<Sprite>();
}
LUA_IMPLEMENT int l_gc(lua_State* L)
@@ -34,7 +32,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_render(lua_State* L)
{
- SharedSprite sprite = checkSprite(L);
+ Sprite* sprite = checkSprite(L);
float x = luax_checknumber(L, 2);
float y = luax_checknumber(L, 3);
float sx = luax_checknumber(L, 4);
@@ -46,7 +44,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_getSize(lua_State* L)
{
- SharedSprite sprite = checkSprite(L);
+ Sprite* sprite = checkSprite(L);
Vector2<int> size = sprite->getSize();
luax_pushinteger(L, size.x);
luax_pushinteger(L, size.y);
diff --git a/src/lua/modules/graphics/je_lua_spritesheet.cpp b/src/lua/modules/graphics/je_lua_spritesheet.cpp
index 23b655e..0cfdb93 100644
--- a/src/lua/modules/graphics/je_lua_spritesheet.cpp
+++ b/src/lua/modules/graphics/je_lua_spritesheet.cpp
@@ -27,7 +27,6 @@ namespace JinEngine
LUA_IMPLEMENT int l_newSprite(lua_State* L)
{
LuaObject* luaSSheet = (LuaObject*)luax_checktype(L, 1, Jin_Lua_SpriteSheet);
- Shared<SpriteSheet>& shrSSheet = luaSSheet->getShared<SpriteSheet>();
SpriteSheet* sheet = luaSSheet->getObject<SpriteSheet>();
Quad quad;
quad.x = luax_rawgetnumberthenpop(L, 2, 1);
@@ -48,9 +47,9 @@ namespace JinEngine
origin = static_cast<Origin>(o);
spr = sheet->createSprite(quad, origin);
}
- Shared<Sprite>* shrSprite = new Shared<Sprite>(spr, Jin_Lua_Sprite);
+ Shared* shrSprite = new Shared(spr, Jin_Lua_Sprite);
LuaObject* luaSprite = luax_newinstance(L, Jin_Lua_Sprite, shrSprite);
- luaSprite->setDependency((int)SpriteDependency::DEP_SPRITESHEET, &shrSSheet);
+ luaSprite->setDependency((int)SpriteDependency::DEP_SPRITESHEET, luaSSheet->getShared());
return 1;
}
@@ -58,7 +57,6 @@ namespace JinEngine
LUA_IMPLEMENT int l_newSprites(lua_State* L)
{
LuaObject* luaSS = (LuaObject*)luax_checktype(L, 1, Jin_Lua_SpriteSheet);
- Shared<SpriteSheet>& shrSS = luaSS->getShared<SpriteSheet>();
SpriteSheet* ss = luaSS->getObject<SpriteSheet>();
int count = luax_checkinteger(L, 2);
int r = luax_checkinteger(L, 3);
@@ -93,11 +91,11 @@ namespace JinEngine
return 1;
}
luax_newtable(L);
- SharedBase* shrGraphic = luaSS->getDependency((int)SpriteSheetDependency::DEP_GRAPHIC);
+ Shared* shrGraphic = luaSS->getDependency((int)SpriteSheetDependency::DEP_GRAPHIC);
for (int i = 0; i < sprs.size(); ++i)
{
Sprite* spr = sprs[i];
- Shared<Sprite>* shrSpr = new Shared<Sprite>(spr, Jin_Lua_Sprite);
+ Shared* shrSpr = new Shared(spr, Jin_Lua_Sprite);
LuaObject* luaSpr = (LuaObject*)luax_newinstance(L, Jin_Lua_Sprite, shrSpr);
luaSpr->setDependency((int)SpriteDependency::DEP_GRAPHIC, shrGraphic);
luax_rawseti(L, -2, i + 1);
diff --git a/src/lua/modules/graphics/je_lua_texture.cpp b/src/lua/modules/graphics/je_lua_texture.cpp
index 9d2d567..7bac237 100644
--- a/src/lua/modules/graphics/je_lua_texture.cpp
+++ b/src/lua/modules/graphics/je_lua_texture.cpp
@@ -12,31 +12,29 @@ namespace JinEngine
const char* Jin_Lua_Texture = "Texture";
- typedef Shared<Texture>& SharedTexture;
-
- LUA_IMPLEMENT inline SharedTexture checkTexture(lua_State* L)
+ LUA_IMPLEMENT inline Texture* checkTexture(lua_State* L)
{
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Texture);
- return luaObj->getShared<Texture>();
+ return luaObj->getObject<Texture>();
}
LUA_IMPLEMENT int l_getWidth(lua_State* L)
{
- SharedTexture shared = checkTexture(L);
+ Texture* shared = checkTexture(L);
luax_pushnumber(L, shared->getWidth());
return 1;
}
LUA_IMPLEMENT int l_getHeight(lua_State *L)
{
- SharedTexture shared = checkTexture(L);
+ Texture* shared = checkTexture(L);
luax_pushnumber(L, shared->getHeight());
return 1;
}
LUA_IMPLEMENT int l_getSize(lua_State* L)
{
- SharedTexture shared = checkTexture(L);
+ Texture* shared = checkTexture(L);
luax_pushnumber(L, shared->getWidth());
luax_pushnumber(L, shared->getHeight());
return 2;
diff --git a/src/lua/modules/graphics/je_lua_texture_font.cpp b/src/lua/modules/graphics/je_lua_texture_font.cpp
index 8a3eca0..1365aa8 100644
--- a/src/lua/modules/graphics/je_lua_texture_font.cpp
+++ b/src/lua/modules/graphics/je_lua_texture_font.cpp
@@ -26,7 +26,6 @@ namespace JinEngine
LUA_IMPLEMENT int l_typeset(lua_State* L)
{
LuaObject* luaTexFont = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TextureFont);
- Shared<TextureFont>& shrTexFont = luaTexFont->getShared<TextureFont>();
TextureFont* tf = luaTexFont->getObject<TextureFont>();
int lineheight = luax_checkinteger(L, 3);
int spacing = luax_optnumber(L, 4, 0);
@@ -44,9 +43,9 @@ namespace JinEngine
Text* text = p2->getObject<Text>();
page = tf->typeset(*text, lineheight, spacing);
}
- Shared<Page>* shrPage = new Shared<Page>(page, Jin_Lua_Page);
+ Shared* shrPage = new Shared(page, Jin_Lua_Page);
LuaObject* luaPage = luax_newinstance(L, Jin_Lua_Page, shrPage);
- luaPage->setDependency((int)PageDependency::DEP_TEXTURE_FONT, &shrTexFont);
+ luaPage->setDependency((int)PageDependency::DEP_TEXTURE_FONT, luaTexFont->getShared());
return 1;
}
diff --git a/src/lua/modules/graphics/je_lua_ttf.cpp b/src/lua/modules/graphics/je_lua_ttf.cpp
index 317670c..ad1872f 100644
--- a/src/lua/modules/graphics/je_lua_ttf.cpp
+++ b/src/lua/modules/graphics/je_lua_ttf.cpp
@@ -26,7 +26,6 @@ namespace JinEngine
LUA_IMPLEMENT int l_typeset(lua_State* L)
{
LuaObject* luaTTF = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TTF);
- Shared<TTF>& shrTTF = luaTTF->getShared<TTF>();
TTF* ttf = luaTTF->getObject<TTF>();
int lineheight = luax_optnumber(L, 3, ttf->getFontSize());
int spacing = luax_optnumber(L, 4, 0);
@@ -44,9 +43,9 @@ namespace JinEngine
Text* text = luaText->getObject<Text>();
page = ttf->typeset(*text, lineheight, spacing);
}
- Shared<Page>* refPage = new Shared<Page>(page, Jin_Lua_Page);
+ Shared* refPage = new Shared(page, Jin_Lua_Page);
LuaObject* luaPage = luax_newinstance(L, Jin_Lua_Page, refPage);
- luaPage->setDependency((int)PageDependency::DEP_TTF, &shrTTF);
+ luaPage->setDependency((int)PageDependency::DEP_TTF, luaTTF->getShared());
return 1;
}
diff --git a/src/lua/modules/graphics/je_lua_ttf_data.cpp b/src/lua/modules/graphics/je_lua_ttf_data.cpp
index 9f4437e..b10b993 100644
--- a/src/lua/modules/graphics/je_lua_ttf_data.cpp
+++ b/src/lua/modules/graphics/je_lua_ttf_data.cpp
@@ -19,12 +19,11 @@ namespace JinEngine
{
LuaObject* luaTTFData = (LuaObject*)luax_checktype(L, 1, Jin_Lua_TTFData);
int fontsize = luax_checkinteger(L, 2);
- Shared<TTFData>& shrFontData = luaTTFData->getShared<TTFData>();
- TTFData* fontData = shrFontData.getObject();
+ TTFData* fontData = luaTTFData->getObject<TTFData>();
TTF* font = fontData->createTTF(fontsize);
- Shared<TTF>* shrTTF = new Shared<TTF>(font, Jin_Lua_TTF);
+ Shared* shrTTF = new Shared(font, Jin_Lua_TTF);
LuaObject* luaTTF = luax_newinstance(L, Jin_Lua_TTF, shrTTF);
- luaTTF->setDependency((int)TTFDependency::DEP_TTFDATA, &shrFontData);
+ luaTTF->setDependency((int)TTFDependency::DEP_TTFDATA, luaTTFData->getShared());
return 1;
}