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_bitmap.cpp26
-rw-r--r--src/lua/modules/graphics/je_lua_canvas.cpp16
-rw-r--r--src/lua/modules/graphics/je_lua_graphics.cpp119
-rw-r--r--src/lua/modules/graphics/je_lua_page.cpp14
-rw-r--r--src/lua/modules/graphics/je_lua_shader.cpp22
-rw-r--r--src/lua/modules/graphics/je_lua_text.cpp8
-rw-r--r--src/lua/modules/graphics/je_lua_texture.cpp16
-rw-r--r--src/lua/modules/graphics/je_lua_texture_font.cpp10
-rw-r--r--src/lua/modules/graphics/je_lua_ttf.cpp14
-rw-r--r--src/lua/modules/graphics/je_lua_ttf_data.cpp14
10 files changed, 122 insertions, 137 deletions
diff --git a/src/lua/modules/graphics/je_lua_bitmap.cpp b/src/lua/modules/graphics/je_lua_bitmap.cpp
index 13517f9..a8d5bc0 100644
--- a/src/lua/modules/graphics/je_lua_bitmap.cpp
+++ b/src/lua/modules/graphics/je_lua_bitmap.cpp
@@ -1,31 +1,31 @@
+#include "lua/common/je_lua_common.h"
#include "lua/modules/luax.h"
#include "lua/modules/types.h"
-#include "lua/common/common.h"
#include "libjin/jin.h"
+using namespace JinEngine::Graphics;
+
namespace JinEngine
{
namespace Lua
{
- using namespace JinEngine::Graphics;
-
typedef Ref<Bitmap>& BitmapRef;
- static inline BitmapRef checkBitmap(lua_State* L)
+ LUA_IMPLEMENT inline BitmapRef checkBitmap(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_BITMAP);
return proxy->getRef<Bitmap>();
}
- static int l_gc(lua_State* L)
+ LUA_IMPLEMENT int l_gc(lua_State* L)
{
BitmapRef ref = checkBitmap(L);
ref.release();
return 0;
}
- static int l_getWidth(lua_State* L)
+ LUA_IMPLEMENT int l_getWidth(lua_State* L)
{
BitmapRef ref = checkBitmap(L);
int w = ref->getWidth();
@@ -33,7 +33,7 @@ namespace JinEngine
return 1;
}
- static int l_getHeight(lua_State* L)
+ LUA_IMPLEMENT int l_getHeight(lua_State* L)
{
BitmapRef ref = checkBitmap(L);
int h = ref->getHeight();
@@ -41,7 +41,7 @@ namespace JinEngine
return 1;
}
- static int l_getSize(lua_State* L)
+ LUA_IMPLEMENT int l_getSize(lua_State* L)
{
BitmapRef ref = checkBitmap(L);
int w = ref->getWidth();
@@ -51,7 +51,7 @@ namespace JinEngine
return 2;
}
- static int l_getPixel(lua_State* L)
+ LUA_IMPLEMENT int l_getPixel(lua_State* L)
{
BitmapRef ref = checkBitmap(L);
int x = luax_checkinteger(L, 2);
@@ -64,7 +64,7 @@ namespace JinEngine
return 4;
}
- static int l_setPixel(lua_State* L)
+ LUA_IMPLEMENT int l_setPixel(lua_State* L)
{
BitmapRef ref = checkBitmap(L);
int x = luax_checkinteger(L, 2);
@@ -82,7 +82,7 @@ namespace JinEngine
return 0;
}
- static int l_clone(lua_State* L)
+ LUA_IMPLEMENT int l_clone(lua_State* L)
{
BitmapRef ref = checkBitmap(L);
Bitmap* bitmap = ref.getObject();
@@ -92,7 +92,7 @@ namespace JinEngine
return 1;
}
- static const luaL_Reg f[] = {
+ LUA_IMPLEMENT const luaL_Reg f[] = {
{ "__gc", l_gc },
{ "getWidth", l_getWidth },
{ "getHeight", l_getHeight },
@@ -103,7 +103,7 @@ namespace JinEngine
{ 0, 0 }
};
- int luaopen_Bitmap(lua_State* L)
+ LUA_EXPORT int luaopen_Bitmap(lua_State* L)
{
luax_newtype(L, JIN_GRAPHICS_BITMAP, f);
return 0;
diff --git a/src/lua/modules/graphics/je_lua_canvas.cpp b/src/lua/modules/graphics/je_lua_canvas.cpp
index e49e209..9461c03 100644
--- a/src/lua/modules/graphics/je_lua_canvas.cpp
+++ b/src/lua/modules/graphics/je_lua_canvas.cpp
@@ -1,6 +1,6 @@
#include "lua/modules/luax.h"
#include "lua/modules/types.h"
-#include "lua/common/common.h"
+#include "lua/common/je_lua_common.h"
#include "libjin/jin.h"
namespace JinEngine
@@ -12,27 +12,27 @@ namespace JinEngine
typedef Ref<Canvas>& CanvasRef;
- static inline CanvasRef checkCanvas(lua_State* L)
+ LUA_IMPLEMENT inline CanvasRef checkCanvas(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_CANVAS);
return proxy->getRef<Canvas>();
}
- static int l_getWidth(lua_State* L)
+ LUA_IMPLEMENT int l_getWidth(lua_State* L)
{
CanvasRef ref = checkCanvas(L);
luax_pushnumber(L, ref->getWidth());
return 1;
}
- static int l_getHeight(lua_State* L)
+ LUA_IMPLEMENT int l_getHeight(lua_State* L)
{
CanvasRef ref = checkCanvas(L);
luax_pushnumber(L, ref->getHeight());
return 1;
}
- static int l_getSize(lua_State* L)
+ LUA_IMPLEMENT int l_getSize(lua_State* L)
{
CanvasRef ref = checkCanvas(L);
luax_pushnumber(L, ref->getWidth());
@@ -40,14 +40,14 @@ namespace JinEngine
return 2;
}
- static int l_gc(lua_State* L)
+ LUA_IMPLEMENT int l_gc(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_CANVAS);
proxy->release();
return 0;
}
- static const luaL_Reg f[] = {
+ LUA_IMPLEMENT const luaL_Reg f[] = {
{ "__gc", l_gc },
{ "getWidth", l_getWidth },
{ "getHeight", l_getHeight },
@@ -55,7 +55,7 @@ namespace JinEngine
{ 0, 0 }
};
- int luaopen_Canvas(lua_State* L)
+ LUA_EXPORT int luaopen_Canvas(lua_State* L)
{
luax_newtype(L, JIN_GRAPHICS_CANVAS, f);
return 0;
diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp
index f98d640..df68957 100644
--- a/src/lua/modules/graphics/je_lua_graphics.cpp
+++ b/src/lua/modules/graphics/je_lua_graphics.cpp
@@ -4,7 +4,7 @@
#include "libjin/jin.h"
#include "lua/modules/luax.h"
#include "lua/modules/types.h"
-#include "lua/common/common.h"
+#include "lua/common/je_lua_common.h"
using namespace std;
using namespace JinEngine;
@@ -27,7 +27,7 @@ namespace JinEngine
Font* defaultFont = nullptr;
} context;
- static int l_init(lua_State* L)
+ LUA_IMPLEMENT int l_init(lua_State* L)
{
Window* wnd = Window::get();
Window::Setting setting;
@@ -45,21 +45,6 @@ namespace JinEngine
{
/* load default font */
Bitmap* bitmap = Bitmap::createBitmap(default_font_bitmap, sizeof(default_font_bitmap));
- const Color* pixels = bitmap->getPixels();
- ofstream f = ofstream();
- f.open("font.pixels", ios_base::app);
- for (int y = 0; y < bitmap->getHeight(); ++y)
- {
- for (int x = 0; x < bitmap->getWidth(); ++x)
- {
- Color c = pixels[x + y * bitmap->getWidth()];
- f << (int)c.r << ",";
- f << (int)c.g << ",";
- f << (int)c.b << ",";
- f << (int)c.a << ",";
- }
- }
-
TextureFont* tf = TextureFont::createTextureFont(bitmap, Text(Encode::UTF8, default_charset), default_font_split, bitmap->getHeight());
context.defaultFont = tf;
delete bitmap;
@@ -70,7 +55,7 @@ namespace JinEngine
return 1;
}
- static int l_setTitle(lua_State* L)
+ LUA_IMPLEMENT int l_setTitle(lua_State* L)
{
Window* wnd = Window::get();
const char* title = luax_checkstring(L, 1);
@@ -78,14 +63,14 @@ namespace JinEngine
return 0;
}
- static int l_destroy(lua_State* L)
+ LUA_IMPLEMENT int l_destroy(lua_State* L)
{
Window* wnd = Window::get();
wnd->quit();
return 0;
}
- static int l_getSize(lua_State* L)
+ LUA_IMPLEMENT int l_getSize(lua_State* L)
{
Window* wnd = Window::get();
luax_pushnumber(L, wnd->getW());
@@ -93,21 +78,21 @@ namespace JinEngine
return 2;
}
- static int l_getWidth(lua_State* L)
+ LUA_IMPLEMENT int l_getWidth(lua_State* L)
{
Window* wnd = Window::get();
luax_pushnumber(L, wnd->getW());
return 1;
}
- static int l_getHeight(lua_State* L)
+ LUA_IMPLEMENT int l_getHeight(lua_State* L)
{
Window* wnd = Window::get();
luax_pushnumber(L, wnd->getH());
return 1;
}
- static int l_newBitmap(lua_State* L)
+ LUA_IMPLEMENT int l_newBitmap(lua_State* L)
{
Bitmap* bitmap = nullptr;
if (luax_gettop(L) == 2)
@@ -162,7 +147,7 @@ namespace JinEngine
}
/* jin.graphics.newTexture(bitmap) */
- static int l_newTexture(lua_State* L)
+ LUA_IMPLEMENT int l_newTexture(lua_State* L)
{
Texture* texture = nullptr;
if (luax_istype(L, 1, JIN_GRAPHICS_BITMAP))
@@ -182,7 +167,7 @@ namespace JinEngine
return 1;
}
- static int l_newShader(lua_State* L)
+ LUA_IMPLEMENT int l_newShader(lua_State* L)
{
const char* program = luax_checkstring(L, 1);
Shader* jsl = Shader::createShader(program);
@@ -197,7 +182,7 @@ namespace JinEngine
return 1;
}
- static int l_newShaderf(lua_State* L)
+ LUA_IMPLEMENT int l_newShaderf(lua_State* L)
{
const char* path = luax_checkstring(L, 1);
AssetDatabase* fs = AssetDatabase::get();
@@ -221,7 +206,7 @@ namespace JinEngine
return 1;
}
- static int l_newCanvas(lua_State* L)
+ LUA_IMPLEMENT int l_newCanvas(lua_State* L)
{
int w = luax_checknumber(L, 1);
int h = luax_checknumber(L, 2);
@@ -231,13 +216,13 @@ namespace JinEngine
return 1;
}
- static int l_clear(lua_State* L)
+ LUA_IMPLEMENT int l_clear(lua_State* L)
{
glClear(GL_COLOR_BUFFER_BIT);
return 0;
}
- static int l_setClearColor(lua_State* L)
+ LUA_IMPLEMENT int l_setClearColor(lua_State* L)
{
if (luax_gettop(L) == 0)
{
@@ -257,13 +242,13 @@ namespace JinEngine
return 0;
}
- static int l_present(lua_State* L)
+ LUA_IMPLEMENT int l_present(lua_State* L)
{
Window::get()->swapBuffers();
return 0;
}
- static void l_draw_texture(lua_State* L)
+ LUA_IMPLEMENT void l_draw_texture(lua_State* L)
{
if (!luax_istype(L, 1, JIN_GRAPHICS_TEXTURE))
return;
@@ -279,7 +264,7 @@ namespace JinEngine
tex->render(x, y, sx, sy, r, ox, oy);
}
- static void l_draw_canvas(lua_State* L)
+ LUA_IMPLEMENT void l_draw_canvas(lua_State* L)
{
if (!luax_istype(L, 1, JIN_GRAPHICS_CANVAS))
return;
@@ -296,7 +281,7 @@ namespace JinEngine
}
/* jin.graphics.draw(text, font, x, y) */
- static void l_draw_text(lua_State* L)
+ LUA_IMPLEMENT void l_draw_text(lua_State* L)
{
if (!luax_istype(L, 1, JIN_GRAPHICS_TEXT))
return;
@@ -326,7 +311,7 @@ namespace JinEngine
}
/* jin.graphics.draw(page, x, y) */
- static void l_draw_page(lua_State* L)
+ LUA_IMPLEMENT void l_draw_page(lua_State* L)
{
if (!luax_istype(L, 1, JIN_GRAPHICS_PAGE))
return;
@@ -338,7 +323,7 @@ namespace JinEngine
font->render(page, x, y);
}
- static int l_draw(lua_State* L)
+ LUA_IMPLEMENT int l_draw(lua_State* L)
{
if (luax_istype(L, 1, JIN_GRAPHICS_TEXTURE))
l_draw_texture(L);
@@ -357,7 +342,7 @@ namespace JinEngine
}
// draw(tex, quad, x, y, sx, sy, r, ax, ay)
- static int l_drawq(lua_State* L)
+ LUA_IMPLEMENT int l_drawq(lua_State* L)
{
if (!luax_istable(L, 2))
{
@@ -398,7 +383,7 @@ namespace JinEngine
/* print(string, x, y, lineheight, spacing) */
/* need set font */
- static int l_print(lua_State* L)
+ LUA_IMPLEMENT int l_print(lua_State* L)
{
Font* font = context.curFont;
if (font == nullptr)
@@ -414,7 +399,7 @@ namespace JinEngine
return 0;
}
- static int l_setColor(lua_State* L)
+ LUA_IMPLEMENT int l_setColor(lua_State* L)
{
if (luax_gettop(L) == 0)
{
@@ -436,7 +421,7 @@ namespace JinEngine
return 0;
}
- static int l_getColor(lua_State * L)
+ LUA_IMPLEMENT int l_getColor(lua_State * L)
{
luax_pushnumber(L, context.curRenderColor.r);
luax_pushnumber(L, context.curRenderColor.g);
@@ -445,7 +430,7 @@ namespace JinEngine
return 4;
}
- static int l_bindCanvas(lua_State* L)
+ LUA_IMPLEMENT int l_bindCanvas(lua_State* L)
{
if (luax_gettop(L) == 0)
{
@@ -459,13 +444,13 @@ namespace JinEngine
return 0;
}
- static int l_unbindCanvas(lua_State* L)
+ LUA_IMPLEMENT int l_unbindCanvas(lua_State* L)
{
Canvas::unbind();
return 0;
}
- static int l_useShader(lua_State* L)
+ LUA_IMPLEMENT int l_useShader(lua_State* L)
{
if (luax_gettop(L) == 0)
{
@@ -485,13 +470,13 @@ namespace JinEngine
return 0;
}
- static int l_setBlend(lua_State* L)
+ LUA_IMPLEMENT int l_setBlend(lua_State* L)
{
return 0;
}
- static RenderMode strtomode(const char* str)
+ LUA_IMPLEMENT RenderMode strtomode(const char* str)
{
std::string s = std::string(str);
if (s == "fill") return RenderMode::FILL;
@@ -499,7 +484,7 @@ namespace JinEngine
else return RenderMode::NONE;
}
- static int l_point(lua_State* L)
+ LUA_IMPLEMENT int l_point(lua_State* L)
{
int x = luax_checknumber(L, 1);
int y = luax_checknumber(L, 2);
@@ -508,7 +493,7 @@ namespace JinEngine
return 0;
}
- static int l_line(lua_State* L)
+ LUA_IMPLEMENT int l_line(lua_State* L)
{
int x1 = luax_checknumber(L, 1);
int y1 = luax_checknumber(L, 2);
@@ -519,7 +504,7 @@ namespace JinEngine
return 0;
}
- static int l_rect(lua_State* L)
+ LUA_IMPLEMENT int l_rect(lua_State* L)
{
const char* modestr = luax_checkstring(L, 1);
RenderMode mode = strtomode(modestr);
@@ -540,7 +525,7 @@ namespace JinEngine
return 0;
}
- static int l_circle(lua_State* L)
+ LUA_IMPLEMENT int l_circle(lua_State* L)
{
const char* modestr = luax_checkstring(L, 1);
RenderMode mode = strtomode(modestr);
@@ -560,7 +545,7 @@ namespace JinEngine
return 0;
}
- static int l_triangle(lua_State* L)
+ LUA_IMPLEMENT int l_triangle(lua_State* L)
{
const char* modestr = luax_checkstring(L, 1);
RenderMode mode = strtomode(modestr);
@@ -586,7 +571,7 @@ namespace JinEngine
return 0;
}
- static int l_polygon(lua_State* L)
+ LUA_IMPLEMENT int l_polygon(lua_State* L)
{
const char* modestr = luax_checkstring(L, 1);
int n = luax_checknumber(L, 2);
@@ -601,7 +586,7 @@ namespace JinEngine
int tn = luax_tableidxlen(L, 3);
if (tn != n * 2)
{
- static char* emsg = \
+ LUA_IMPLEMENT char* emsg = \
"number of polygon vertices doesn't match " \
"provided n, expect %d numbers but get %d";
luax_error(L, emsg, n * 2, tn);
@@ -621,7 +606,7 @@ namespace JinEngine
return 0;
}
- static int l_newTTFData(lua_State* L)
+ LUA_IMPLEMENT int l_newTTFData(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_newinstance(L, JIN_GRAPHICS_TTFDATA, sizeof(Proxy));
TTFData* fd = nullptr;
@@ -643,7 +628,7 @@ namespace JinEngine
}
/* newText(str[, encode]) */
- static int l_newText(lua_State* L)
+ LUA_IMPLEMENT int l_newText(lua_State* L)
{
Encode encode = Encode::UTF8;
if (luax_gettop(L) == 2)
@@ -667,7 +652,7 @@ namespace JinEngine
}
/* newTextureFont(bitmap, text, color | cellw, cellh) */
- static int l_newTextureFont(lua_State* L)
+ LUA_IMPLEMENT int l_newTextureFont(lua_State* L)
{
Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_BITMAP);
Bitmap* bitmap = p->getObject<Bitmap>();
@@ -719,7 +704,7 @@ namespace JinEngine
}
/* setFont(font) */
- static int l_setFont(lua_State* L)
+ LUA_IMPLEMENT int l_setFont(lua_State* L)
{
if (luax_istype(L, 1, JIN_GRAPHICS_TTF))
{
@@ -736,13 +721,13 @@ namespace JinEngine
return 0;
}
- static int l_unsetFont(lua_State* L)
+ LUA_IMPLEMENT int l_unsetFont(lua_State* L)
{
context.curFont = context.defaultFont;
return 0;
}
- static const luaL_Reg f[] = {
+ LUA_IMPLEMENT const luaL_Reg f[] = {
/* window */
{ "init", l_init },
{ "setTitle", l_setTitle },
@@ -786,17 +771,17 @@ namespace JinEngine
{ 0, 0 }
};
- extern int luaopen_Texture(lua_State* L);
- extern int luaopen_Text(lua_State* L);
- extern int luaopen_TTF(lua_State* L);
- extern int luaopen_TextureFont(lua_State* L);
- extern int luaopen_TTFData(lua_State* L);
- extern int luaopen_Page(lua_State* L);
- extern int luaopen_Canvas(lua_State* L);
- extern int luaopen_JSL(lua_State* L);
- extern int luaopen_Bitmap(lua_State* L);
+ LUA_PORT int luaopen_Texture(lua_State* L);
+ LUA_PORT int luaopen_Text(lua_State* L);
+ LUA_PORT int luaopen_TTF(lua_State* L);
+ LUA_PORT int luaopen_TextureFont(lua_State* L);
+ LUA_PORT int luaopen_TTFData(lua_State* L);
+ LUA_PORT int luaopen_Page(lua_State* L);
+ LUA_PORT int luaopen_Canvas(lua_State* L);
+ LUA_PORT int luaopen_JSL(lua_State* L);
+ LUA_PORT int luaopen_Bitmap(lua_State* L);
- int luaopen_graphics(lua_State* L)
+ LUA_EXPORT int luaopen_graphics(lua_State* L)
{
// register types
luaopen_Bitmap(L);
diff --git a/src/lua/modules/graphics/je_lua_page.cpp b/src/lua/modules/graphics/je_lua_page.cpp
index 8c9e918..2505ec5 100644
--- a/src/lua/modules/graphics/je_lua_page.cpp
+++ b/src/lua/modules/graphics/je_lua_page.cpp
@@ -1,6 +1,6 @@
#include "lua/modules/luax.h"
#include "lua/modules/types.h"
-#include "lua/common/common.h"
+#include "lua/common/je_lua_common.h"
#include "libjin/jin.h"
#include <iostream>
@@ -20,7 +20,7 @@ namespace JinEngine
return proxy->getObject<Page>();
}
- static int l_gc(lua_State* L)
+ LUA_IMPLEMENT int l_gc(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_PAGE);
{
@@ -33,7 +33,7 @@ namespace JinEngine
return 0;
}
- static int l_getSize(lua_State* L)
+ LUA_IMPLEMENT int l_getSize(lua_State* L)
{
Page* page = getPage(L);
luax_pushinteger(L, page->size.w);
@@ -41,21 +41,21 @@ namespace JinEngine
return 2;
}
- static int l_getWidth(lua_State* L)
+ LUA_IMPLEMENT int l_getWidth(lua_State* L)
{
Page* page = getPage(L);
luax_pushinteger(L, page->size.w);
return 1;
}
- static int l_getHeight(lua_State* L)
+ LUA_IMPLEMENT int l_getHeight(lua_State* L)
{
Page* page = getPage(L);
luax_pushinteger(L, page->size.h);
return 1;
}
- static const luaL_Reg f[] = {
+ LUA_IMPLEMENT const luaL_Reg f[] = {
{ "__gc", l_gc },
{ "getSize", l_getSize },
{ "getWidth", l_getWidth },
@@ -63,7 +63,7 @@ namespace JinEngine
{ 0, 0 }
};
- int luaopen_Page(lua_State* L)
+ LUA_EXPORT int luaopen_Page(lua_State* L)
{
luax_newtype(L, JIN_GRAPHICS_PAGE, f);
return 0;
diff --git a/src/lua/modules/graphics/je_lua_shader.cpp b/src/lua/modules/graphics/je_lua_shader.cpp
index d7733d4..6aa45e2 100644
--- a/src/lua/modules/graphics/je_lua_shader.cpp
+++ b/src/lua/modules/graphics/je_lua_shader.cpp
@@ -1,6 +1,6 @@
#include "lua/modules/luax.h"
#include "lua/modules/types.h"
-#include "lua/common/common.h"
+#include "lua/common/je_lua_common.h"
#include "libjin/jin.h"
namespace JinEngine
@@ -21,7 +21,7 @@ namespace JinEngine
/**
* jsl:sendNumber("variable", 0.1)
*/
- static int l_sendNumber (lua_State* L)
+ LUA_IMPLEMENT int l_sendNumber (lua_State* L)
{
ShaderRef ref = checkShader(L);
const char* variable = luax_checkstring(L, 2);
@@ -30,7 +30,7 @@ namespace JinEngine
return 0;
}
- static int l_sendTexture (lua_State* L)
+ LUA_IMPLEMENT int l_sendTexture (lua_State* L)
{
ShaderRef ref = checkShader(L);
const char* variable = luax_checkstring(L, 2);
@@ -40,7 +40,7 @@ namespace JinEngine
return 0;
}
- static int l_sendCanvas (lua_State* L)
+ LUA_IMPLEMENT int l_sendCanvas (lua_State* L)
{
ShaderRef ref = checkShader(L);
const char* variable = luax_checkstring(L, 2);
@@ -50,7 +50,7 @@ namespace JinEngine
return 0;
}
- static int l_sendVec2 (lua_State* L)
+ LUA_IMPLEMENT int l_sendVec2 (lua_State* L)
{
ShaderRef ref = checkShader(L);
const char* variable = luax_checkstring(L, 2);
@@ -65,7 +65,7 @@ namespace JinEngine
return 0;
}
- static int l_sendVec3 (lua_State* L)
+ LUA_IMPLEMENT int l_sendVec3 (lua_State* L)
{
ShaderRef ref = checkShader(L);
const char* variable = luax_checkstring(L, 2);
@@ -81,7 +81,7 @@ namespace JinEngine
return 0;
}
- static int l_sendVec4 (lua_State* L)
+ LUA_IMPLEMENT int l_sendVec4 (lua_State* L)
{
ShaderRef ref = checkShader(L);
const char* variable = luax_checkstring(L, 2);
@@ -98,19 +98,19 @@ namespace JinEngine
return 0;
}
- static int l_sendColor (lua_State* L)
+ LUA_IMPLEMENT int l_sendColor (lua_State* L)
{
return l_sendVec4(L);
}
- static int l_gc(lua_State* L)
+ LUA_IMPLEMENT int l_gc(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SHADER);
proxy->release();
return 0;
}
- static const luaL_Reg f[] = {
+ LUA_IMPLEMENT const luaL_Reg f[] = {
{ "__gc", l_gc },
{ "sendNumber", l_sendNumber },
{ "sendTexture", l_sendTexture },
@@ -125,7 +125,7 @@ namespace JinEngine
/**
* JSL program
*/
- int luaopen_JSL(lua_State* L)
+ LUA_EXPORT int luaopen_JSL(lua_State* L)
{
luax_newtype(L, JIN_GRAPHICS_SHADER, f);
return 0;
diff --git a/src/lua/modules/graphics/je_lua_text.cpp b/src/lua/modules/graphics/je_lua_text.cpp
index cbc82f1..34b0d77 100644
--- a/src/lua/modules/graphics/je_lua_text.cpp
+++ b/src/lua/modules/graphics/je_lua_text.cpp
@@ -1,6 +1,6 @@
#include "lua/modules/luax.h"
#include "lua/modules/types.h"
-#include "lua/common/common.h"
+#include "lua/common/je_lua_common.h"
#include "libjin/jin.h"
namespace JinEngine
@@ -10,19 +10,19 @@ namespace JinEngine
using namespace JinEngine::Graphics;
- static int l_gc(lua_State* L)
+ LUA_IMPLEMENT int l_gc(lua_State* L)
{
Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXT);
p->release();
return 0;
}
- static const luaL_Reg f[] = {
+ LUA_IMPLEMENT const luaL_Reg f[] = {
{ "__gc", l_gc },
{ 0, 0 }
};
- int luaopen_Text(lua_State* L)
+ LUA_EXPORT int luaopen_Text(lua_State* L)
{
luax_newtype(L, JIN_GRAPHICS_TEXT, f);
return 0;
diff --git a/src/lua/modules/graphics/je_lua_texture.cpp b/src/lua/modules/graphics/je_lua_texture.cpp
index 61bfaee..04d8f34 100644
--- a/src/lua/modules/graphics/je_lua_texture.cpp
+++ b/src/lua/modules/graphics/je_lua_texture.cpp
@@ -1,6 +1,6 @@
#include "lua/modules/luax.h"
#include "lua/modules/types.h"
-#include "lua/common/common.h"
+#include "lua/common/je_lua_common.h"
#include "libjin/jin.h"
namespace JinEngine
@@ -12,27 +12,27 @@ namespace JinEngine
typedef Ref<Texture>& TextureRef;
- static inline TextureRef checkTexture(lua_State* L)
+ LUA_IMPLEMENT inline TextureRef checkTexture(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTURE);
return proxy->getRef<Texture>();
}
- static int l_getWidth(lua_State* L)
+ LUA_IMPLEMENT int l_getWidth(lua_State* L)
{
TextureRef ref = checkTexture(L);
luax_pushnumber(L, ref->getWidth());
return 1;
}
- static int l_getHeight(lua_State *L)
+ LUA_IMPLEMENT int l_getHeight(lua_State *L)
{
TextureRef ref = checkTexture(L);
luax_pushnumber(L, ref->getHeight());
return 1;
}
- static int l_getSize(lua_State* L)
+ LUA_IMPLEMENT int l_getSize(lua_State* L)
{
TextureRef ref = checkTexture(L);
luax_pushnumber(L, ref->getWidth());
@@ -40,14 +40,14 @@ namespace JinEngine
return 2;
}
- static int l_gc(lua_State* L)
+ LUA_IMPLEMENT int l_gc(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTURE);
proxy->release();
return 0;
}
- static const luaL_Reg f[] = {
+ LUA_IMPLEMENT const luaL_Reg f[] = {
{ "__gc", l_gc },
{ "getWidth", l_getWidth },
{ "getHeight", l_getHeight },
@@ -55,7 +55,7 @@ namespace JinEngine
{ 0, 0 }
};
- int luaopen_Texture(lua_State* L)
+ LUA_EXPORT int luaopen_Texture(lua_State* L)
{
luax_newtype(L, JIN_GRAPHICS_TEXTURE, f);
return 0;
diff --git a/src/lua/modules/graphics/je_lua_texture_font.cpp b/src/lua/modules/graphics/je_lua_texture_font.cpp
index a2e88ba..c3b9f64 100644
--- a/src/lua/modules/graphics/je_lua_texture_font.cpp
+++ b/src/lua/modules/graphics/je_lua_texture_font.cpp
@@ -1,6 +1,6 @@
#include "lua/modules/luax.h"
#include "lua/modules/types.h"
-#include "lua/common/common.h"
+#include "lua/common/je_lua_common.h"
#include "libjin/jin.h"
namespace JinEngine
@@ -10,7 +10,7 @@ namespace JinEngine
using namespace JinEngine::Graphics;
- static int l_gc(lua_State* L)
+ LUA_IMPLEMENT int l_gc(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTUREFONT);
proxy->release();
@@ -18,7 +18,7 @@ namespace JinEngine
}
/* typeset(Text | string, lineheight, spacing) */
- static int l_typeset(lua_State* L)
+ LUA_IMPLEMENT int l_typeset(lua_State* L)
{
Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTUREFONT);
TextureFont* tf = p->getObject<TextureFont>();
@@ -50,13 +50,13 @@ namespace JinEngine
return 1;
}
- static const luaL_Reg f[] = {
+ LUA_IMPLEMENT const luaL_Reg f[] = {
{ "__gc", l_gc },
{ "typeset", l_typeset },
{ 0, 0 }
};
- int luaopen_TextureFont(lua_State* L)
+ LUA_EXPORT int luaopen_TextureFont(lua_State* L)
{
luax_newtype(L, JIN_GRAPHICS_TEXTUREFONT, f);
diff --git a/src/lua/modules/graphics/je_lua_ttf.cpp b/src/lua/modules/graphics/je_lua_ttf.cpp
index 414c7eb..2818b06 100644
--- a/src/lua/modules/graphics/je_lua_ttf.cpp
+++ b/src/lua/modules/graphics/je_lua_ttf.cpp
@@ -1,16 +1,16 @@
#include "lua/modules/luax.h"
#include "lua/modules/types.h"
-#include "lua/common/common.h"
+#include "lua/common/je_lua_common.h"
#include "libjin/jin.h"
+using namespace JinEngine::Graphics;
+
namespace JinEngine
{
namespace Lua
{
- using namespace JinEngine::Graphics;
-
- static int l_gc(lua_State* L)
+ LUA_IMPLEMENT int l_gc(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TTF);
{
@@ -24,7 +24,7 @@ namespace JinEngine
}
/* typeset(Text | string, lineheight, spacing) */
- static int l_typeset(lua_State* L)
+ LUA_IMPLEMENT int l_typeset(lua_State* L)
{
Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TTF);
TTF* ttf = p->getObject<TTF>();
@@ -56,13 +56,13 @@ namespace JinEngine
return 1;
}
- static const luaL_Reg f[] = {
+ LUA_IMPLEMENT const luaL_Reg f[] = {
{ "__gc", l_gc },
{ "typeset", l_typeset },
{ 0, 0 }
};
- int luaopen_TTF(lua_State* L)
+ LUA_EXPORT int luaopen_TTF(lua_State* L)
{
luax_newtype(L, JIN_GRAPHICS_TTF, f);
diff --git a/src/lua/modules/graphics/je_lua_ttf_data.cpp b/src/lua/modules/graphics/je_lua_ttf_data.cpp
index 43c3613..269789c 100644
--- a/src/lua/modules/graphics/je_lua_ttf_data.cpp
+++ b/src/lua/modules/graphics/je_lua_ttf_data.cpp
@@ -1,16 +1,16 @@
#include "lua/modules/luax.h"
#include "lua/modules/types.h"
-#include "lua/common/common.h"
+#include "lua/common/je_lua_common.h"
#include "libjin/jin.h"
+using namespace JinEngine::Graphics;
+
namespace JinEngine
{
namespace Lua
{
- using namespace JinEngine::Graphics;
-
- static int l_newTTF(lua_State* L)
+ LUA_IMPLEMENT int l_newTTF(lua_State* L)
{
Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TTFDATA);
int fontsize = luax_checkinteger(L, 2);
@@ -28,20 +28,20 @@ namespace JinEngine
return 1;
}
- static int l_gc(lua_State* L)
+ LUA_IMPLEMENT int l_gc(lua_State* L)
{
Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TTFDATA);
p->release();
return 0;
}
- static const luaL_Reg f[] = {
+ LUA_IMPLEMENT const luaL_Reg f[] = {
{ "__gc", l_gc },
{ "newTTF", l_newTTF },
{ 0, 0 }
};
- int luaopen_TTFData(lua_State* L)
+ LUA_EXPORT int luaopen_TTFData(lua_State* L)
{
luax_newtype(L, JIN_GRAPHICS_TTFDATA, f);
return 0;