aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libjin/audio/audio.cpp5
-rw-r--r--src/libjin/audio/audio.h14
-rw-r--r--src/libjin/common/subsystem.h33
-rw-r--r--src/libjin/core/game.h6
-rw-r--r--src/libjin/input/joypad.cpp0
-rw-r--r--src/libjin/input/mouse.h15
-rw-r--r--src/libjin/render/drawable.cpp2
-rw-r--r--src/libjin/render/drawable.h22
-rw-r--r--src/libjin/render/jsl.cpp100
-rw-r--r--src/libjin/render/window.cpp33
-rw-r--r--src/libjin/render/window.h27
-rw-r--r--src/main.cpp2
-rw-r--r--src/script/embed/boot.lua.h33
-rw-r--r--src/script/embed/debug.lua.h72
-rw-r--r--src/script/event/luaopen_event.cpp21
-rw-r--r--src/script/graphics/luaopen_JSL.cpp98
-rw-r--r--src/script/graphics/luaopen_graphics.cpp11
17 files changed, 271 insertions, 223 deletions
diff --git a/src/libjin/audio/audio.cpp b/src/libjin/audio/audio.cpp
index 88fe52b..f4b64e6 100644
--- a/src/libjin/audio/audio.cpp
+++ b/src/libjin/audio/audio.cpp
@@ -5,7 +5,10 @@ namespace jin
namespace audio
{
-
+ onlyonce bool Audio::_init(const SettingBase* setting)
+ {
+ return false;
+ }
}
} \ No newline at end of file
diff --git a/src/libjin/audio/audio.h b/src/libjin/audio/audio.h
index 9356c8a..fd4ab69 100644
--- a/src/libjin/audio/audio.h
+++ b/src/libjin/audio/audio.h
@@ -1,23 +1,29 @@
#ifndef __JIN_AUDIO_H
#define __JIN_AUDIO_H
-
+#include "../utils/macros.h"
+#include "../common/subsystem.h"
namespace jin
{
namespace audio
{
- class Audio
+ class Audio : public common::Subsystem
{
public:
- struct Setting
+ struct Setting : SettingBase
{
};
- void init(const Setting& setting);
+ private:
+
+ onlyonce bool _init(const SettingBase* setting) override;
+
};
+ typedef Audio::Setting AudioSetting;
+
}
}
diff --git a/src/libjin/common/subsystem.h b/src/libjin/common/subsystem.h
new file mode 100644
index 0000000..a6c5099
--- /dev/null
+++ b/src/libjin/common/subsystem.h
@@ -0,0 +1,33 @@
+#ifndef __JIN_COMMON_SUBSYSTEM_H
+#define __JIN_COMMON_SUBSYSTEM_H
+
+#include "../utils/macros.h"
+
+namespace jin
+{
+namespace common
+{
+
+ class Subsystem
+ {
+ public:
+
+ struct Setting {};
+
+ bool init(const Setting* setting)
+ {
+ static bool result = _init(setting);
+ return result;
+ }
+
+ typedef Subsystem::Setting SettingBase;
+
+ private:
+
+ virtual onlyonce bool _init(const Setting* setting) = 0;
+ };
+
+}
+}
+
+#endif \ No newline at end of file
diff --git a/src/libjin/core/game.h b/src/libjin/core/game.h
index 069566b..e36a71b 100644
--- a/src/libjin/core/game.h
+++ b/src/libjin/core/game.h
@@ -9,10 +9,10 @@ namespace core
{
public:
- struct Setting
- {
+ struct Setting
+ {
- };
+ };
static inline Game* get()
{
diff --git a/src/libjin/input/joypad.cpp b/src/libjin/input/joypad.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/libjin/input/joypad.cpp
diff --git a/src/libjin/input/mouse.h b/src/libjin/input/mouse.h
index 55e3346..b926327 100644
--- a/src/libjin/input/mouse.h
+++ b/src/libjin/input/mouse.h
@@ -10,21 +10,6 @@ namespace input
};
- inline const char* buttonStr(int id) {
- switch (id) {
- case 1: return "left";
- case 2: return "middle";
- case 3: return "right";
- case 4: return "wheelup";
- case 5: return "wheeldown";
- default: return "?";
- }
- }
-
- inline const char* wheelStr(int dir)
- {
-
- }
}
}
#endif \ No newline at end of file
diff --git a/src/libjin/render/drawable.cpp b/src/libjin/render/drawable.cpp
index c0d40a1..4ac4f03 100644
--- a/src/libjin/render/drawable.cpp
+++ b/src/libjin/render/drawable.cpp
@@ -60,7 +60,7 @@ namespace render
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
- // pop the model matrix
+ // pop the model matrix
glPopMatrix();
// bind texture to default screen
diff --git a/src/libjin/render/drawable.h b/src/libjin/render/drawable.h
index b8e985a..0cf6d4b 100644
--- a/src/libjin/render/drawable.h
+++ b/src/libjin/render/drawable.h
@@ -15,20 +15,20 @@ namespace render
void draw(int x, int y, float sx, float sy, float r);
- inline int Drawable::getWidth() const
- {
- return width;
- }
+ inline int Drawable::getWidth() const
+ {
+ return width;
+ }
- inline int Drawable::getHeight() const
- {
- return height;
- }
+ inline int Drawable::getHeight() const
+ {
+ return height;
+ }
inline GLuint getTexture() const
- {
- return texture;
- };
+ {
+ return texture;
+ };
protected:
#define DRAWABLE_V_SIZE 8
diff --git a/src/libjin/render/jsl.cpp b/src/libjin/render/jsl.cpp
index 58b9a15..3702e14 100644
--- a/src/libjin/render/jsl.cpp
+++ b/src/libjin/render/jsl.cpp
@@ -10,7 +10,7 @@ namespace render
"#define number float \n"
"#define Image sampler2D \n"
"#define Canvas sampler2D \n"
- "#define Color vec4 \n"
+ "#define Color vec4 \n"
"#define Texel texture2D \n"
"#define extern uniform \n"
"uniform Image _tex0_; \n"
@@ -19,10 +19,10 @@ namespace render
"gl_FragColor = effect(gl_Color, _tex0_, gl_TexCoord[0].xy, gl_FragCoord.xy);\n"
"}\0";
- shared GLint JSLProgram::currentTextureUnit = 0;
- shared GLint JSLProgram::maxTextureUnits = -1;
+ shared GLint JSLProgram::currentTextureUnit = 0;
+ shared GLint JSLProgram::maxTextureUnits = -1;
- shared JSLProgram* JSLProgram::currentJSLProgram = nullptr;
+ shared JSLProgram* JSLProgram::currentJSLProgram = nullptr;
JSLProgram::JSLProgram(const char* program)
{
@@ -61,17 +61,17 @@ namespace render
std::map<std::string, GLint>::iterator texture_unit = texturePool.find(name);
if (texture_unit != texturePool.end())
return texture_unit->second;
- if (++currentTextureUnit >= maxTextureUnits)
- return 0;
+ if (++currentTextureUnit >= maxTextureUnits)
+ return 0;
texturePool[name] = currentTextureUnit;
- return currentTextureUnit;
+ return currentTextureUnit;
}
#define checkJSL() if (currentJSLProgram != this) return
void JSLProgram::sendFloat(const char* variable, float number)
{
- checkJSL();
+ checkJSL();
int loc = glGetUniformLocation(pid, variable);
glUniform1f(loc, number);
@@ -79,12 +79,12 @@ namespace render
void JSLProgram::sendImage(const char* variable, const Image* image)
{
- checkJSL();
+ checkJSL();
GLint texture_unit = JSLProgram::getTextureUnit(variable);
GLint location = glGetUniformLocation(pid, variable);
- glUniform1i(location, texture_unit);
+ glUniform1i(location, texture_unit);
glActiveTexture(GL_TEXTURE0 + texture_unit);
glBindTexture(GL_TEXTURE_2D, image->getTexture());
@@ -92,57 +92,57 @@ namespace render
glActiveTexture(GL_TEXTURE0);
}
- void JSLProgram::sendCanvas(const char* variable, const Canvas* canvas)
- {
- checkJSL();
+ void JSLProgram::sendCanvas(const char* variable, const Canvas* canvas)
+ {
+ checkJSL();
- GLint texture_unit = getTextureUnit(variable);
+ GLint texture_unit = getTextureUnit(variable);
- GLint location = glGetUniformLocation(pid, variable);
- glUniform1i(location, texture_unit);
+ GLint location = glGetUniformLocation(pid, variable);
+ glUniform1i(location, texture_unit);
- glActiveTexture(GL_TEXTURE0 + texture_unit);
- glBindTexture(GL_TEXTURE_2D, canvas->getTexture());
+ glActiveTexture(GL_TEXTURE0 + texture_unit);
+ glBindTexture(GL_TEXTURE_2D, canvas->getTexture());
- glActiveTexture(GL_TEXTURE0);
- }
+ glActiveTexture(GL_TEXTURE0);
+ }
- void JSLProgram::sendVec2(const char* name, float x, float y)
- {
- checkJSL();
+ void JSLProgram::sendVec2(const char* name, float x, float y)
+ {
+ checkJSL();
- int loc = glGetUniformLocation(pid, name);
- glUniform2f(loc, x, y);
- }
+ int loc = glGetUniformLocation(pid, name);
+ glUniform2f(loc, x, y);
+ }
- void JSLProgram::sendVec3(const char* name, float x, float y, float z)
- {
- checkJSL();
+ void JSLProgram::sendVec3(const char* name, float x, float y, float z)
+ {
+ checkJSL();
- int loc = glGetUniformLocation(pid, name);
- glUniform3f(loc, x, y, z);
- }
+ int loc = glGetUniformLocation(pid, name);
+ glUniform3f(loc, x, y, z);
+ }
- void JSLProgram::sendVec4(const char* name, float x, float y, float z, float w)
- {
- checkJSL();
+ void JSLProgram::sendVec4(const char* name, float x, float y, float z, float w)
+ {
+ checkJSL();
- int loc = glGetUniformLocation(pid, name);
- glUniform4f(loc, x, y, z, w);
- }
+ int loc = glGetUniformLocation(pid, name);
+ glUniform4f(loc, x, y, z, w);
+ }
- void JSLProgram::sendColor(const char* name, const color* col)
- {
- checkJSL();
-
- int loc = glGetUniformLocation(pid, name);
- glUniform4f(loc,
- col->rgba.r / 255.f,
- col->rgba.g / 255.f,
- col->rgba.b / 255.f,
- col->rgba.a / 255.f
- );
- }
+ void JSLProgram::sendColor(const char* name, const color* col)
+ {
+ checkJSL();
+
+ int loc = glGetUniformLocation(pid, name);
+ glUniform4f(loc,
+ col->rgba.r / 255.f,
+ col->rgba.g / 255.f,
+ col->rgba.b / 255.f,
+ col->rgba.a / 255.f
+ );
+ }
}
}
diff --git a/src/libjin/render/window.cpp b/src/libjin/render/window.cpp
index 70e7e2d..1f55be8 100644
--- a/src/libjin/render/window.cpp
+++ b/src/libjin/render/window.cpp
@@ -18,17 +18,17 @@ namespace render
{
}
- onlyonce void Window::init(const Window::Setting& setting)
+ onlyonce bool Window::_init(const SettingBase* s)
{
- CallOnce(_init(setting));
- }
+ if (SDL_Init(SDL_INIT_VIDEO) < 0)
+ return false;
- inline void Window::_init(const Setting& setting)
- {
- width = setting.width;
- height = setting.height;
- const char* title = setting.title;
- bool vsync = setting.vsync;
+ WindowSetting* setting = (WindowSetting*)s;
+
+ width = setting->width;
+ height = setting->height;
+ bool vsync = setting->vsync;
+ const char* title = setting->title;
if (wnd)
{
@@ -54,7 +54,11 @@ namespace render
wy = SDL_WINDOWPOS_UNDEFINED;
wnd = SDL_CreateWindow(title, wx, wy, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
+ if (wnd == NULL)
+ return false;
ctx = SDL_GL_CreateContext(wnd);
+ if (ctx == NULL)
+ return false;
SDL_GL_SetSwapInterval(vsync ? 1 : 0);
SDL_GL_MakeCurrent(wnd, ctx);
glClearColor(0.f, 0.f, 0.f, 1.f);
@@ -66,6 +70,7 @@ namespace render
Canvas::unbind();
swapBuffers();
+ return true;
}
SDL_Window* Window::getWnd()
@@ -78,11 +83,11 @@ namespace render
return ctx;
}
- inline void Window::swapBuffers()
- {
- if (wnd)
- SDL_GL_SwapWindow(wnd);
- }
+ inline void Window::swapBuffers()
+ {
+ if (wnd)
+ SDL_GL_SwapWindow(wnd);
+ }
}
} \ No newline at end of file
diff --git a/src/libjin/render/window.h b/src/libjin/render/window.h
index 8066f8a..1064c36 100644
--- a/src/libjin/render/window.h
+++ b/src/libjin/render/window.h
@@ -2,24 +2,25 @@
#define __JIN_RENDER_WINDOW
#include <SDL2/SDL.h>
#include "../utils/utils.h"
+#include "../common/subsystem.h"
namespace jin
{
namespace render
{
- class Window
+
+ class Window : public common::Subsystem
{
public:
- struct Setting
- {
- int width, height; // ڴС
- bool vsync; // ֱͬ
- const char* title; //
- };
+ struct Setting : SettingBase
+ {
+ public:
+ int width, height; // ڴС
+ bool vsync; // ֱͬ
+ const char* title; //
+ };
- onlyonce void init(const Setting& setting);
-
SDL_Window* getWnd();
SDL_GLContext getCtx();
@@ -39,7 +40,7 @@ namespace render
return height;
}
- inline void swapBuffers();
+ inline void swapBuffers();
private:
@@ -54,8 +55,12 @@ namespace render
int width, height;
- inline void _init(const Setting& setting);
+ onlyonce bool _init(const SettingBase* setting) override;
+
};
+
+ typedef Window::Setting WindowSetting;
+
}
}
#endif \ No newline at end of file
diff --git a/src/main.cpp b/src/main.cpp
index e54d2c2..9b0da69 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -34,7 +34,7 @@ int main(int argc, char* argv[])
* jin._dir is the folder of jin binary executable
*/
#define BUFFER_SIZE 512
- char buffer[BUFFER_SIZE];
+ char buffer[BUFFER_SIZE];
#ifdef _WIN32
_getcwd(buffer, BUFFER_SIZE);
#elif defined __unix__
diff --git a/src/script/embed/boot.lua.h b/src/script/embed/boot.lua.h
index 223f354..cb61468 100644
--- a/src/script/embed/boot.lua.h
+++ b/src/script/embed/boot.lua.h
@@ -1,23 +1,7 @@
/* boot.lua */
static const char* boot_lua = R"(
-local function _onEvent(e)
- -- update keyboard status
- if e.type == "keydown" then
- jin.keyboard.set(e.key, true)
- elseif e.type == "keyup" then
- jin.keyboard.set(e.key, false)
- end
-
- -- call user onEvent function
- if jin.core.onEvent then
- jin.core.onEvent(e)
- end
-end
-
--------------------------------------------------
--- init file system
--------------------------------------------------
+-- init filesystem
jin._argv[2] = jin._argv[2] or '.'
jin.filesystem.init()
jin.filesystem.mount(jin._argv[2])
@@ -54,13 +38,26 @@ function jin.core.run()
local study = jin.graphics.study
local onDraw = jin.core.onDraw
local onUpdate = jin.core.onUpdate
+ local onEvent = jin.core.onEvent
local present = jin.graphics.present
+ local setkey = jin.keyboard.set
local dstatus = jin.debug.status
local drender = jin.debug.render
local fps = conf.fps
-
+
+ local _onEvent = function (e)
+ if e.type == "keydown" then
+ setkey(e.key, true)
+ elseif e.type == "keyup" then
+ setkey(e.key, false)
+ end
+ if onEvent then
+ onEvent(e)
+ end
+ end
+
if load then
load()
end
diff --git a/src/script/embed/debug.lua.h b/src/script/embed/debug.lua.h
index 7ccc99d..79c95ba 100644
--- a/src/script/embed/debug.lua.h
+++ b/src/script/embed/debug.lua.h
@@ -33,27 +33,27 @@ local refresh = true
function jin.debug.init()
debug = true
- panel = jin.graphics.Canvas(jin.graphics.size())
+ panel = jin.graphics.Canvas(jin.graphics.size())
end
-- set buffer size
function jin.debug.size(c)
- bsize = c
+ bsize = c
end
function jin.debug.print(msg)
- if not debug then return end
-
- msg = tostring(msg)
- local tp = type(msg)
- if tp ~= "string" and tp ~= "number" then
- msg = string.format("print failed, expect string or number but get a %s", tp)
- end
-
+ if not debug then return end
+
+ msg = tostring(msg)
+ local tp = type(msg)
+ if tp ~= "string" and tp ~= "number" then
+ msg = string.format("print failed, expect string or number but get a %s", tp)
+ end
+
-- remove the first one (old msg)
- if #buffer >= bsize then
- table.remove(buffer, 1)
- end
+ if #buffer >= bsize then
+ table.remove(buffer, 1)
+ end
buffer[#buffer + 1] = msg
refresh = true
@@ -61,33 +61,33 @@ end
-- clear debug buffer
function jin.debug.clear()
- buffer = {}
+ buffer = {}
end
local function getStrHeight(str, lheight)
- local h = lheight
- if #str == 0 then
- h = 0
- end
- for i = 1, #str do
- local c = string.sub(str, i, i)
- if c == '\n' then
- h = h + lheight
- end
- end
- return h
+ local h = lheight
+ if #str == 0 then
+ h = 0
+ end
+ for i = 1, #str do
+ local c = string.sub(str, i, i)
+ if c == '\n' then
+ h = h + lheight
+ end
+ end
+ return h
end
local function getBgQuad()
- local width, height = 0, 0
- for i = 1, #buffer do
- local w, h = jin.graphics.box( buffer[i], fsize, 1, lheight)
- height = height + h
- if width < w then
- width = w
- end
- end
- return width, height
+ local width, height = 0, 0
+ for i = 1, #buffer do
+ local w, h = jin.graphics.box( buffer[i], fsize, 1, lheight)
+ height = height + h
+ if width < w then
+ width = w
+ end
+ end
+ return width, height
end
-- render to screen
@@ -115,7 +115,7 @@ function jin.debug.render()
y = y - h
jin.graphics.write(msg, margin / 2, y - margin/ 2, fsize, 1, lheight)
end
-
+
jin.graphics.bind()
refresh = false
@@ -126,7 +126,7 @@ function jin.debug.render()
end
function jin.debug.status()
- return debug
+ return debug
end
)"; \ No newline at end of file
diff --git a/src/script/event/luaopen_event.cpp b/src/script/event/luaopen_event.cpp
index 87882e7..16ecbad 100644
--- a/src/script/event/luaopen_event.cpp
+++ b/src/script/event/luaopen_event.cpp
@@ -12,6 +12,23 @@ namespace jin
{
namespace lua
{
+
+ static inline const char* buttonstr(int id) {
+ switch (id) {
+ case 1: return "left";
+ case 2: return "middle";
+ case 3: return "right";
+ case 4: return "wheelup";
+ case 5: return "wheeldown";
+ default: return "?";
+ }
+ }
+
+ static inline const char* wheelstr(int dir)
+ {
+
+ }
+
/**
* Load event poll, return a iterator(a table).
*/
@@ -50,14 +67,14 @@ namespace lua
case SDL_MOUSEBUTTONDOWN:
luax_setfield_string(L, "type", "mousebuttondown");
- luax_setfield_string(L, "button", buttonStr(e.button.button));
+ luax_setfield_string(L, "button", buttonstr(e.button.button));
luax_setfield_number(L, "x", e.button.x);
luax_setfield_number(L, "y", e.button.y);
break;
case SDL_MOUSEBUTTONUP:
luax_setfield_string(L, "type", "mousebuttonup");
- luax_setfield_string(L, "button", buttonStr(e.button.button));
+ luax_setfield_string(L, "button", buttonstr(e.button.button));
luax_setfield_number(L, "x", e.button.x);
luax_setfield_number(L, "y", e.button.y);
break;
diff --git a/src/script/graphics/luaopen_JSL.cpp b/src/script/graphics/luaopen_JSL.cpp
index adb109c..d5db363 100644
--- a/src/script/graphics/luaopen_JSL.cpp
+++ b/src/script/graphics/luaopen_JSL.cpp
@@ -24,22 +24,22 @@ namespace lua
NUMBER,
IMAGE,
CANVAS,
- VEC2,
- VEC3,
- VEC4,
- COLOR,
+ VEC2,
+ VEC3,
+ VEC4,
+ COLOR,
};
static VARIABLE_TYPE strtotype(const char* str)
{
std::string s = std::string(str);
- if (s == "number") return NUMBER;
+ 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 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;
}
@@ -72,48 +72,48 @@ namespace lua
break;
}
case CANVAS:
- {
+ {
Proxy* proxy = (Proxy*)luax_checktype(L, 4, TYPE_IMAGE);
Canvas* canvas = (Canvas*)proxy->object;
- jsl->sendCanvas(variable, canvas);
- break;
- }
- case VEC2:
- {
- float x = luax_checknumber(L, 4);
- float y = luax_checknumber(L, 5);
- jsl->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);
- jsl->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);
- jsl->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);
- jsl->sendColor(variable, &col);
- break;
- }
- default:
- return 0;
+ jsl->sendCanvas(variable, canvas);
+ break;
+ }
+ case VEC2:
+ {
+ float x = luax_checknumber(L, 4);
+ float y = luax_checknumber(L, 5);
+ jsl->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);
+ jsl->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);
+ jsl->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);
+ jsl->sendColor(variable, &col);
+ break;
+ }
+ default:
+ return 0;
}
}
return 1;
diff --git a/src/script/graphics/luaopen_graphics.cpp b/src/script/graphics/luaopen_graphics.cpp
index 6e78e36..948e28a 100644
--- a/src/script/graphics/luaopen_graphics.cpp
+++ b/src/script/graphics/luaopen_graphics.cpp
@@ -30,15 +30,12 @@ namespace lua
static int l_init(lua_State* L)
{
Window* wnd = Window::get();
- Window::Setting setting;
+ WindowSetting setting;
setting.width = luax_getfield_integer(L, 1, "width");
setting.height = luax_getfield_integer(L, 1, "height");
setting.title = luax_getfield_string(L, 1, "title");
setting.vsync = luax_getfield_bool(L, 1, "vsync");
- wnd->init(setting);
-
- // init success
- luax_pushboolean(L, true);
+ luax_pushboolean(L, wnd->init(&setting));
return 1;
}
@@ -357,8 +354,8 @@ namespace lua
int tn = luax_tableidxlen(L, 3);
if (tn != n * 2)
{
- static char emsg[] =
- "number of polygon vertices doesn't match "
+ static char* emsg = \
+ "number of polygon vertices doesn't match " \
"provided n, expect %d numbers but get %d";
luax_error(L, emsg, n * 2, tn);
return 1;