aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libjin/Graphics/animations/je_animation.h2
-rw-r--r--src/libjin/Graphics/fonts/je_texture_font.h4
-rw-r--r--src/libjin/Graphics/je_canvas.h3
-rw-r--r--src/libjin/Graphics/je_graphic.cpp4
-rw-r--r--src/libjin/Graphics/je_graphic.h6
-rw-r--r--src/libjin/Graphics/je_graphics.h2
-rw-r--r--src/libjin/Graphics/je_image.h3
-rw-r--r--src/libjin/Graphics/je_sprite.cpp72
-rw-r--r--src/libjin/Graphics/je_sprite.h11
-rw-r--r--src/libjin/Graphics/je_texture.h3
-rw-r--r--src/libjin/Graphics/je_window.h3
-rw-r--r--src/lua/embed/scripts/graphics.lua.h12
-rw-r--r--src/lua/modules/graphics/je_lua_graphics.cpp17
-rw-r--r--src/lua/modules/graphics/je_lua_sprite.cpp220
-rw-r--r--src/lua/modules/graphics/je_lua_sprite.h42
-rw-r--r--src/lua/modules/graphics/je_lua_text.cpp4
-rw-r--r--src/lua/modules/graphics/je_lua_ttf.cpp23
-rw-r--r--src/lua/modules/graphics/je_lua_ttf.h39
-rw-r--r--src/lua/modules/types.h1
19 files changed, 440 insertions, 31 deletions
diff --git a/src/libjin/Graphics/animations/je_animation.h b/src/libjin/Graphics/animations/je_animation.h
index 3f9d008..05e1d4f 100644
--- a/src/libjin/Graphics/animations/je_animation.h
+++ b/src/libjin/Graphics/animations/je_animation.h
@@ -19,7 +19,7 @@ namespace JinEngine
class Animation
{
public:
- void onUpdate(float dt);
+ void update(float dt);
void start();
void pause();
diff --git a/src/libjin/Graphics/fonts/je_texture_font.h b/src/libjin/Graphics/fonts/je_texture_font.h
index df8f956..8a50699 100644
--- a/src/libjin/Graphics/fonts/je_texture_font.h
+++ b/src/libjin/Graphics/fonts/je_texture_font.h
@@ -23,7 +23,9 @@ namespace JinEngine
///
///
///
- class TextureFont : public Font, public Graphic
+ class TextureFont
+ : public Font
+ , public Graphic
{
public:
diff --git a/src/libjin/Graphics/je_canvas.h b/src/libjin/Graphics/je_canvas.h
index 952c25f..3964517 100644
--- a/src/libjin/Graphics/je_canvas.h
+++ b/src/libjin/Graphics/je_canvas.h
@@ -14,7 +14,8 @@ namespace JinEngine
///
/// A canvas is a rendering target.
///
- class Canvas: public Graphic
+ class Canvas
+ : public Graphic
{
public:
///
diff --git a/src/libjin/Graphics/je_graphic.cpp b/src/libjin/Graphics/je_graphic.cpp
index 73d46b3..1231139 100644
--- a/src/libjin/Graphics/je_graphic.cpp
+++ b/src/libjin/Graphics/je_graphic.cpp
@@ -43,7 +43,7 @@ namespace JinEngine
glDeleteTextures(1, &mTexture);
}
- void Graphic::render(int x, int y, float sx, float sy, float r, float ox, float oy)
+ void Graphic::render(int x, int y, float sx, float sy, float r, float ox, float oy) const
{
gl.ModelMatrix.setTransformation(x, y, r, sx, sy, ox, oy);
int w = getWidth(), h = getHeight();
@@ -71,7 +71,7 @@ namespace JinEngine
gl.bindTexture(0);
}
- void Graphic::render(const Math::Quad& slice, int x, int y, float sx, float sy, float r, float ax, float ay)
+ void Graphic::render(const Math::Quad& slice, int x, int y, float sx, float sy, float r, float ax, float ay) const
{
static float vertexCoords[8];
static float textureCoords[8];
diff --git a/src/libjin/Graphics/je_graphic.h b/src/libjin/Graphics/je_graphic.h
index fdc328d..91c8b44 100644
--- a/src/libjin/Graphics/je_graphic.h
+++ b/src/libjin/Graphics/je_graphic.h
@@ -60,15 +60,15 @@ namespace JinEngine
///
/// Render graphic single with given coordinates.
///
- void render(int x, int y, float sx = 1, float sy = 1, float r = 0, float ox = 0, float oy = 0);
+ void render(int x, int y, float sx = 1, float sy = 1, float r = 0, float ox = 0, float oy = 0) const;
///
/// Render part of graphic single with given coordinates.
///
- void render(const Math::Quad& slice, int x, int y, float sx = 1, float sy = 1, float r = 0, float ox = 0, float oy = 0);
+ void render(const Math::Quad& slice, int x, int y, float sx = 1, float sy = 1, float r = 0, float ox = 0, float oy = 0) const;
protected:
- JinEngine::Math::Vector2<uint> mSize;
+ Math::Vector2<uint> mSize;
private:
GLuint mTexture;
diff --git a/src/libjin/Graphics/je_graphics.h b/src/libjin/Graphics/je_graphics.h
index 52bfbda..a46e740 100644
--- a/src/libjin/Graphics/je_graphics.h
+++ b/src/libjin/Graphics/je_graphics.h
@@ -10,6 +10,7 @@
#include "je_window.h"
#include "je_bitmap.h"
#include "je_image.h"
+#include "je_sprite.h"
#include "shaders/je_shader.h"
@@ -19,7 +20,6 @@
#include "particles/je_particle_system.h"
-
//struct Stats
//{
// int drawCalls;
diff --git a/src/libjin/Graphics/je_image.h b/src/libjin/Graphics/je_image.h
index 15baed3..971ac18 100644
--- a/src/libjin/Graphics/je_image.h
+++ b/src/libjin/Graphics/je_image.h
@@ -13,7 +13,8 @@ namespace JinEngine
///
/// Just like bitmap but only from image file. The pixels data is readonly.
///
- class Image : public Bitmap
+ class Image
+ : public Bitmap
{
public:
///
diff --git a/src/libjin/Graphics/je_sprite.cpp b/src/libjin/Graphics/je_sprite.cpp
index 4ef32a4..9ee4fc1 100644
--- a/src/libjin/Graphics/je_sprite.cpp
+++ b/src/libjin/Graphics/je_sprite.cpp
@@ -12,6 +12,12 @@ namespace JinEngine
Sprite::Sprite()
: mShader(nullptr)
, mGraphic(nullptr)
+ , mScale(1, 1)
+ , mColor(255, 255, 255, 255)
+ {
+ }
+
+ Sprite::~Sprite()
{
}
@@ -22,37 +28,81 @@ namespace JinEngine
void Sprite::setOrigin(Origin origin)
{
-
+ int l = 0, r = 0, t = 0, b = 0;
+ if (mGraphic != nullptr)
+ {
+ r = mGraphic->getWidth();
+ b = mGraphic->getHeight();
+ }
+ switch (origin)
+ {
+ case TopLeft:
+ mOrigin.x = l;
+ mOrigin.y = t;
+ break;
+ case TopCenter:
+ mOrigin.x = r/2.f;
+ mOrigin.y = t;
+ break;
+ case TopRight:
+ mOrigin.x = r;
+ mOrigin.y = t;
+ break;
+ case MiddleLeft:
+ mOrigin.x = l;
+ mOrigin.y = b/2.f;
+ break;
+ case MiddleCenter:
+ mOrigin.x = r/2.f;
+ mOrigin.y = b/2.f;
+ break;
+ case MiddleRight:
+ mOrigin.x = r;
+ mOrigin.y = b/2.f;
+ break;
+ case BottomLeft:
+ mOrigin.x = l;
+ mOrigin.y = b;
+ break;
+ case BottomCenter:
+ mOrigin.x = r/2.f;
+ mOrigin.y = b;
+ break;
+ case BottomRight:
+ mOrigin.x = r;
+ mOrigin.y = b;
+ break;
+ }
}
void Sprite::setOrigin(int x, int y)
{
-
+ mOrigin.set(x, y);
}
void Sprite::setPosition(int x, int y)
{
-
+ mPosition.set(x, y);
}
void Sprite::setScale(float x, float y)
{
-
+ mScale.set(x, y);
}
void Sprite::setColor(Color color)
{
-
+ mColor = color;
}
- void Sprite::setShader(const Shader* shader)
+ void Sprite::setShader(Shader* shader)
{
-
+ mShader = shader;
}
void Sprite::setGraphic(const Graphic* graphic)
{
-
+ mGraphic = graphic;
}
void Sprite::render()
@@ -60,8 +110,10 @@ namespace JinEngine
Shader* shader = Shader::getCurrentShader();
Color c = gl.getColor();
gl.setColor(mColor);
- mShader->use();
- mGraphic->render(mPosition.x, mPosition.y, mScale.x, mScale.y, mRotation, mOrigin.x, mOrigin.y);
+ if(mShader != nullptr)
+ mShader->use();
+ if(mGraphic != nullptr)
+ mGraphic->render(mPosition.x, mPosition.y, mScale.x, mScale.y, mRotation, mOrigin.x, mOrigin.y);
shader->use();
gl.setColor(c);
}
diff --git a/src/libjin/Graphics/je_sprite.h b/src/libjin/Graphics/je_sprite.h
index 4fb7ebf..fad5b44 100644
--- a/src/libjin/Graphics/je_sprite.h
+++ b/src/libjin/Graphics/je_sprite.h
@@ -40,9 +40,15 @@ namespace JinEngine
void setPosition(int x, int y);
void setScale(float x, float y);
void setColor(Color color);
- void setShader(const Shaders::Shader* shader);
+ void setShader(Shaders::Shader* shader);
void setGraphic(const Graphic* graphic);
+ float getRotation() { return mRotation; }
+ const Math::Vector2<float>& getPosition() { return mPosition; }
+ const Math::Vector2<int>& getOrigin() { return mOrigin; }
+ const Math::Vector2<float>& getScale() { return mScale; }
+ const Color& getColor() { return mColor; }
+
///
/// Render callback.
///
@@ -55,10 +61,11 @@ namespace JinEngine
Math::Vector2<float> mPosition;
Math::Vector2<int> mOrigin;
Math::Vector2<float> mScale;
+
float mRotation;
Color mColor;
Shaders::Shader* mShader;
- Graphic* mGraphic;
+ const Graphic* mGraphic;
};
diff --git a/src/libjin/Graphics/je_texture.h b/src/libjin/Graphics/je_texture.h
index 0ab682d..566ba84 100644
--- a/src/libjin/Graphics/je_texture.h
+++ b/src/libjin/Graphics/je_texture.h
@@ -17,7 +17,8 @@ namespace JinEngine
///
///
///
- class Texture: public Graphic
+ class Texture
+ : public Graphic
{
public:
///
diff --git a/src/libjin/Graphics/je_window.h b/src/libjin/Graphics/je_window.h
index 436fd24..831f3e6 100644
--- a/src/libjin/Graphics/je_window.h
+++ b/src/libjin/Graphics/je_window.h
@@ -16,7 +16,8 @@ namespace JinEngine
///
///
///
- class Window : public Subsystem<Window>
+ class Window
+ : public Subsystem<Window>
{
public:
///
diff --git a/src/lua/embed/scripts/graphics.lua.h b/src/lua/embed/scripts/graphics.lua.h
index 751d029..e1079b9 100644
--- a/src/lua/embed/scripts/graphics.lua.h
+++ b/src/lua/embed/scripts/graphics.lua.h
@@ -9,6 +9,18 @@ jg.RenderMode = {
LINE = 2,
}
+jg.SpriteOrigin = {
+ TOPLEFT = 0,
+ TOPCENTER = 1,
+ TOPRIGHT = 2,
+ MIDDLELEFT = 3,
+ MIDDLECENTER = 4,
+ MIDDLERIGHT = 5,
+ BOTTOMLEFT = 6,
+ BOTTOMCENTER = 7,
+ BOTTOMRIGHT = 8
+}
+
local default_shader = nil
local default_shader_source = [[
#VERTEX_SHADER
diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp
index b1437e2..78674dd 100644
--- a/src/lua/modules/graphics/je_lua_graphics.cpp
+++ b/src/lua/modules/graphics/je_lua_graphics.cpp
@@ -6,6 +6,8 @@
#include "lua/modules/types.h"
#include "lua/common/je_lua_common.h"
+#include "je_lua_sprite.h"
+
using namespace std;
using namespace JinEngine;
using namespace JinEngine::Graphics;
@@ -19,7 +21,7 @@ namespace JinEngine
{
#include "../../resources/font.ttf.h"
-
+
static struct
{
Color curRenderColor;
@@ -634,7 +636,7 @@ namespace JinEngine
proxy->bind(new Shared<TTFData>(fd, JIN_GRAPHICS_TTFDATA));
return 1;
}
-
+
/* newText(str[, encode]) */
LUA_IMPLEMENT int l_newText(lua_State* L)
{
@@ -659,6 +661,13 @@ namespace JinEngine
return 1;
}
+ LUA_IMPLEMENT int l_newSprite(lua_State* L)
+ {
+ Proxy* p = luax_newinstance(L, JIN_GRAPHICS_SPRITE);
+ p->bind(new Shared<Lua::Sprite>(new Lua::Sprite(), JIN_GRAPHICS_SPRITE));
+ return 1;
+ }
+
/* newTextureFont(bitmap, text, color | cellw, cellh) */
LUA_IMPLEMENT int l_newTextureFont(lua_State* L)
{
@@ -746,6 +755,7 @@ namespace JinEngine
luax_newclass(L, luaopen_TextureFont);
luax_newclass(L, luaopen_Page);
luax_newclass(L, luaopen_JSL);
+ luax_newclass(L, luaopen_Sprite);
luaL_Reg f[] = {
/* window */
@@ -766,6 +776,7 @@ namespace JinEngine
{ "newTTFData", l_newTTFData },
{ "newText", l_newText },
{ "newTextureFont", l_newTextureFont },
+ { "newSprite", l_newSprite },
/* render */
{ "setClearColor", l_setClearColor },
{ "clear", l_clear },
@@ -793,7 +804,7 @@ namespace JinEngine
{ 0, 0 }
};
- // load whole lib
+ // Load whole lib.
luax_newlib(L, f);
return 1;
diff --git a/src/lua/modules/graphics/je_lua_sprite.cpp b/src/lua/modules/graphics/je_lua_sprite.cpp
index d87f23b..f02d1cc 100644
--- a/src/lua/modules/graphics/je_lua_sprite.cpp
+++ b/src/lua/modules/graphics/je_lua_sprite.cpp
@@ -1,11 +1,227 @@
+#include "lua/modules/luax.h"
+#include "lua/modules/types.h"
+#include "lua/common/je_lua_common.h"
#include "libjin/jin.h"
+#include "je_lua_sprite.h"
+
+using namespace JinEngine::Graphics;
+using namespace JinEngine::Graphics::Shaders;
namespace JinEngine
{
namespace Lua
{
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // Sprite class.
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ Lua::Sprite::~Sprite()
+ {
+ if (mGraphicShared != nullptr)
+ {
+ mGraphicShared->release();
+ mGraphicShared = nullptr;
+ }
+ if (mShaderShared != nullptr)
+ {
+ mShaderShared->release();
+ mShaderShared = nullptr;
+ }
+ }
+
+ void Lua::Sprite::setShader(Shared<Shader>* shader)
+ {
+ if (mShaderShared != nullptr)
+ mShaderShared->release();
+ mShaderShared = shader;
+ mShaderShared->retain();
+ Parent::setShader(mShaderShared->getObject());
+ }
+
+ void Lua::Sprite::setGraphic(Shared<Graphic>* graphic)
+ {
+ if (mGraphicShared != nullptr)
+ mGraphicShared = graphic;
+ mGraphicShared = graphic;
+ mGraphicShared->retain();
+ Parent::setGraphic(mGraphicShared->getObject());
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // Register Sprite class.
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ typedef Shared<Lua::Sprite>& SharedSprite;
+
+ LUA_IMPLEMENT inline SharedSprite checkSprite(lua_State* L)
+ {
+ Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SPRITE);
+ return proxy->getShared<Lua::Sprite>();
+ }
+
+ LUA_IMPLEMENT int l_gc(lua_State* L)
+ {
+ Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SPRITE);
+ p->release();
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setRotation(lua_State* L)
+ {
+ SharedSprite sprite = checkSprite(L);
+ float r = luax_checknumber(L, 2);
+ sprite->setRotation(r);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setOrigin(lua_State* L)
+ {
+ SharedSprite sprite = checkSprite(L);
+ switch (luax_gettop(L))
+ {
+ case 2:
+ {
+ int origin = luax_checkinteger(L, 2);
+ sprite->setOrigin(static_cast<Lua::Sprite::Origin>(origin));
+ }
+ break;
+ case 3:
+ {
+ int x = luax_checkinteger(L, 2);
+ int y = luax_checkinteger(L, 3);
+ sprite->setOrigin(x, y);
+ }
+ break;
+ }
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setPosition(lua_State* L)
+ {
+ SharedSprite sprite = checkSprite(L);
+ int x = luax_checkinteger(L, 2);
+ int y = luax_checkinteger(L, 3);
+ sprite->setPosition(x, y);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setScale(lua_State* L)
+ {
+ SharedSprite sprite = checkSprite(L);
+ float sx = luax_checknumber(L, 2);
+ float sy = luax_checknumber(L, 3);
+ sprite->setScale(sx, sy);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setColor(lua_State* L)
+ {
+ SharedSprite sprite = checkSprite(L);
+ Channel r = luax_checkinteger(L, 2);
+ Channel g = luax_checkinteger(L, 3);
+ Channel b = luax_checkinteger(L, 4);
+ Channel a = luax_checkinteger(L, 5);
+ sprite->setColor(Color(r, g, b, a));
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setShader(lua_State* L)
+ {
+ SharedSprite sprite = checkSprite(L);
+ Proxy* proxy = (Proxy*)luax_checktype(L, 2, JIN_GRAPHICS_SHADER);
+ sprite->setShader(&proxy->getShared<Shader>());
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setGraphic(lua_State* L)
+ {
+ SharedSprite sprite = checkSprite(L);
+ Graphic* graphic = nullptr;
+ Proxy* p = nullptr;
+ if (luax_istype(L, 2, JIN_GRAPHICS_TEXTURE))
+ p = (Proxy*)luax_checktype(L, 2, JIN_GRAPHICS_TEXTURE);
+ else if (luax_istype(L, 2, JIN_GRAPHICS_CANVAS))
+ p = (Proxy*)luax_checktype(L, 2, JIN_GRAPHICS_CANVAS);
+ if(p != nullptr)
+ sprite->setGraphic(&p->getShared<Graphic>());
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_getRotation(lua_State* L)
+ {
+ SharedSprite sprite = checkSprite(L);
+ float r = sprite->getRotation();
+ luax_pushnumber(L, r);
+ return 1;
+ }
+
+ LUA_IMPLEMENT int l_getPosition(lua_State* L)
+ {
+ SharedSprite sprite = checkSprite(L);
+ const Math::Vector2<float>& pos = sprite->getPosition();
+ luax_pushnumber(L, pos.x);
+ luax_pushnumber(L, pos.y);
+ return 2;
+ }
+
+ LUA_IMPLEMENT int l_getOrigin(lua_State* L)
+ {
+ SharedSprite sprite = checkSprite(L);
+ const Math::Vector2<int>& origin = sprite->getOrigin();
+ luax_pushinteger(L, origin.x);
+ luax_pushinteger(L, origin.y);
+ return 2;
+ }
+
+ LUA_IMPLEMENT int l_getScale(lua_State* L)
+ {
+ SharedSprite sprite = checkSprite(L);
+ const Math::Vector2<float> scale = sprite->getScale();
+ luax_pushnumber(L, scale.x);
+ luax_pushnumber(L, scale.y);
+ return 2;
+ }
+
+ LUA_IMPLEMENT int l_getColor(lua_State* L)
+ {
+ SharedSprite sprite = checkSprite(L);
+ const Color& c = sprite->getColor();
+ luax_pushinteger(L, c.r);
+ luax_pushinteger(L, c.g);
+ luax_pushinteger(L, c.b);
+ luax_pushinteger(L, c.a);
+ return 4;
+ }
+ LUA_IMPLEMENT int l_render(lua_State* L)
+ {
+ SharedSprite sprite = checkSprite(L);
+ sprite->render();
+ return 0;
+ }
+ LUA_EXPORT int luaopen_Sprite(lua_State* L)
+ {
+ luaL_Reg methods[] = {
+ { "__gc", l_gc },
+ { "render", l_render },
+ { "setRotation", l_setRotation },
+ { "setOrigin", l_setOrigin },
+ { "setPosition", l_setPosition },
+ { "setScale", l_setScale },
+ { "setColor", l_setColor },
+ { "setShader", l_setShader },
+ { "setGraphic", l_setGraphic },
+ { "getRotation", l_getRotation },
+ { "getPosition", l_getPosition },
+ { "getOrigin", l_getOrigin },
+ { "getScale", l_getScale },
+ { "getColor", l_getColor },
+ { 0, 0 }
+ };
+ luax_newtype(L, JIN_GRAPHICS_SPRITE, methods);
+ return 0;
+ }
- } // namespace JinEngine
-} // namespace Lua \ No newline at end of file
+ } // namespace Lua
+} // namespace JinEngine \ No newline at end of file
diff --git a/src/lua/modules/graphics/je_lua_sprite.h b/src/lua/modules/graphics/je_lua_sprite.h
new file mode 100644
index 0000000..ded237e
--- /dev/null
+++ b/src/lua/modules/graphics/je_lua_sprite.h
@@ -0,0 +1,42 @@
+#ifndef __JE_LUA_SPRITE_H__
+#define __JE_LUA_SPRITE_H__
+
+#include "../../common/je_lua_shared.hpp"
+
+#include "libjin/jin.h"
+
+namespace JinEngine
+{
+ namespace Lua
+ {
+
+ class Sprite
+ : public Graphics::Sprite
+ {
+ public:
+ ~Sprite();
+
+ void setShader(Shared<Graphics::Shaders::Shader>* shader);
+
+ void setGraphic(Shared<Graphics::Graphic>* graphic);
+
+ private:
+
+ using Parent = Graphics::Sprite;
+
+ ///
+ ///
+ ///
+ Shared<Graphics::Graphic>* mGraphicShared;
+
+ ///
+ ///
+ ///
+ Shared<Graphics::Shaders::Shader>* mShaderShared;
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/src/lua/modules/graphics/je_lua_text.cpp b/src/lua/modules/graphics/je_lua_text.cpp
index 4d6db5f..3316a4c 100644
--- a/src/lua/modules/graphics/je_lua_text.cpp
+++ b/src/lua/modules/graphics/je_lua_text.cpp
@@ -20,8 +20,8 @@ namespace JinEngine
LUA_EXPORT int luaopen_Text(lua_State* L)
{
luaL_Reg f[] = {
- { "__gc", l_gc },
- { 0, 0 }
+ { "__gc", l_gc },
+ { 0, 0 }
};
luax_newtype(L, JIN_GRAPHICS_TEXT, f);
return 0;
diff --git a/src/lua/modules/graphics/je_lua_ttf.cpp b/src/lua/modules/graphics/je_lua_ttf.cpp
index 4e47906..31af310 100644
--- a/src/lua/modules/graphics/je_lua_ttf.cpp
+++ b/src/lua/modules/graphics/je_lua_ttf.cpp
@@ -2,6 +2,7 @@
#include "lua/modules/types.h"
#include "lua/common/je_lua_common.h"
#include "libjin/jin.h"
+#include "je_lua_ttf.h"
using namespace JinEngine::Graphics;
using namespace JinEngine::Graphics::Fonts;
@@ -11,6 +12,28 @@ namespace JinEngine
namespace Lua
{
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // TTFData
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ TTF* TTFData::createTTF(unsigned fontSize)
+ {
+ TTF* ttf;
+ try
+ {
+ ttf = new TTF(this, fontSize);
+ }
+ catch (...)
+ {
+ return nullptr;
+ }
+ return ttf;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // TTF
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////
+
LUA_IMPLEMENT int l_gc(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TTF);
diff --git a/src/lua/modules/graphics/je_lua_ttf.h b/src/lua/modules/graphics/je_lua_ttf.h
new file mode 100644
index 0000000..7673d67
--- /dev/null
+++ b/src/lua/modules/graphics/je_lua_ttf.h
@@ -0,0 +1,39 @@
+#ifndef __JE_LUA_TTF_H__
+#define __JE_LUA_TTF_H__
+
+#include "../../common/je_lua_shared.hpp"
+
+#include "libjin/jin.h"
+
+namespace JinEngine
+{
+ namespace Lua
+ {
+
+ class TTFData
+ : public Graphics::Fonts::TTFData
+ {
+ public:
+ TTF * createTTF(unsigned fontSize);
+
+ private:
+ using Parent = Graphics::Fonts::TTFData;
+
+ };
+
+ class TTF
+ : public Graphics::Fonts::TTF
+ {
+ public:
+
+ private:
+ using Parent = Graphics::Fonts::TTF;
+
+ Shared<Graphics::Fonts::TTFData>* ttfDataShared;
+
+ };
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/src/lua/modules/types.h b/src/lua/modules/types.h
index 1ed1016..326b5f2 100644
--- a/src/lua/modules/types.h
+++ b/src/lua/modules/types.h
@@ -11,6 +11,7 @@
#define JIN_GRAPHICS_TEXTUREFONT "TextureFont"
#define JIN_GRAPHICS_PAGE "Page"
#define JIN_GRAPHICS_BITMAP "Bitmap"
+#define JIN_GRAPHICS_SPRITE "Sprite"
// audio module
#define JIN_AUDIO_SOURCE "Source"