From 203ded3f89f9be99754f440de47c7691ac9c7e94 Mon Sep 17 00:00:00 2001 From: Hartmut Seichter Date: Wed, 28 Jun 2017 10:58:01 +0200 Subject: [PATCH] initial trials with getting sol and other things work in sync --- src/core/context.cpp | 1 + src/core/window.cpp | 14 ++++++++++++-- src/core/window.hpp | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/core/context.cpp b/src/core/context.cpp index 0ae59cd..3235cce 100644 --- a/src/core/context.cpp +++ b/src/core/context.cpp @@ -30,6 +30,7 @@ void pw::context::yield() void pw::context::script(const char *s) { _lua.script("w = pw.window.new()"); + _lua.script("w:set_title(\"pixwerks\")"); _lua.script("while w:update() do end"); // luaL_loadstring(_state,s); diff --git a/src/core/window.cpp b/src/core/window.cpp index 281a871..b8437cc 100644 --- a/src/core/window.cpp +++ b/src/core/window.cpp @@ -2,7 +2,7 @@ pw::window::window() { - _window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); + _window = glfwCreateWindow(640, 480, "pixwerxs", NULL, NULL); } pw::window::~window() { @@ -13,6 +13,10 @@ pw::window::~window() { bool pw::window::update() { if (!glfwWindowShouldClose(_window)) { + glfwMakeContextCurrent(_window); + + // do other stuff + glfwSwapBuffers(_window); glfwPollEvents(); @@ -22,12 +26,18 @@ bool pw::window::update() return false; } +void pw::window::set_title(const char *t) +{ + glfwSetWindowTitle(_window,t); +} + void pw::window::load(sol::table &ns) { { glfwInit(); ns.new_usertype("window", - "update",&window::update + "update",&window::update, + "set_title",&window::set_title ); } } diff --git a/src/core/window.hpp b/src/core/window.hpp index 4cef508..64b835c 100644 --- a/src/core/window.hpp +++ b/src/core/window.hpp @@ -19,6 +19,8 @@ public: bool update(); + void set_title(const char* t); + static void load(sol::table &ns); };