initial trials with getting sol and other things work in sync
This commit is contained in:
parent
8c67b1f632
commit
203ded3f89
3 changed files with 15 additions and 2 deletions
|
@ -30,6 +30,7 @@ void pw::context::yield()
|
||||||
void pw::context::script(const char *s)
|
void pw::context::script(const char *s)
|
||||||
{
|
{
|
||||||
_lua.script("w = pw.window.new()");
|
_lua.script("w = pw.window.new()");
|
||||||
|
_lua.script("w:set_title(\"pixwerks\")");
|
||||||
_lua.script("while w:update() do end");
|
_lua.script("while w:update() do end");
|
||||||
// luaL_loadstring(_state,s);
|
// luaL_loadstring(_state,s);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
pw::window::window() {
|
pw::window::window() {
|
||||||
|
|
||||||
_window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
|
_window = glfwCreateWindow(640, 480, "pixwerxs", NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
pw::window::~window() {
|
pw::window::~window() {
|
||||||
|
@ -13,6 +13,10 @@ pw::window::~window() {
|
||||||
bool pw::window::update()
|
bool pw::window::update()
|
||||||
{
|
{
|
||||||
if (!glfwWindowShouldClose(_window)) {
|
if (!glfwWindowShouldClose(_window)) {
|
||||||
|
glfwMakeContextCurrent(_window);
|
||||||
|
|
||||||
|
// do other stuff
|
||||||
|
|
||||||
glfwSwapBuffers(_window);
|
glfwSwapBuffers(_window);
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
||||||
|
@ -22,12 +26,18 @@ bool pw::window::update()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pw::window::set_title(const char *t)
|
||||||
|
{
|
||||||
|
glfwSetWindowTitle(_window,t);
|
||||||
|
}
|
||||||
|
|
||||||
void pw::window::load(sol::table &ns) {
|
void pw::window::load(sol::table &ns) {
|
||||||
{
|
{
|
||||||
glfwInit();
|
glfwInit();
|
||||||
|
|
||||||
ns.new_usertype<window>("window",
|
ns.new_usertype<window>("window",
|
||||||
"update",&window::update
|
"update",&window::update,
|
||||||
|
"set_title",&window::set_title
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@ public:
|
||||||
|
|
||||||
bool update();
|
bool update();
|
||||||
|
|
||||||
|
void set_title(const char* t);
|
||||||
|
|
||||||
|
|
||||||
static void load(sol::table &ns);
|
static void load(sol::table &ns);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue