{"id":18027641,"url":"https://github.com/phisko/kreogl","last_synced_at":"2025-04-04T20:19:10.140Z","repository":{"id":39708662,"uuid":"483115695","full_name":"phisko/kreogl","owner":"phisko","description":"A simple OpenGL renderer, aimed to get any game project up and running with simple but satisfying graphics.","archived":false,"fork":false,"pushed_at":"2023-02-27T16:07:13.000Z","size":6573,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-10T04:44:39.065Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phisko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-04-19T05:59:58.000Z","updated_at":"2023-01-31T19:45:43.000Z","dependencies_parsed_at":"2024-10-30T08:43:07.480Z","dependency_job_id":null,"html_url":"https://github.com/phisko/kreogl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phisko%2Fkreogl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phisko%2Fkreogl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phisko%2Fkreogl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phisko%2Fkreogl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phisko","download_url":"https://codeload.github.com/phisko/kreogl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247242687,"owners_count":20907135,"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":[],"created_at":"2024-10-30T08:12:05.151Z","updated_at":"2025-04-04T20:19:10.108Z","avatar_url":"https://github.com/phisko.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kreogl\n\n[![build](https://github.com/phisko/kreogl/workflows/build/badge.svg)](https://github.com/phisko/kreogl/actions/workflows/build.yml)\n\nA simple OpenGL renderer, aimed to get any game project up and running with simple but satisfying graphics.\n\n## Motivation\n\nI'm not a graphics programmer and, although I do find it fun when I get pretty things to appear on-screen, I much prefer [metaprogramming](https://github.com/phisko/reflection/) and [engine architecture](https://github.com/phisko/kengine/). However, whenever I've wanted to get some proof-of-concept graphics, I've always been frustrated to see there's no 3D equivalent to [SFML](https://www.sfml-dev.org/): a simple 3D graphics library, letting me load meshes and draw them without having to write my own shaders.\n\nEventually I came to accept this, and started implementing a custom OpenGL system for the [kengine](https://github.com/phisko/kengine/). This was a learning process for me, as it was my first time toying with graphics programming.\n\nNow that I'm relatively satisfied with the final result (although it's far from perfect), I figured it was time to move the functionality out of the `kengine` and have it become what I was initially looking for, so that future engine programmers don't have to write their own renderer from scratch.\n\n## Usage\n\nTake a look at the [example code](example). There are two examples:\n* [a simple one](example/simple_main.cpp) which shows how to quickly draw and animate a model\n* [a more complex one](example/complex_main.cpp), which makes use of most available features but may be a bit harder to follow\n\nThe examples can be built by setting the `KREOGL_EXAMPLE` CMake option.\n\nBelow is a snippet of the important parts of the simple example:\n\n```cpp\nkreogl::window window; // create a window\nwindow.get_default_camera().set_position({ 0.f, 0.f, -5.f }); // move the camera back to see the centered scene\n\nkreogl::world world; // the world that will be used to draw into the window\n\nconst kreogl::skybox_texture skybox_texture{ // load the skybox\n\t\"resources/skybox/left.jpg\",\n\t\"resources/skybox/right.jpg\",\n\t\"resources/skybox/top.jpg\",\n\t\"resources/skybox/bottom.jpg\",\n\t\"resources/skybox/front.jpg\",\n\t\"resources/skybox/back.jpg\",\n};\nworld.skybox.texture = \u0026skybox_texture; // add it to the world\n\nkreogl::directional_light light; // create a light\nworld.add(light); // add it to the world\nlight.direction = { 0.f, -1.f, -1.f };\nlight.cast_shadows = false; // disable shadows for our scene\n\nconst auto model = kreogl::assimp::load_animated_model(\"resources/funnyman/funnyman.fbx\"); // load a 3d model\nassert(model \u0026\u0026 model-\u003eanimations.size() == 1);\n\nkreogl::animated_object object; // create an object\nobject.model = model.get(); // base it on the loaded 3d model\nobject.transform = glm::translate(glm::mat4{1.f}, glm::vec3{ 0.f, -2.5f, 5.f }); // move it forward and down a bit\nobject.transform = glm::rotate(object.transform, glm::pi\u003cfloat\u003e(), glm::vec3{ 0.f, 1.f, 0.f }); // rotate it to face the camera\nobject.animation = kreogl::animation{ // play an animation\n\t.model = model-\u003eanimations-\u003eanimations[0].get(), // use the animation that was baked into the 3d model\n\t.loop = true\n};\nworld.add(object); // add the object to the world\n\n// main loop\nauto previous_time = std::chrono::system_clock::now();\nwhile (!window.should_close()) {\n\tconst auto now = std::chrono::system_clock::now();\n\tconst auto delta_time = float(std::chrono::duration_cast\u003cstd::chrono::milliseconds\u003e(now - previous_time).count()) / 1000.f;\n\tprevious_time = now;\n\n\tobject.tick_animation(delta_time); // play the object's animation\n\n\twindow.poll_events(); // process input\n\twindow.draw(world); // draw the world into the window\n\twindow.display(); // present the new window contents\n}\n```\n\nAnd here's a screenshot of the result:\n\n![](docs/example_simple.png)\n\n## API\n\n### High level objects\n\nThese are objects that will typically live for as long as the application is running.\n\n* [window](kreogl/window.md)\n* [world](kreogl/world.md)\n* [camera](kreogl/camera.md)\n\n### Basic drawables\n\n* [object](kreogl/object.md)\n* [sprite](kreogl/sprite.md)\n* [text](kreogl/text.md)\n* [debug_element](kreogl/debug_element.md)\n\n### Lights\n\n* [directional_light](kreogl/lights/directional_light.md)\n* [point_light](kreogl/lights/point_light.md)\n* [spot_light](kreogl/lights/spot_light.md)\n\n### Loaders\n\nThese provide functions to load [models](kreogl/model/model.md) from files.\n\n* [assimp](kreogl/loaders/assimp/assimp.md)\n* [polyvox](kreogl/loaders/polyvox/polyvox.md)\n\n### Animation\n\n* [animated_object](kreogl/animation/animated_object.md)\n\nThe rest of these types are less user-facing, and understanding them isn't required for basic animation code.\n\n* [animated_model](kreogl/animation/animated_model.md)\n* [animation](kreogl/animation/animation.md)\n* [animation_file](kreogl/animation/animation_file.md)\n* [animation_model](kreogl/animation/animation_model.md)\n* [skeleton](kreogl/animation/skeleton.md)\n* [skeleton_model](kreogl/animation/skeleton_model.md)\n\n## Implementation details\n\nThis describe the internal implementation of the rendering engine. You don't need to be aware of these to make use of `kreogl`, but if you wish to improve/extend/understand its behavior, this is a good starting point.\n\n### [viewport](kreogl/impl/viewport.md)\n\nEach [camera](kreogl/camera.md) has an associated viewport, which represents the on-screen area used to display the camera.\n\n### [gbuffer](kreogl/impl/gbuffer.md)\n\nEach [viewport](kreogl/impl/viewport.md) has an underlying G-buffer, which contains the intermediate rendering data generated when drawing the camera content. It can be used to query the position, color, or custom user data that was drawn in a specific pixel.\n\n### [RAII](https://en.cppreference.com/w/cpp/language/raii) wrappers to OpenGL resources\n\n* [buffer](kreogl/impl/raii/buffer.md)\n* [frame_buffer](kreogl/impl/raii/frame_buffer.md)\n* [scoped_bind_framebuffer](kreogl/impl/raii/scoped_bind_framebuffer.md)\n* [scoped_gl_feature](kreogl/impl/raii/scoped_gl_feature.md)\n* [texture](kreogl/impl/raii/texture.md)\n* [vertex_array](kreogl/impl/raii/vertex_array.md)\n\n### Shadow maps\n\n* [shadow_map](kreogl/impl/shadow_maps/shadow_map.md)\n* [shadow_cube](kreogl/impl/shadow_maps/shadow_cube.md)\n* [cascaded_shadow_map](kreogl/impl/shadow_maps/cascaded_shadow_map.md)\n\n### Textures\n\n* [texture_data](kreogl/impl/texture/texture_data.md)\n* [skybox_texture](kreogl/impl/texture/skybox_texture.md)\n\n### Shapes\n\n* [box](kreogl/impl/shapes/box.md)\n* [line](kreogl/impl/shapes/line.md)\n* [quad](kreogl/impl/shapes/quad.md)\n* [sphere](kreogl/impl/shapes/sphere.md)\n* [textured_quad](kreogl/impl/shapes/textured_quad.md)\n\n### Shaders\n\nShaders are instances of [shader](kreogl/impl/shaders/shader.md), grouped into a [shader_pipeline](kreogl/impl/shaders/shader_pipeline.md), which can be passed to `window::draw`. The default pipeline contains all the pre-implemented shaders:\n\n#### gbuffer shaders\n\nThese are shaders in charge of filling the [gbuffer](kreogl/impl/gbuffer.md).\n\n* [position_color_shader](kreogl/impl/shaders/gbuffer/position_color/position_color_shader.md)\n* [skeletal_textured_shader](kreogl/impl/shaders/gbuffer/skeletal_textured/skeletal_textured_shader.md)\n* [debug_shader](kreogl/impl/shaders/gbuffer/debug/debug_shader.md)\n* [sprite_shader](kreogl/impl/shaders/gbuffer/sprite/sprite_shader.md)\n* [text_shader](kreogl/impl/shaders/gbuffer/text/text_shader.md)\n\n#### Lighting shaders\n\nThese are shaders in charge of applying lighting to what was previously written into the [gbuffer](kreogl/impl/gbuffer.md), and writing the result to the main framebuffer.\n\n* [directional_light_shader](kreogl/impl/shaders/lighting/directional_light/directional_light_shader.md)\n* [point_light_shader](kreogl/impl/shaders/lighting/point_light/point_light_shader.md)\n* [spot_light_shader](kreogl/impl/shaders/lighting/spot_light/spot_light_shader.md)\n\n#### Post-lighting shaders\n\nThese are shaders that run after the lighting pass, and can render effects to alter the lighting of the scene.\n\n* [volumetric_directional_light](kreogl/impl/shaders/post_lighting/volumetric_lighting/volumetric_directional_light/volumetric_directional_light_shader.md)\n* [volumetric_point_light](kreogl/impl/shaders/post_lighting/volumetric_lighting/volumetric_point_light/volumetric_point_light_shader.md)\n* [volumetric_spot_light](kreogl/impl/shaders/post_lighting/volumetric_lighting/volumetric_spot_light/volumetric_spot_light_shader.md)\n\n#### Post-process shaders\n\nThese are shaders that run after the post-lighting pass, and can add the \"final touches\" to the scene.\n\n* [light_sphere_shader](kreogl/impl/shaders/post_process/light_sphere/light_sphere_shader.md)\n* [skybox_shader](kreogl/impl/shaders/post_process/skybox/skybox_shader.md)\n\n#### Shadowmap shaders\n\nThese are shaders that implement the [shadow_map_shader](kreogl/impl/shaders/shadow_map/shadow_map_shader.md) or [shadow_cube_shader](kreogl/impl/shaders/shadow_map/shadow_cube_shader.md) interfaces, and are called by the lighting shaders to fill lights' [ShadowMaps](kreogl/impl/shadow_maps/shadow_map.md).\n\n* [position_shadow_map_shader](kreogl/impl/shaders/shadow_map/position_shadow_map/position_shadow_map_shader.md)\n* [position_shadow_cube_shader](kreogl/impl/shaders/shadow_map/position_shadow_cube/position_shadow_cube_shader.md)\n* [skeletal_shadow_map_shader](kreogl/impl/shaders/shadow_map/skeletal_shadow_map/skeletal_shadow_map_shader.md)\n* [skeletal_shadow_cube_shader](kreogl/impl/shaders/shadow_map/skeletal_shadow_cube/skeletal_shadow_cube_shader.md)\n\n## Profiling\n\nThe code is instrumented using [Tracy](https://github.com/wolfpld/tracy). Profiling can be enabled by setting the `KREOGL_PROFILING` CMake option.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphisko%2Fkreogl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphisko%2Fkreogl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphisko%2Fkreogl/lists"}