aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libjin/Common/Singleton.hpp3
-rw-r--r--src/libjin/Core/game.cpp74
-rw-r--r--src/libjin/Debug/Debug.h6
-rw-r--r--src/libjin/Debug/Log.h14
-rw-r--r--src/libjin/Graphics/Drawable.h1
-rw-r--r--src/libjin/Graphics/JSL.cpp29
-rw-r--r--src/libjin/Graphics/Texture.h4
-rw-r--r--src/libjin/debug/debug.h6
-rw-r--r--src/libjin/debug/log.h14
-rw-r--r--src/lua/modules/embed/boot.lua.h42
-rw-r--r--src/lua/modules/embed/embed.h18
-rw-r--r--src/lua/modules/graphics/graphics.cpp56
-rw-r--r--src/lua/modules/graphics/jsl.cpp164
-rw-r--r--src/lua/modules/graphics/texture.cpp (renamed from src/lua/modules/graphics/image.cpp)25
-rw-r--r--src/lua/modules/types.h28
15 files changed, 247 insertions, 237 deletions
diff --git a/src/libjin/Common/Singleton.hpp b/src/libjin/Common/Singleton.hpp
index 48cd5bc..b817901 100644
--- a/src/libjin/Common/Singleton.hpp
+++ b/src/libjin/Common/Singleton.hpp
@@ -30,8 +30,7 @@ namespace jin
template<class T> T* Singleton<T>::_instance = nullptr;
-#define SINGLETON(T) \
- friend Singleton<T>
+#define SINGLETON(T) friend Singleton<T>
} // jin
diff --git a/src/libjin/Core/game.cpp b/src/libjin/Core/game.cpp
new file mode 100644
index 0000000..3f905f2
--- /dev/null
+++ b/src/libjin/Core/game.cpp
@@ -0,0 +1,74 @@
+#include "game.h"
+#include "../Time/Timer.h"
+#include "../input/Event.h"
+#include "../Graphics/Window.h"
+#include "../Math/Math.h"
+#include <iostream>
+
+namespace jin
+{
+namespace core
+{
+
+ using namespace jin::graphics;
+ using namespace jin::input;
+ using namespace jin::time;
+ using namespace jin::math;
+
+ Game::Game() :_running(true) {};
+
+ void Game::run()
+ {
+ if (_onLoad != nullptr)
+ _onLoad();
+ Window* wnd = Window::get();
+ const int FPS = wnd ? wnd->getFPS() : 60;
+ const int MS_PER_UPDATE = 1000.0f / FPS;
+ _running = true;
+ Event e;
+ int previous = getMilliSecond();
+ int dt = MS_PER_UPDATE;
+ while (_running)
+ {
+ while (jin::input::pollEvent(&e))
+ {
+ if (_onEvent != nullptr)
+ _onEvent(&e);
+ if (!_running) goto quitloop;
+ }
+ if (_onUpdate != nullptr) _onUpdate(dt);
+ if (_onDraw != nullptr) _onDraw();
+ wnd->swapBuffers();
+ const int current = getMilliSecond();
+ dt = current - previous;
+ const int wait = MS_PER_UPDATE - (current - previous);
+ previous += MS_PER_UPDATE;
+ if (wait > 0)
+ {
+ sleep(wait);
+ dt = MS_PER_UPDATE;
+ }
+ else
+ previous = current;
+ }
+ quitloop:;
+ }
+
+ bool Game::initSystem(const SettingBase* setting)
+ {
+ if (setting == nullptr)
+ return false;
+ Game::Setting* s = (Game::Setting*) setting;
+ _onEvent = s->eventHandler;
+ _onUpdate = s->updater;
+ _onDraw = s->drawer;
+ _onLoad = s->loader;
+ return true;
+ }
+
+ void Game::quitSystem()
+ {
+ }
+
+} // core
+} // jin \ No newline at end of file
diff --git a/src/libjin/Debug/Debug.h b/src/libjin/Debug/Debug.h
deleted file mode 100644
index 9fa9fe1..0000000
--- a/src/libjin/Debug/Debug.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __JIN_DEBUG_H
-#define __JIN_DEBUG_H
-
-
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Debug/Log.h b/src/libjin/Debug/Log.h
deleted file mode 100644
index e1624f5..0000000
--- a/src/libjin/Debug/Log.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __JIN_LOG_H
-#define __JIN_LOG_H
-
-namespace jin
-{
-namespace debug
-{
-
- const char* err;
-
-}
-}
-
-#endif \ No newline at end of file
diff --git a/src/libjin/Graphics/Drawable.h b/src/libjin/Graphics/Drawable.h
index e04ac6b..4e91adb 100644
--- a/src/libjin/Graphics/Drawable.h
+++ b/src/libjin/Graphics/Drawable.h
@@ -41,6 +41,7 @@ namespace graphics
void setVertices(float* v, float* t);
GLuint texture;
+ GLuint vbo;
int width, height;
diff --git a/src/libjin/Graphics/JSL.cpp b/src/libjin/Graphics/JSL.cpp
index 2ab7ceb..fb6279a 100644
--- a/src/libjin/Graphics/JSL.cpp
+++ b/src/libjin/Graphics/JSL.cpp
@@ -7,20 +7,21 @@ namespace jin
{
namespace graphics
{
- //vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords)
- static const char* base_f = " "
- //"#version 120 \n"
- "#define number float \n"
- "#define Image sampler2D \n"
- "#define Canvas sampler2D \n"
- "#define Color vec4 \n"
- "#define Texel texture2D \n"
- "#define extern uniform \n"
- "uniform Image _tex0_; \n"
- "%s \n"
- "void main(){ \n"
- " gl_FragColor = effect(gl_Color, _tex0_, gl_TexCoord[0].xy, gl_FragCoord.xy);\n"
- "}\0";
+
+ static const char* base_f = R"base_f(
+#define number float
+#define Texture sampler2D
+#define Canvas sampler2D
+#define Color vec4
+#define Texel texture2D
+#define extern uniform
+uniform Texture _tex0_;
+%s
+void main()
+{
+ gl_FragColor = effect(gl_Color, _tex0_, gl_TexCoord[0].xy, gl_FragCoord.xy);
+}
+ )base_f";
/*static*/ JSLProgram* JSLProgram::currentJSLProgram = nullptr;
diff --git a/src/libjin/Graphics/Texture.h b/src/libjin/Graphics/Texture.h
index 47f8d53..1e7a2f5 100644
--- a/src/libjin/Graphics/Texture.h
+++ b/src/libjin/Graphics/Texture.h
@@ -33,8 +33,8 @@ namespace graphics
};
-}
-}
+} // graphics
+} // jin
#endif // JIN_MODULES_RENDER
#endif // __JIN_IMAGE_H \ No newline at end of file
diff --git a/src/libjin/debug/debug.h b/src/libjin/debug/debug.h
deleted file mode 100644
index 9fa9fe1..0000000
--- a/src/libjin/debug/debug.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __JIN_DEBUG_H
-#define __JIN_DEBUG_H
-
-
-
-#endif \ No newline at end of file
diff --git a/src/libjin/debug/log.h b/src/libjin/debug/log.h
deleted file mode 100644
index e1624f5..0000000
--- a/src/libjin/debug/log.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __JIN_LOG_H
-#define __JIN_LOG_H
-
-namespace jin
-{
-namespace debug
-{
-
- const char* err;
-
-}
-}
-
-#endif \ No newline at end of file
diff --git a/src/lua/modules/embed/boot.lua.h b/src/lua/modules/embed/boot.lua.h
index 4f8ed94..cc71102 100644
--- a/src/lua/modules/embed/boot.lua.h
+++ b/src/lua/modules/embed/boot.lua.h
@@ -37,16 +37,6 @@ local function call(func, ...)
end
end
-jin.core.setHandler = function(handler)
- if handler == nil then
- return
- end
- jin.core.onLoad = handler.onLoad
- jin.core.onEvent = handler.onEvent
- jin.core.onUpdate = handler.onUpdate
- jin.core.onDraw = handler.onDraw
-end
-
function jin.core.run()
call(jin.core.onLoad)
local dt = 0
@@ -64,21 +54,12 @@ function jin.core.run()
end
previous = current
current = jin.time.second()
- dt = dt + current - previous
- local refresh = false
- while dt > SECOND_PER_FRAME do
- call(jin.core.onUpdate, SECOND_PER_FRAME)
- dt = dt - SECOND_PER_FRAME
- refresh = true
- end
- if refresh and jin.graphics then
- jin.graphics.clear()
- call(jin.core.onDraw)
- jin.graphics.present()
- end
- if jin.time then
- jin.time.sleep(0.001)
- end
+ dt = current - previous
+ call(jin.core.onUpdate, dt)
+ call(jin.graphics.clear)
+ call(jin.core.onDraw)
+ call(jin.graphics.present)
+ call(jin.time.sleep, 0.001)
end
end
@@ -86,6 +67,16 @@ end
-- No game handler
-------------------------------------------------------------------------
+jin.core.setHandler = function(handler)
+ if handler == nil then
+ return
+ end
+ jin.core.onLoad = handler.onLoad
+ jin.core.onEvent = handler.onEvent
+ jin.core.onUpdate = handler.onUpdate
+ jin.core.onDraw = handler.onDraw
+end
+
jin.nogame = {
cs = 64,
sw = jin.graphics.getWidth(),
@@ -108,6 +99,7 @@ jin.nogame = {
end
end,
onUpdate = function(dt)
+ print(dt)
local nogame = jin.nogame
nogame.t = nogame.t + dt * nogame.speed
if nogame.t > nogame.ww2 then
diff --git a/src/lua/modules/embed/embed.h b/src/lua/modules/embed/embed.h
index 18ed1d8..6393454 100644
--- a/src/lua/modules/embed/embed.h
+++ b/src/lua/modules/embed/embed.h
@@ -7,9 +7,6 @@ namespace jin
namespace embed
{
- /**
- * embed lua script to context.
- */
#define embed(L, script, name)\
if(luax_loadbuffer(L, script, strlen(script), name) == 0)\
lua_call(L, 0, 0);
@@ -32,18 +29,19 @@ namespace embed
// embed scripts
const jin_Embed scripts[] = {
- { "graphics.lua", graphics_lua },
- { "keyboard.lua", keyboard_lua },
- { "mouse.lua", mouse_lua },
- { "boot.lua", boot_lua },
- { 0, 0 }
+ { "graphics.lua", graphics_lua },
+ { "keyboard.lua", keyboard_lua },
+ { "mouse.lua", mouse_lua },
+ { "boot.lua", boot_lua },
+ { 0, 0 }
};
// load all emebd lua scripts
for (int i = 0; scripts[i].file; ++i)
embed(L, scripts[i].source, scripts[i].file);
}
-}
-}
+
+} // embed
+} // jin
#endif \ No newline at end of file
diff --git a/src/lua/modules/graphics/graphics.cpp b/src/lua/modules/graphics/graphics.cpp
index 9c1d404..98a4fef 100644
--- a/src/lua/modules/graphics/graphics.cpp
+++ b/src/lua/modules/graphics/graphics.cpp
@@ -12,7 +12,7 @@ namespace lua
using jin::filesystem::Filesystem;
using jin::filesystem::Buffer;
- typedef Texture Image;
+ typedef Texture Texture;
static struct
{
@@ -70,21 +70,21 @@ namespace lua
return 1;
}
- static int l_newImage(lua_State* L)
+ static int l_newTexture(lua_State* L)
{
Filesystem* fs = Filesystem::get();
const char* f = luax_checkstring(L, 1);
if (!fs->exists(f))
{
- printf("Error: no such image %s\n", f);
+ printf("Error: no such texture %s\n", f);
exit(1);
}
Buffer b;
fs->read(f, &b);
- Proxy* proxy = (Proxy*)luax_newinstance(L, JIN_GRAPHICS_IMAGE, sizeof(Proxy));
- Image* img = Image::createTexture(b.data, b.size);
- proxy->bind(new Ref<Image>(img, JIN_GRAPHICS_IMAGE));
+ Proxy* proxy = (Proxy*)luax_newinstance(L, JIN_GRAPHICS_TEXTURE, sizeof(Proxy));
+ Texture* img = Texture::createTexture(b.data, b.size);
+ proxy->bind(new Ref<Texture>(img, JIN_GRAPHICS_TEXTURE));
return 1;
}
@@ -158,10 +158,10 @@ namespace lua
float sx = luax_optnumber(L, 4, 1);
float sy = luax_optnumber(L, 5, 1);
float r = luax_optnumber(L, 6, 0);
- if (luax_istype(L, 1, JIN_GRAPHICS_IMAGE))
+ if (luax_istype(L, 1, JIN_GRAPHICS_TEXTURE))
{
Proxy* proxy = (Proxy*)luax_toudata(L, 1);
- Ref<Image>& tex = proxy->getRef<Image>();
+ Ref<Texture>& tex = proxy->getRef<Texture>();
tex->draw(x, y, sx, sy, r);
}
else if (luax_istype(L, 1, JIN_GRAPHICS_CANVAS))
@@ -173,7 +173,7 @@ namespace lua
else
{
/* wrong type */
- luax_typerror(L, 1, "image or canvas");
+ luax_typerror(L, 1, "texture or canvas");
}
return 0;
}
@@ -198,7 +198,7 @@ namespace lua
return 0;
}
- static int l_getColor(lua_State * L)
+ static int l_palette(lua_State * L)
{
luax_pushnumber(L, context.curRenderColor.rgba.r);
luax_pushnumber(L, context.curRenderColor.rgba.g);
@@ -267,7 +267,7 @@ namespace lua
else return RENDER_MODE::NONE;
}
- static int l_drawpoint(lua_State* L)
+ static int l_point(lua_State* L)
{
int x = luax_checknumber(L, 1);
int y = luax_checknumber(L, 2);
@@ -276,7 +276,7 @@ namespace lua
return 0;
}
- static int l_drawLine(lua_State* L)
+ static int l_line(lua_State* L)
{
int x1 = luax_checknumber(L, 1);
int y1 = luax_checknumber(L, 2);
@@ -287,7 +287,7 @@ namespace lua
return 0;
}
- static int l_drawRect(lua_State* L)
+ static int l_rect(lua_State* L)
{
const char* modestr = luax_checkstring(L, 1);
RENDER_MODE mode = strtomode(modestr);
@@ -308,7 +308,7 @@ namespace lua
return 0;
}
- static int l_drawCircle(lua_State* L)
+ static int l_circle(lua_State* L)
{
const char* modestr = luax_checkstring(L, 1);
RENDER_MODE mode = strtomode(modestr);
@@ -328,7 +328,7 @@ namespace lua
return 0;
}
- static int l_drawTriangle(lua_State* L)
+ static int l_triangle(lua_State* L)
{
const char* modestr = luax_checkstring(L, 1);
RENDER_MODE mode = strtomode(modestr);
@@ -354,7 +354,7 @@ namespace lua
return 0;
}
- static int l_drawPolygon(lua_State* L)
+ static int l_polygon(lua_State* L)
{
const char* modestr = luax_checkstring(L, 1);
int n = luax_checknumber(L, 2);
@@ -410,7 +410,7 @@ namespace lua
return 1;
}
- static int l_study(lua_State* L)
+ static int l_setFont(lua_State* L)
{
int n = luax_gettop(L);
if (n == 0)
@@ -466,7 +466,7 @@ namespace lua
{ "getSize", l_getSize },
{ "getWidth", l_getWidth },
{ "getHeight", l_getHeight },
- { "newImage", l_newImage },
+ { "newTexture", l_newTexture },
{ "newShader", l_newShader },
{ "newCanvas", l_newCanvas },
{ "newFont", l_newFont },
@@ -476,24 +476,24 @@ namespace lua
{ "clear", l_clear },
{ "draw", l_draw },
{ "setColor", l_setColor },
- { "palette", l_getColor },
+ { "palette", l_palette },
{ "present", l_present },
- { "setFont", l_study },
+ { "setFont", l_setFont },
{ "bindCanvas", l_bindCanvas },
{ "unbindCanvas", l_unbindCanvas },
{ "useShader", l_useShader },
{ "unuseShader", l_unuseShader },
- { "point", l_drawpoint },
- { "line", l_drawLine },
- { "rect", l_drawRect },
- { "circle", l_drawCircle },
- { "triangle", l_drawTriangle },
- { "polygon", l_drawPolygon },
+ { "point", l_point },
+ { "line", l_line },
+ { "rect", l_rect },
+ { "circle", l_circle },
+ { "triangle", l_triangle },
+ { "polygon", l_polygon },
{ "destroy", l_destroy },
{ 0, 0 }
};
- extern int luaopen_Image(lua_State* L);
+ extern int luaopen_Texture(lua_State* L);
extern int luaopen_Font(lua_State* L);
extern int luaopen_Canvas(lua_State* L);
extern int luaopen_JSL(lua_State* L);
@@ -501,7 +501,7 @@ namespace lua
int luaopen_graphics(lua_State* L)
{
// register types
- luaopen_Image(L);
+ luaopen_Texture(L);
luaopen_Canvas(L);
luaopen_Font(L);
luaopen_JSL(L);
diff --git a/src/lua/modules/graphics/jsl.cpp b/src/lua/modules/graphics/jsl.cpp
index 58de46a..9714695 100644
--- a/src/lua/modules/graphics/jsl.cpp
+++ b/src/lua/modules/graphics/jsl.cpp
@@ -10,7 +10,6 @@ namespace lua
using namespace jin::graphics;
- typedef Texture Image;
typedef Ref<JSLProgram>& JSLRef;
static inline JSLRef checkJSLProgram(lua_State* L)
@@ -32,93 +31,74 @@ namespace lua
COLOR,
};
- static VARIABLE_TYPE strToType(const char* str)
+ /**
+ * jsl:sendNumber("variable", 0.1)
+ */
+ static int l_sendNumber (lua_State* L)
{
- std::string s = std::string(str);
- if (s == "number") return NUMBER;
- else if (s == "Image") return IMAGE;
- else if (s == "Canvas") return CANVAS;
- else if (s == "vec2") return VEC2;
- else if (s == "vec3") return VEC3;
- else if (s == "vec4") return VEC4;
- else if (s == "Color") return COLOR;
- else return INVALID;
+ JSLRef ref = checkJSLProgram(L);
+ const char* variable = luax_checkstring(L, 2);
+ float number = luax_checknumber(L, 3);
+ ref->sendFloat(variable, number);
+ return 0;
}
- /**
- * Use send function send variables to JSL program.
- */
- static int l_send(lua_State* L)
+ static int l_sendTexture (lua_State* L)
+ {
+ JSLRef ref = checkJSLProgram(L);
+ const char* variable = luax_checkstring(L, 2);
+ Proxy* proxy = (Proxy*)luax_checktype(L, 3, JIN_GRAPHICS_TEXTURE);
+ Ref<Texture>& tex = proxy->getRef<Texture>();
+ ref->sendTexture(variable, tex.getObject());
+ return 0;
+ }
+
+ static int l_sendCanvas (lua_State* L)
+ {
+ JSLRef ref = checkJSLProgram(L);
+ const char* variable = luax_checkstring(L, 2);
+ Proxy* proxy = (Proxy*)luax_checktype(L, 3, JIN_GRAPHICS_CANVAS);
+ Ref<Canvas>& canvas = proxy->getRef<Canvas>();
+ ref->sendCanvas(variable, canvas.getObject());
+ return 0;
+ }
+
+ static int l_sendVec2 (lua_State* L)
+ {
+ JSLRef ref = checkJSLProgram(L);
+ const char* variable = luax_checkstring(L, 2);
+ float x = luax_checknumber(L, 3);
+ float y = luax_checknumber(L, 4);
+ ref->sendVec2(variable, x, y);
+ return 0;
+ }
+
+ static int l_sendVec3 (lua_State* L)
+ {
+ JSLRef ref = checkJSLProgram(L);
+ const char* variable = luax_checkstring(L, 2);
+ float x = luax_checknumber(L, 3);
+ float y = luax_checknumber(L, 4);
+ float z = luax_checknumber(L, 5);
+ ref->sendVec3(variable, x, y, z);
+ return 0;
+ }
+
+ static int l_sendVec4 (lua_State* L)
+ {
+ JSLRef ref = checkJSLProgram(L);
+ const char* variable = luax_checkstring(L, 2);
+ float x = luax_checknumber(L, 3);
+ float y = luax_checknumber(L, 4);
+ float z = luax_checknumber(L, 5);
+ float w = luax_checknumber(L, 6);
+ ref->sendVec4(variable, x, y, z, w);
+ return 0;
+ }
+
+ static int l_sendColor (lua_State* L)
{
- JSLRef ref = checkJSLProgram(L);
- // number Image Texel
- const char* typestr = luax_checkstring(L, 2);
- // variable name
- const char* variable = luax_checkstring(L, 3);
- if (typestr != nullptr)
- {
- int type = strToType(typestr);
- switch (type)
- {
- case NUMBER:
- {
- float number = luax_checknumber(L, 4);
- ref->sendFloat(variable, number);
- break;
- }
- case IMAGE:
- {
- Proxy* proxy = (Proxy*)luax_checktype(L, 4, JIN_GRAPHICS_IMAGE);
- Ref<Image>& tex = proxy->getRef<Image>();
- ref->sendTexture(variable, tex.getObject());
- break;
- }
- case CANVAS:
- {
- Proxy* proxy = (Proxy*)luax_checktype(L, 4, JIN_GRAPHICS_CANVAS);
- Ref<Canvas>& canvas = proxy->getRef<Canvas>();
- ref->sendCanvas(variable, canvas.getObject());
- break;
- }
- case VEC2:
- {
- float x = luax_checknumber(L, 4);
- float y = luax_checknumber(L, 5);
- ref->sendVec2(variable, x, y);
- break;
- }
- case VEC3:
- {
- float x = luax_checknumber(L, 4);
- float y = luax_checknumber(L, 5);
- float z = luax_checknumber(L, 6);
- ref->sendVec3(variable, x, y, z);
- break;
- }
- case VEC4:
- {
- float x = luax_checknumber(L, 4);
- float y = luax_checknumber(L, 5);
- float z = luax_checknumber(L, 6);
- float w = luax_checknumber(L, 7);
- ref->sendVec4(variable, x, y, z, w);
- break;
- }
- case COLOR:
- {
- color col;
- col.rgba.r = luax_checkinteger(L, 4);
- col.rgba.g = luax_checkinteger(L, 5);
- col.rgba.b = luax_checkinteger(L, 6);
- col.rgba.a = luax_checkinteger(L, 7);
- ref->sendColor(variable, &col);
- break;
- }
- default:
- return 0;
- }
- }
- return 1;
+ return l_sendVec4(L);
}
static int l_gc(lua_State* L)
@@ -129,9 +109,15 @@ namespace lua
}
static const luaL_Reg f[] = {
- { "__gc", l_gc },
- { "send", l_send },
- { 0, 0 }
+ { "__gc", l_gc },
+ { "sendNumber", l_sendNumber },
+ { "sendTexture", l_sendTexture },
+ { "sendCanvas", l_sendCanvas },
+ { "sendVec2", l_sendVec2 },
+ { "sendVec3", l_sendVec3 },
+ { "sendVec4", l_sendVec4 },
+ { "sendColor", l_sendColor },
+ { 0, 0 }
};
/**
@@ -143,5 +129,5 @@ namespace lua
return 0;
}
-}
-} \ No newline at end of file
+} // lua
+} // jin \ No newline at end of file
diff --git a/src/lua/modules/graphics/image.cpp b/src/lua/modules/graphics/texture.cpp
index 3caff16..5bc208a 100644
--- a/src/lua/modules/graphics/image.cpp
+++ b/src/lua/modules/graphics/texture.cpp
@@ -10,32 +10,31 @@ namespace lua
using namespace jin::graphics;
- typedef Texture Image;
- typedef Ref<Image>& ImageRef;
+ typedef Ref<Texture>& TextureRef;
- static inline ImageRef checkImage(lua_State* L)
+ static inline TextureRef checkTexture(lua_State* L)
{
- Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_IMAGE);
- return proxy->getRef<Image>();
+ Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTURE);
+ return proxy->getRef<Texture>();
}
static int l_getWidth(lua_State* L)
{
- ImageRef ref = checkImage(L);
+ TextureRef ref = checkTexture(L);
luax_pushnumber(L, ref->getWidth());
return 1;
}
static int l_getHeight(lua_State *L)
{
- ImageRef ref = checkImage(L);
+ TextureRef ref = checkTexture(L);
luax_pushnumber(L, ref->getHeight());
return 1;
}
static int l_getPixel(lua_State* L)
{
- ImageRef ref = checkImage(L);
+ TextureRef ref = checkTexture(L);
int x = luax_checknumber(L, 2);
int y = luax_checknumber(L, 3);
color c = ref->getPixel(x, y);
@@ -48,7 +47,7 @@ namespace lua
static int l_setAnchor(lua_State* L)
{
- ImageRef ref = checkImage(L);
+ TextureRef ref = checkTexture(L);
int x = luax_checknumber(L, 2);
int y = luax_checknumber(L, 3);
ref->setAnchor(x, y);
@@ -57,7 +56,7 @@ namespace lua
static int l_getSize(lua_State* L)
{
- ImageRef ref = checkImage(L);
+ TextureRef ref = checkTexture(L);
luax_pushnumber(L, ref->getWidth());
luax_pushnumber(L, ref->getHeight());
return 2;
@@ -65,7 +64,7 @@ namespace lua
static int l_gc(lua_State* L)
{
- Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_IMAGE);
+ Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTURE);
proxy->release();
return 0;
}
@@ -80,9 +79,9 @@ namespace lua
{ 0, 0 }
};
- int luaopen_Image(lua_State* L)
+ int luaopen_Texture(lua_State* L)
{
- luax_newtype(L, JIN_GRAPHICS_IMAGE, f);
+ luax_newtype(L, JIN_GRAPHICS_TEXTURE, f);
return 0;
}
diff --git a/src/lua/modules/types.h b/src/lua/modules/types.h
index 318f5fa..4e824c2 100644
--- a/src/lua/modules/types.h
+++ b/src/lua/modules/types.h
@@ -2,19 +2,19 @@
#define __JIN_MODULES_TYPES_H
// graphics module
-#define JIN_GRAPHICS_IMAGE "jin.graphics.Image"
-#define JIN_GRAPHICS_SHADER "jin.graphics.Shader"
-#define JIN_GRAPHICS_CANVAS "jin.graphics.Canvas"
-#define JIN_GRAPHICS_FONT "jin.graphics.Font"
-
-// audio module
-#define JIN_AUDIO_SOURCE "jin.Audio.Source"
-
-// thread module
-#define JIN_THREAD_THREAD "jin.thread.Thread"
-
-// network module
-#define JIN_NETWORK_SOCKET "jin.net.Socket"
-#define JIN_NETWORK_BUFFER "jin.net.Buffer"
+#define JIN_GRAPHICS_TEXTURE "jin.graphics.Texture"
+#define JIN_GRAPHICS_SHADER "jin.graphics.Shader"
+#define JIN_GRAPHICS_CANVAS "jin.graphics.Canvas"
+#define JIN_GRAPHICS_FONT "jin.graphics.Font"
+
+// audio module
+#define JIN_AUDIO_SOURCE "jin.Audio.Source"
+
+// thread module
+#define JIN_THREAD_THREAD "jin.thread.Thread"
+
+// network module
+#define JIN_NETWORK_SOCKET "jin.net.Socket"
+#define JIN_NETWORK_BUFFER "jin.net.Buffer"
#endif \ No newline at end of file