SpiderPig Posted April 24 Share Posted April 24 I'm using the latest steam version on the dev branch and get the error popup "Invalid function syntax fot hook ID 2". This is my code. void NotificationManager_UpdateHook(shared_ptr<Object> object) { } ... void NotificationManager::Init() { world->AddHook(HOOKID_UPDATE, NotificationManager_UpdateHook, Self()); } Based on the parameters for AddHook() my function syntax looks correct... and HOOKID_RENDER works. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted April 24 Author Share Posted April 24 Oh... wait. I don't think my paths are actually pointing to steam. One sec... Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted April 24 Author Share Posted April 24 Yup. It's not working with Steam. Quote Link to comment Share on other sites More sharing options...
Josh Posted April 24 Share Posted April 24 Use this overload: void AddHook(const HookID id, void (*hook)(std::shared_ptr<Object> source, std::shared_ptr<Object> extra), std::shared_ptr<Object> extra = nullptr); 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted April 24 Author Share Posted April 24 Hmm it crashes with an out of memory range error. My class inherits Object so the function is available and compiles. void NotificationManager_UpdateHook(shared_ptr<Engine::Object> source, shared_ptr<Engine::Object> object) { } ... void NotificationManager::Init() { AddHook(HOOKID_UPDATE, NotificationManager_UpdateHook, Self()); } Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted April 30 Solution Share Posted April 30 I had to change the way hooks are inserted into the object info. In the next build, this example will work: #include "UltraEngine.h" using namespace UltraEngine; struct MyObject : public Object { int count{ 0 }; static void Hook(shared_ptr<Object> source, shared_ptr<Object> extra) { auto world = source->As<World>(); auto o = extra->As<MyObject>(); o->count++; Print(o->count); } }; int main(int argc, const char* argv[]) { //Get the display list auto displays = GetDisplays(); //Create a window auto window = CreateWindow("Ultra Engine", 0, 0, 1920, 1080, displays[0], WINDOW_CLIENTCOORDS | WINDOW_CENTER | WINDOW_TITLEBAR); //Create a world auto world = CreateWorld(); auto o = std::make_shared<MyObject>(); world->AddHook(HOOKID_UPDATE, MyObject::Hook, o); //Main loop while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false) { world->Update(); Sleep(1000); } return 0; } 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.