diff --git a/source/glerminal-main.cpp b/source/glerminal-main.cpp index 233c798..af94735 100644 --- a/source/glerminal-main.cpp +++ b/source/glerminal-main.cpp @@ -112,7 +112,7 @@ namespace { const char* error_message = lua_tostring(L, -1); - luaL_traceback(L, L, error_message, 0); + luaL_traceback(L, L, error_message, 1); const char* err = lua_tostring(L, -1); @@ -215,13 +215,24 @@ int main(int argc, char** argv) luaL_newlib(L, lglerminal_methods); lua_setglobal(L, "glerminal"); - if (luaL_dofile(L, "main.lua") != LUA_OK) + lua_pushcfunction(L, message_handler); + const int handler = lua_gettop(L); + if (luaL_loadfile(L, "main.lua") != LUA_OK) { const char* str = lua_tostring(L, -1); + std::cout << str << std::endl; lua_pop(L, 1); } - - glerminal_run(init, mainloop, pressed, released); + else if (lua_pcall(L, 0, LUA_MULTRET, handler) != LUA_OK) + { + const char* str = lua_tostring(L, -1); + std::cout << str << std::endl; + lua_pop(L, 1); + } + else + { + glerminal_run(init, mainloop, pressed, released); + } lua_close(L); diff --git a/source/glerminal.cpp b/source/glerminal.cpp index 1217679..93a7542 100644 --- a/source/glerminal.cpp +++ b/source/glerminal.cpp @@ -296,6 +296,7 @@ namespace glerminal glfwSwapInterval(0); glfwSwapBuffers(m_window); + glBlitNamedFramebuffer(m_screen_framebuffer, 0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, GL_COLOR_BUFFER_BIT, GL_NEAREST); glfwSwapInterval(1); glfwSwapBuffers(m_window); }