{"id":13622280,"url":"https://github.com/giorgiomarcias/glfwm","last_synced_at":"2025-04-15T05:34:22.716Z","repository":{"id":86643112,"uuid":"43667366","full_name":"giorgiomarcias/glfwm","owner":"giorgiomarcias","description":"GLFW Manager - C++ wrapper with multi-threading","archived":false,"fork":false,"pushed_at":"2024-02-27T08:27:12.000Z","size":126,"stargazers_count":64,"open_issues_count":0,"forks_count":16,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-08-01T21:52:17.622Z","etag":null,"topics":["event-handling","glfw","gui","multi-threading","window-manager"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/giorgiomarcias.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-05T05:48:00.000Z","updated_at":"2024-05-13T07:07:33.000Z","dependencies_parsed_at":"2024-08-01T21:54:25.534Z","dependency_job_id":null,"html_url":"https://github.com/giorgiomarcias/glfwm","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giorgiomarcias%2Fglfwm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giorgiomarcias%2Fglfwm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giorgiomarcias%2Fglfwm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giorgiomarcias%2Fglfwm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giorgiomarcias","download_url":"https://codeload.github.com/giorgiomarcias/glfwm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223661495,"owners_count":17181680,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["event-handling","glfw","gui","multi-threading","window-manager"],"created_at":"2024-08-01T21:01:17.187Z","updated_at":"2024-11-08T09:31:18.069Z","avatar_url":"https://github.com/giorgiomarcias.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"GLFW Manager - C++ wrapper with multi-threading\n===============================================\n\nA [GLFW](http://www.glfw.org) C++ wrapper with additional OOP features.\n\n### Features\n* C++11\n* wrapping of GLFW window-related concepts\n* multiple event handling\n* handling of same event with multiple handlers\n* binding of same handler to multiple windows\n* multiple content drawing\n* drawing of the same content in multiple windows\n* grouping of windows\n* multi-threaded drawing with groups\n* window-to-window update notifications\n* update notifications to whole groups\n* automatic control of the loop\n\n\n\n### Compilation\n#### Dependencies\nThere are two mandatory dependencies.\n\n* [GLFW](http://www.glfw.org), which must have already been installed on the system.\nSee [http://www.glfw.org](http://www.glfw.org) for details.\nAlternatively, it is possible to get GLFW through package managers, such as apt-get (Linux) or MacPort/Homebrew (Mac OS).\n\n* [cmake](https://cmake.org), which is used to compile and install this library, greatly simplifying this tasks.\nSee [https://cmake.org](https://cmake.org) for details.\nAlternatively, as before, it is possible to get cmake through package managers.\n\n\n\n#### Building\nThrough *cmake* it is possible to compile and eventually import this library into another software.\nThere are two ways to do that.\n\n* *install* the shared library binaries somewhere on the system and then import it:\n\n        mkdir glfwm_build\n        cd glfwm_build\n        cmake \u003cpath-to-glfwm\u003e\n        make\n        make install\n\n    Now `glfwm` is installed as a shared library depending on the value of `CMAKE_INSTALL_PREFIX` and can be linked to.\n    Then in the cmake list file `CMakeList.txt` of another project just add:\n\n        ...\n        find_package(glfwm 3.3 REQUIRED)\n        ...\n        add_executable(myexe myexe.cpp)\n        target_link_libraries(myexe glfwm)\n\n    And that's all.\n\n* *include* the library sources in a cmake list file `CMakeList.txt` of another project:\n\n        ...\n        add_subdirectory(\u003cpath-to-glfwm\u003e ${${PROJECT_NAME}_BINARY_DIR}/glfwm)\n        ...\n        add_executable(myexe myexe.cpp)\n        target_link_libraries(myexe glfwm)\n\n    In this way, `glfwm` is compiled as a static library in the build tree of the `myexe` target.\n\n##### Build options\nThere are some options that affect the compilation and/or installation:\n\n* `WITH_MULTITHREADING` enables/disables multi-threading support. This allows windows to operate and be managed in separate threads.\n\n* `BUILD_SHARED_LIBS` makes `glfwm` be built as a shared (if `ON`) or a static (if `OFF`) library.\n\n* `INSTALL_GLFWM` makes `glfwm` be installed (if `ON`) or not (if `OFF`).\n\nDefault values mainly depends on the way it is built as described in the **Building** section above.\n`BUILD_SHARED_LIBS` and `INSTALL_GLFWM` are `OFF` when glfwm is included as a sub-directory, `ON` otherwise.\n`WITH_MULTITHREADING` is always `ON`.\n\nIt is possible to change these options either as argument to the `cmake` command, e.g. `-DWITH_MULTITHREADING=OFF`, or directly in the cmake list file of another project which includes glfwm:\n\n    ...\n    option(WITH_MULTITHREADING \"Build GLFWM with multithreading (i.e. thread-safe) or not.\" OFF)\n    add_subdirectory(\u003cpath-to-glfwm\u003e ${${PROJECT_NAME}_BINARY_DIR}/glfwm)\n    ...\n\n### Usage\nThe main purpose is to manage windows.\nSo the main objects are `Window`s and a `WindowManager` which takes care of.\n\nFirst of all, include the main header:\n\n    #include \u003cGLFWM/glfwm.hpp\u003e\n\nThen initialize the library resources by calling\n\n    glfwm::WindowManager::init();\n\nat the beginning of the program execution, e.g. in the `main` function before everything.\n\nA `Window` can receive events and draw some content.\nFor this purpose, special objects can bind to it.\n\nDerive `EventHandler` and override the `getHandledEventTypes()` and `handle()` methods in order to react to events like cursor position changes and mouse button clicks.\nThen bind such objects to a `Window` s.t. events directed to it may handled:\n\n    class MyHandler : public glfwm::EventHandler {\n        public:\n        glfwm::EventBaseType getHandledEventTypes() const override\n        {\n            return static_cast\u003cglfwm::EventBaseType\u003e(glfwm::EventType::MOUSE_BUTTON);\n        }\n\n        bool handle(const glfwm::EventPointer \u0026e) override\n        {\n            if (e-\u003egetEventType() == glfwm::EventType::MOUSE_BUTTON) {\n                // make some action based on this event\n                ...\n                return true;\n            }\n            return false;\n        }\n    };\n\nDerive `Drawable` and override the `draw()` method.\nThere put the code responsible of drawing the content, e.g. OpenGL calls:\n\n    class MyDrawable : public glfwm::Drawable {\n        public:\n        void draw(const glfwm::WindowID id) override\n        {\n            // draw the content on the screen\n        }\n    };\n\nThen create some `Window` and bind the handler and the drawable to it:\n\n    std::shared_ptr\u003cMyHandler\u003e myHandler = std::make_shared\u003cMyHandler\u003e();\n    std::shared_ptr\u003cMyDrawable\u003e myDrawable = std::make_shared\u003cMyDrawable\u003e();\n    glfwm::WindowPointer mainWin = glfwm::WindowManager::createWindow(800, 600, std::string(), myHandler-\u003egetHandledEventTypes());\n    mainWin-\u003ebindEventHandler(myHandler, 0);    // 0 is the rank among all event handlers bound\n    mainWin-\u003ebindDrawable(myDrawable, 0);       // 0 is the rank among all drawables bound\n\nPossibly create other windows and group them.\nGroups are useful for concurrent management (i.e. multi-threaded windows) or even just for sending notifications to all the windows in the same group.\nNotifications can be used to make several windows react to a single event.\nTo create a group and attach windows:\n\n    glfwm::WindowGroupPointer grp = glfwm::WindowGroup::newGroup();\n    grp-\u003eattachWindow(mainWin-\u003egetID());\n    grp-\u003erunLoopConcurrently();     // this is available only if compiled with WITH_MULTITHREADING=ON\n\nFinally, start the main loop, which ends when all the windows are closed, and release the library resources:\n\n    glfwm::WindowManager::mainLoop();\n    glfwm::WindowManager::terminate();\n\nSee the examples for more details.\n\nIt has been tested on macOS's: 10.9 - 10.10 - 10.11 - 10.12 - 10.13 - 10.14 - 14.3\n\n### License\nThis software is subject to the [zlib/libpng](http://opensource.org/licenses/Zlib) License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiorgiomarcias%2Fglfwm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiorgiomarcias%2Fglfwm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiorgiomarcias%2Fglfwm/lists"}