{"action":"created","issue":{"url":"https://api.github.com/repos/wjakob/nanogui/issues/35","labels_url":"https://api.github.com/repos/wjakob/nanogui/issues/35/labels{/name}","comments_url":"https://api.github.com/repos/wjakob/nanogui/issues/35/comments","events_url":"https://api.github.com/repos/wjakob/nanogui/issues/35/events","html_url":"https://github.com/wjakob/nanogui/issues/35","id":122579369,"number":35,"title":"Launching nanogui Screen in a separate thread","user":{"login":"mrzv","id":720816,"avatar_url":"https://avatars.githubusercontent.com/u/720816?v=3","gravatar_id":"","url":"https://api.github.com/users/mrzv","html_url":"https://github.com/mrzv","followers_url":"https://api.github.com/users/mrzv/followers","following_url":"https://api.github.com/users/mrzv/following{/other_user}","gists_url":"https://api.github.com/users/mrzv/gists{/gist_id}","starred_url":"https://api.github.com/users/mrzv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrzv/subscriptions","organizations_url":"https://api.github.com/users/mrzv/orgs","repos_url":"https://api.github.com/users/mrzv/repos","events_url":"https://api.github.com/users/mrzv/events{/privacy}","received_events_url":"https://api.github.com/users/mrzv/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":24,"created_at":"2015-12-16T19:08:50Z","updated_at":"2016-01-19T10:01:13Z","closed_at":null,"body":"I would like to launch a nanogui `Screen` in a thread of its own. This works as intended on Linux, but crashes and burns on a Mac. Any suggestions and pointers would be very welcome.\r\n\r\n```\r\n#include <iostream>\r\n#include <thread>\r\n#include <nanogui/screen.h>\r\n\r\nnamespace ng = nanogui;\r\n\r\nint main(int argc, char *argv[])\r\n{\r\n    std::thread t([]()\r\n    {\r\n        try\r\n        {\r\n            nanogui::init();\r\n\r\n            ng::Screen* app = new ng::Screen(ng::Vector2i { 800, 600 }, \"Test\");\r\n\r\n            app->drawAll();\r\n            app->setVisible(true);\r\n\r\n            nanogui::mainloop();\r\n\r\n            delete app;\r\n\r\n            nanogui::shutdown();\r\n        } catch (const std::runtime_error &e)\r\n        {\r\n            std::string error_msg = std::string(\"Caught a fatal error: \") + std::string(e.what());\r\n            #if defined(WIN32)\r\n                MessageBoxA(nullptr, error_msg.c_str(), NULL, MB_ICONERROR | MB_OK);\r\n            #else\r\n                std::cerr << error_msg << '\\n';\r\n            #endif\r\n            return -1;\r\n        }\r\n    });\r\n    t.join();\r\n\r\n    return 0;\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/wjakob/nanogui/issues/comments/172799932","html_url":"https://github.com/wjakob/nanogui/issues/35#issuecomment-172799932","issue_url":"https://api.github.com/repos/wjakob/nanogui/issues/35","id":172799932,"user":{"login":"mrzv","id":720816,"avatar_url":"https://avatars.githubusercontent.com/u/720816?v=3","gravatar_id":"","url":"https://api.github.com/users/mrzv","html_url":"https://github.com/mrzv","followers_url":"https://api.github.com/users/mrzv/followers","following_url":"https://api.github.com/users/mrzv/following{/other_user}","gists_url":"https://api.github.com/users/mrzv/gists{/gist_id}","starred_url":"https://api.github.com/users/mrzv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrzv/subscriptions","organizations_url":"https://api.github.com/users/mrzv/orgs","repos_url":"https://api.github.com/users/mrzv/repos","events_url":"https://api.github.com/users/mrzv/events{/privacy}","received_events_url":"https://api.github.com/users/mrzv/received_events","type":"User","site_admin":false},"created_at":"2016-01-19T10:01:13Z","updated_at":"2016-01-19T10:01:13Z","body":"I've pushed the changes I've made to https://github.com/mrzv/nanogui in case you want to take a look."}}