{"id":19118572,"url":"https://github.com/dkosmari/gtk-sfml","last_synced_at":"2026-04-18T03:32:40.883Z","repository":{"id":204557302,"uuid":"711746716","full_name":"dkosmari/gtk-sfml","owner":"dkosmari","description":"A set of gtkmm3 widgets for SFML integration.","archived":false,"fork":false,"pushed_at":"2023-11-09T19:28:24.000Z","size":373,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-22T12:26:19.346Z","etag":null,"topics":["c-plus-plus","cpp","cross-platform-library","graphics","gtkmm","gtkmm3","library","multimedia","opengl","sfml"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dkosmari.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-30T05:02:34.000Z","updated_at":"2024-11-13T22:16:11.000Z","dependencies_parsed_at":"2025-01-03T07:30:41.749Z","dependency_job_id":null,"html_url":"https://github.com/dkosmari/gtk-sfml","commit_stats":null,"previous_names":["dkosmari/gtk-sfml"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/dkosmari/gtk-sfml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkosmari%2Fgtk-sfml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkosmari%2Fgtk-sfml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkosmari%2Fgtk-sfml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkosmari%2Fgtk-sfml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dkosmari","download_url":"https://codeload.github.com/dkosmari/gtk-sfml/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkosmari%2Fgtk-sfml/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31955712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["c-plus-plus","cpp","cross-platform-library","graphics","gtkmm","gtkmm3","library","multimedia","opengl","sfml"],"created_at":"2024-11-09T05:07:01.243Z","updated_at":"2026-04-18T03:32:40.877Z","avatar_url":"https://github.com/dkosmari.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GTK-SFML - A set of gtkmm widgets for integration with SFML.\n\nGTK-SFML is a C++ library that integrates [SFML](https://www.sfml-dev.org/) with\n[gtkmm](https://gtkmm.org).\n\nThis version supports gtkmm 3 and SFML 3.\n\nOn some systems, this approach allows for higher frame rates than using OpenGL directly\nwith GTK+ (e.g. GTK+ will cap the OpenGL rendering to 30 fps, while GTK-SFML will perform\nthe exact same rendering at 60 fps)\n\nThis is done through widgets that offer an `on_render()` pure virtual method for SFML\nrendering.\n\n\n## Example\n\nHere's [an example](examples/window.cpp) from the examples directory:\n\n```cpp\n#include \u003cSFML/Graphics.hpp\u003e\n#include \u003cSFML/System/Vector2.hpp\u003e\n#include \u003cgtkmm.h\u003e\n\n#include \u003cgtk3-sfml3/Window.hpp\u003e\n\n#include \"font.hpp\"\n\n\nstruct MyWindow :\n    gtksfml::Window {\n\n    sf::Font font{FONT_DATA, FONT_SIZE};\n    sf::Text text{font, \"Window demo\"};\n\n\n    MyWindow()\n    {\n        set_default_size(500, 300);\n        text.setPosition({100, 100});\n    }\n\n\n    void\n    on_render()\n        override\n    {\n        clear({64, 0, 0});\n        draw(text);\n        display();\n    }\n\n};\n\n\nint main()\n{\n    auto app = Gtk::Application::create();\n    MyWindow window;\n    return app-\u003erun(window);\n}\n```\n\nThe following widgets are provided:\n\n- `gtksfml::ApplicationWindow` (from [`\u003cgtk3-sfml3/ApplicationWindow.hpp\u003e`](include/gtk3-sfml3/ApplicationWindow.hpp))\n- `gtksfml::DrawingArea` (from [`\u003cgtk3-sfml3/DrawingArea.hpp\u003e`](include/gtk3-sfml3/DrawingArea.hpp))\n- `gtksfml::Window` (from [`\u003cgtk3-sfml3/Window.hpp\u003e`](include/gtk3-sfml3/Window.hpp))\n\nTo use these classes, the user must derive from them, and override one or more of the\nmethods:\n\n - `void on_event(const sf::Event\u0026 event)`: this is how GTK+ events can be handled as if\n   they were SFML events. You cannot use `pollEvent()` to retrieve events, since GTK+ is\n   handling the events.\n - `void on_render()`: (**mandatory**) called by GTK+ during a widget's \"draw\"\n   event.\n - `void on_update()`: called periodically if the \"auto update\" flag is set.\n\nEach GTK-SFML widget has an \"auto-update\" flag, that can be controlled by the\n`set_auto_update(bool enable)` method. When it's enabled, the `on_update()` method will be\ncalled periodically, followed by a redraw request (that will invoke `on_render()`). If\n\"auto-update\" is disabled, the `on_update()` method is not called, and the redraw only\noccurs when GTK+ deems it necessary (e.g. the widget got resized.) This flag is enabled by\ndefault.\n\n\n## Prerequisites\n\nFor this library to work you need:\n\n- [gtkmm](https://gtkmm.org) (only gtkmm 3.x is supported at the moment)\n- [SFML](https://www.sfml-dev.org/) (version 3.0 or above)\n- A C++17 (or better) compiler.\n\n\n## Build instructions\n\n0. When cloning from the repository, you need to first run `./bootstrap`. This step is not\n   needed when obtaining a source tarball, as the resulting files are already included in\n   the tarball.\n\n1. `./configure --prefix=/usr`\n\n2. `make`\n\n3. `sudo make install`\n\nFor more installation options, use `./configure --help`. This is a standard Automake\npackage.\n\n\n## Usage\n\nA `pkg-config` script, `gtk3-sfml3.pc` will be installed, which provides the compilation\nand linker flags to use GTK-SFML.\n\n\n### With Makefiles\n\nIn a Makefile, you would use:\n\n```Makefile\nCXXFLAGS := $(shell pkg-config --cflags gtk3-sfml3)\nLIBS := $(shell pkg-config --libs gtk3-sfml3)\n```\n\n\n### With Autoconf/Automake\n\nIf using Autoconf/Automake, you can use the `PKG_CHECK_MODULES` macro in `configure.ac`:\n\n```\nPKG_CHECK_MODULES([GTKSFML], [gtk3-sfml3])\n```\n\nThen the `Makefile.am` can use:\n\n```Makefile\nAM_CXXFLAGS = $(GTKSFML_CFLAGS)\nLDADD = $(GTKSFML_LIBS)\n# if linking into a library, use _LIBADD instead of LDADD\n```\n\n\n### With Cmake\n\nThe [FindPkgConfig](https://cmake.org/cmake/help/latest/module/FindPkgConfig.html) module can obtain the flags from a pkg-config module:\n\n```cmake\nfind_package(PkgConfig)\n\npkg_check_modules(GTKSFML gtk3-sfml3)\n\n# now use GTKSFML_CFLAGS and GTKSFML_LDFLAGS in your target\n```\n\n\n### Invoking the compiler directly in a shell\n\nSimply use [command\nsubstitution](https://www.gnu.org/software/bash/manual/html_node/Command-Substitution.html)\nto invoke `pkg-config`:\n\n```\ng++ -c my-code.cpp $(pkg-config gtk3-sfml3 --cflags)\ng++ my-code.o -o my-program $(pkg-config gtk3-sfml3 --libs)\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkosmari%2Fgtk-sfml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdkosmari%2Fgtk-sfml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkosmari%2Fgtk-sfml/lists"}