diff options
author | pixel <pixel> | 2006-02-09 17:13:31 +0000 |
---|---|---|
committer | pixel <pixel> | 2006-02-09 17:13:31 +0000 |
commit | 49157898b4c3e0975d66dae0f72724f0cb8d9283 (patch) | |
tree | b0b558b0df03ff82dbf2091a7d5b96c9d8575581 | |
parent | c9c08ba9dd28fe23c59d62b4c04361d7a1406a25 (diff) |
Reporting the latests API changes into Dalos - yet it's only a test software, but one day...
-rw-r--r-- | Dalos/Dalos.cc | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/Dalos/Dalos.cc b/Dalos/Dalos.cc index 1262d73..23006c0 100644 --- a/Dalos/Dalos.cc +++ b/Dalos/Dalos.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: Dalos.cc,v 1.24 2006-02-02 17:25:28 pixel Exp $ */ +/* $Id: Dalos.cc,v 1.25 2006-02-09 17:13:31 pixel Exp $ */ #include <SDL.h> #include <SDL_thread.h> @@ -32,6 +32,7 @@ #include <LuaHandle.h> #include <LuaConfigFile.h> #include <LuaRegex.h> +#include <LuaGL.h> #include <engine.h> #include <glbase.h> @@ -55,6 +56,10 @@ bool auto_exec = true; bool lua_started = false; bool do_lua_break = false; +bool do_lua_pause = false; +bool lua_paused = false; + +Lua * L; CODE_BEGINS @@ -72,7 +77,12 @@ class threaded_Lua : public Lua { virtual void unlock() { SDL_mutexV(mutex); } + protected: + virtual Lua * spawn_from_thread(lua_State * __L) { + return new threaded_Lua(__L); + } private: + threaded_Lua(lua_State * __L) : Lua(__L) { } SDL_mutex * mutex; }; @@ -111,12 +121,21 @@ static void lua_hook(lua_State * __L, lua_Debug * ar) { L->do_break(); do_lua_break = false; } + + if (do_lua_pause) { + L->yield(); + do_lua_pause = false; + lua_paused = true; + } } void start_lua() { - Lua * L = new threaded_Lua(); + Lua * L1; + L = new threaded_Lua(); bool use_builtin_cdtool = false; + L->lock(); + L->open_base(); L->open_math(); L->open_string(); @@ -131,12 +150,15 @@ void start_lua() { CD_PUSHSTATICS(L); Luapsx::pushstatics(L); + + luaopen_opengl(L); + L->pop(); L->push("print"); L->push(lua_print); L->setvar(); - - L->sethook(lua_hook, LUA_MASKLINE, 0); + + L->unlock(); console_lock = SDL_CreateMutex(); console_sem = SDL_CreateSemaphore(0); @@ -158,8 +180,10 @@ void start_lua() { printm(M_WARNING, "There was an error loading built-in cd-tool.lua: %s\n", e.GetMsg()); } } - - SDL_CreateThread(LuaThread, L); + + L1 = L->thread(); + L1->sethook(lua_hook, LUA_MASKLINE, 0); + SDL_CreateThread(LuaThread, L1); } static int LuaThread(void * d) { @@ -169,7 +193,7 @@ static int LuaThread(void * d) { lua_started = true; SDL_mutexP(console_lock); try { - L->load(&console_buffer); + L->resume(&console_buffer); } catch (LuaException e) { /* If there was an error, ignore it, and free the stack */ @@ -192,7 +216,7 @@ class myprinter : public printer_t { myprinter() : lock(SDL_CreateMutex()) { } virtual ~myprinter() { SDL_DestroyMutex(lock); } virtual bool printm(int level, const char * m, va_list ap) { - static String heads[] = {"EE", "--", "WW", "II"}; + static const String heads[] = {"EE", "--", "WW", "II"}; static char buffer[20480]; if (level >= M_INFO) @@ -268,6 +292,10 @@ class timer : public mogltk::widget { String fps; fps.set("FPS: %6.2f", mogltk::engine::FPS()); Application->MainMenu->SetCaption(3, fps); + + L->resume("fps = " + String(mogltk::engine::FPS())); + L->resume("tick = " + String(tick)); + return true; } return false; @@ -358,7 +386,7 @@ virtual int startup() throw (GeneralException) { new hexview::hexview_keyevent; new console::console_keyevent; // Should be one of the last - new mogltk::widgets::InputDialog(0, sh, MainPanel, "Test", "blah blah blah"); +// new mogltk::widgets::InputDialog(0, sh, MainPanel, "Test", "blah blah blah"); // And launching the main loop Root->mainloop(); |