THIS HELPED A LOT!!!
http://www.cegui.org.uk/wiki/index.php/ ... _InterfaceBut I didn't used namespace, classes, typedefs, variables, constants, just tried to do simple job, I tried to call C function from Lua
Code: Select all
// C function
bool MenuItemExit_OnButtonClick(const CEGUI::EventArgs& pEventArgs)
{
glfwCloseWindow();
return true;
}
Code: Select all
-- Lua code
function MenuItemExitHandler(args)
return MenuItemExit_OnButtonClick(args);
end
...initialization skipped due its not related to subject...
-- subscribe required events, i can place here "MenuItemExit_OnButtonClick" directly, but i will need to handle it in Lua in future, save project before close, etc
winMgr:getWindow("root/MenuitemExit"):subscribeEvent("Clicked", "MenuItemExitHandler")
Then I created .pkg file, but only one .pkg, not two .pkg files like in tutorial. Tutorial more complex.
Then I compiled .pkg using .bat file. Now I'm thinking to integrate .bat into prebuild step of MSBuild of Visual Studio 2010. But I want this step only if .pkg or .hpp file changed.
Code: Select all
REM Create lua interface
tolua++cegui_Static.exe -n Sample_FirstWindow -H Sample_FirstWindow_reg.hpp -o Sample_FirstWindow_reg.cpp Sample_FirstWindow.pkg
pause
Then I attached this "Sample_FirstWindow_reg.hpp" to my code. And used this glue-creator function in initialization step:
Code: Select all
#include "Sample_FirstWindow_reg.hpp"
...
void initialiseSample()
{
using namespace CEGUI;
// create a script module.
LuaScriptModule& scriptmod(LuaScriptModule::create());
// tell CEGUI to use this scripting module
System::getSingleton().setScriptingModule(&scriptmod);
tolua_Sample_FirstWindow_open( scriptmod.getLuaState() );
// execute the procgen.lua script which controls the rest of this demo
System::getSingleton().executeScriptFile("procgen.lua");
}
Screenshot
![Image](http://img406.imageshack.us/img406/8441/procgenscreen.png)
Then I click File -> Exit it calls Lua handler function, which calls C function, which calls glfwCloseWindow(), which marks to break main event loop.
Procgen Studio is program name, 0-1D Function is my future software developer company name.