{"id":13532738,"url":"https://github.com/hugoam/two","last_synced_at":"2025-04-08T10:33:25.682Z","repository":{"id":41413298,"uuid":"116430022","full_name":"hugoam/two","owner":"hugoam","description":"c++ toolkit for rapid development of live graphical apps and games","archived":false,"fork":false,"pushed_at":"2023-11-21T18:16:25.000Z","size":23070,"stargazers_count":1684,"open_issues_count":9,"forks_count":93,"subscribers_count":75,"default_branch":"master","last_synced_at":"2025-04-01T09:25:44.263Z","etag":null,"topics":["gamedev","reflection","rendering","ui"],"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/hugoam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-01-05T21:48:50.000Z","updated_at":"2025-04-01T06:15:47.000Z","dependencies_parsed_at":"2022-09-21T08:13:08.063Z","dependency_job_id":"864bd34c-cc85-406b-8c13-a92e78f9e36c","html_url":"https://github.com/hugoam/two","commit_stats":{"total_commits":1424,"total_committers":2,"mean_commits":712.0,"dds":0.0175561797752809,"last_synced_commit":"d4b386f48c572da03ac5c89e702cf08f388d434d"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugoam%2Ftwo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugoam%2Ftwo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugoam%2Ftwo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugoam%2Ftwo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hugoam","download_url":"https://codeload.github.com/hugoam/two/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247824130,"owners_count":21002209,"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":["gamedev","reflection","rendering","ui"],"created_at":"2024-08-01T07:01:13.397Z","updated_at":"2025-04-08T10:33:25.657Z","avatar_url":"https://github.com/hugoam.png","language":"C++","readme":"![libtwo](media/libtwo0s.png?raw=true)\n\n| CI            | Community     | Support   |\n| ------------- | ------------- | --------- |\n[![Build Status](https://travis-ci.org/hugoam/two.svg?branch=master)](https://travis-ci.org/hugoam/two) [![Build status](https://ci.appveyor.com/api/projects/status/4a77n3scl71ybcgj?svg=true)](https://ci.appveyor.com/project/hugoam/two) | [![Gitter](https://badges.gitter.im/hugoam/two.svg)](https://gitter.im/hugoam/two) | [![Patreon](https://img.shields.io/badge/donate-patreon-orange.svg)](https://www.patreon.com/bePatron?u=11301355)\n\ntwo is an all-purpose c++ app prototyping library, focused towards live graphical apps and games.  \ntwo contains all the essential building blocks to develop lean c++ apps from scratch, providing [reflection](#reflection) and low level [generic](#generic-features) algorithms, an [immediate ui](#ui) paradigm, and an immediate minimalistic and flexible [graphics renderer](#graphics).\n\ntwo aims to provide the *quickest idioms* to build functional and lightweight c++ graphical applications. It wagers that the future of application and game coding lies in small, self-contained, reusable and shared libraries, and **not** in gigantic tightly coupled *engines* of hundreds thousands of lines of code. It tackles the problem of the code you *don't* want to write, and *should not have* to write when prototyping an app.\n\ntwo provides two main APIs, two low-level application building blocks which you can use just as well from native C++ as from higher-level language bindings:\n\n- a stable API for [mid-level graphics rendering](https://github.com/hugoam/two/blob/master/docs/graphics.md) (think scenes, shapes, meshes, models, lights, materials, passes, post-processing, etc).\n- a stable API for fully auto-layout, stylable, [declarative/immediate mode UI](https://github.com/hugoam/two/blob/master/docs/ui.md) (with a large set of widgets, docking, tabs, nodes, text editors, inputs, curves etc).\n\nEach of those layers are also their own libraries, available as [twfx](https://github.com/hugoam/twfx) and [twui](https://github.com/hugoam/twui), which can be used independently: they are not tied to one another.\n\n**two** is open-source, and published under the zlib license: as such it is looking for sponsors, funding, and your support through [patreon](https://www.patreon.com/libmud).\n\n### live coding\n\nAs a demonstration of the features and API of two, you can try this [live-coding environment](https://hugoam.github.io/two/editor/editor.html), which allows you to browse and edit (in real-time) any of the 35 examples we ported from three.js\n\n[![samples](media/samples0.gif?raw=true)](https://hugoam.github.io/two/editor/editor.html)\n\n### building\ntwo is built with [GENie](https://github.com/bkaradzic/GENie) build system, which is based on premake and consists of a bunch of lua scripts. The GENie binaries needed by two for windows and linux are included for convenience in the `bin` folder.  \nTo get a headstart and build two you should clone this repository, and run GENie which will generate projects for two libraries and for the examples.\n\nThe build instructions for linux and gcc look like:\n- `git clone https://github.com/hugoam/bx`\n- `git clone https://github.com/hugoam/bimg`\n- `git clone https://github.com/hugoam/bgfx`\n- `git clone --recursive https://github.com/hugoam/two`\n- `cd two`\n- for linux (make):\n  - `bin/linux/genie --gcc=linux-gcc gmake`\n  - `cd build/projects/gmake-linux`\n  - `make config=debug64 -j8`\n- for osx (make): `bin/darwin/genie --gcc=osx gmake`\n- for osx (xcode): `bin/darwin/genie --xcode=osx xcode9`\n- for windows (visual studio): `bin/windows/genie vs2017`\n\n### quickstart\nThis is the minimal sample code you need to run a two application\n```c++\n#include \u003ctwo/two.h\u003e\n\nusing namespace two;\n\nbool pump(Shell\u0026 app)\n{\n    // ui code goes here\n    return app.pump();\n}\n\nint main(int argc, char *argv[])\n{\n    Shell app(RESOURCE_PATH);\n    app.run(pump);\n}\n```\n\nAdd some UI code or some graphics code in the body of the function to get started using two.  \nDon't hesitate to have a look at the examples!\n\n![samples](media/ui0.gif?raw=true)\n\n### [ui](docs/ui.md)\n\ntwo ui uses a novel paradigm that sits halfway between **immediate** (like dear imgui) and **retained** ui (like Qt) : its API looks and feels exactly like an immediate ui library, except not much is *actually* done immediately. As such, we prefer to refer to it as a **declarative** ui.  \nThe final tree of widgets will look exactly like the tree of the declarations that is traversed on any given frame. however, events are processed, and rendering is done in a separate step.\n\nOnce you have setup a window and called the `begin()` function on the root widget on each iteration, you can freely declare/draw all your widgets:\n```c++\nWidget\u0026 window = ui::window(uroot, \"My Window\");\nui::label(window, \"Welcome to two ui\");\nif(ui::button(window, \"Click me !\"))\n    printf(\"Button clicked !\\n\");\nui::color_edit(window, Colour(1.f, 0.34f, 0.73f));\n```\n\nThe styles of all widgets are entirely customizable, through style sheets declared in the json format  \nstyles govern literally all aspects of :\n- the layout of the widgets\n- the appearance of the widgets\n\nBy switching between [style sheets]() on the fly, you can instantly change the **whole** appearance of the ui\n\nYou can also specify styles on a per-widget basis, by passing in a style parameter\n```c++\nStyle style = {};\nui::button(parent, style, \"Click me!\");\n```\n\nAn extensive UI example demonstrates the usage in a way no documentation ever could: have a look at the code.\n\n### [graphics](graphics.md)\ntwo gfx library uses the same immediate paradigm as the ui. instead of nesting ui nodes (widgets) calls, you nest graphics nodes calls. as such it is perfect for quickly setting up some debug graphics rendering.\n\n```c++\n// create a viewer to render into\nSceneViewer\u0026 viewer = ui::scene_viewer(uroot);\nGnode\u0026 groot = viewer.m_scene.m_graph.begin();\n\n// draw a node, which transform applies to children of this node\nGnode\u0026 gnode gfx::node(root, {}, vec3(0.f, 15.f, 7.5f));\n\n// draw a cube shape item as a child of node\ngfx::shape(gnode, Symbol(Colour::White), Cube());\n\n// draw a 3d model item as a child of node\nItem\u0026 item = gfx::model(gnode, \"my_3d_model.obj\");\n\n// animate a model\nAnimated\u0026 animated = gfx::animated(gnode, item);\nanimated.play(\"walk\");\n```\n\nA collection of 35 examples ported from three.js demonstrate most usages of the API: check them out to get familiar with how to use two.\n\n### examples\n\n#### [pbr materials](https://hugoam.github.io/two-io/examples/03_materials_low.html)\n![pbr materials](https://github.com/hugoam/two-io/blob/master/media/03_materials.png)\n\n#### [lights](https://hugoam.github.io/two-io/examples/04_lights.html)\n![lights](https://github.com/hugoam/two-io/blob/master/media/04_lights.png)\n\n#### [sponza (.obj import)](https://hugoam.github.io/two-io/examples/04_sponza.html)\n![sponza (.obj import)](https://github.com/hugoam/two-io/blob/master/media/04_sponza.png)\n\n#### [character (animations)](https://hugoam.github.io/two-io/examples/05_character.html)\n![character (animations)](https://github.com/hugoam/two-io/blob/master/media/05_character.png)\n\n#### [particles](https://hugoam.github.io/two-io/examples/06_particles.html)\n![particles](https://github.com/hugoam/two-io/blob/master/media/06_particles.png)\n\n#### [gltf](https://hugoam.github.io/two-io/examples/07_gltf.html)\n![gltf](https://github.com/hugoam/two-io/blob/master/media/07_gltf.png)\n\n#### [sky (perez model)](https://hugoam.github.io/two-io/examples/08_sky.html)\n![sky (perez model)](https://github.com/hugoam/two-io/blob/master/media/08_sky.png)\n\n#### [live shader](https://hugoam.github.io/two-io/examples/09_live_shader.html)\n![live shader](https://github.com/hugoam/two-io/blob/master/media/09_live_shader.png)\n\n#### [live graphics](https://hugoam.github.io/two-io/examples/14_live_gfx.html)\n![live graphics](https://github.com/hugoam/two-io/blob/master/media/14_live_gfx.png)\n\n#### [live graphics (visual script)](https://hugoam.github.io/two-io/examples/4_live_gfx_visual.html)\n![live graphics (visual script)](https://github.com/hugoam/two-io/blob/master/media/14_live_gfx_visual.png)\n\n### credits\ntwo couldn't exist without:\n- [GENie](https://github.com/bkaradzic/GENie) build system\n- [bgfx](https://github.com/bkaradzic/bgfx) rendering library\n- [vg-renderer](https://github.com/jdryg/vg-renderer) and [NanoVG](https://github.com/memononen/nanovg) vector drawing libraries\n- [lua](https://github.com/lua/lua) scripting language\n- [stb](https://github.com/nothings/stb) headers\n- [glm](https://github.com/g-truc/glm) math library\n- [json](https://github.com/nlohmann/json) header\n\n### license\ntwo is licensed under the [zlib license](LICENSE.txt).\n","funding_links":["https://www.patreon.com/bePatron?u=11301355","https://www.patreon.com/libmud"],"categories":["C++","Libraries"],"sub_categories":["C++"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugoam%2Ftwo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhugoam%2Ftwo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugoam%2Ftwo/lists"}