Skip to content
Snippets Groups Projects
Commit 8b689a3c authored by Jonathan Kunstwald's avatar Jonathan Kunstwald
Browse files

Expand interactive sample

parent 59eeecb7
No related branches found
No related tags found
No related merge requests found
glow-extras @ 74c32ddb
Subproject commit e6a26d9aba5d56f8bcff82eeb882befe5516ee4c
Subproject commit 74c32ddbaac927c5183e6efaebfc4685ae2fd940
#include <iostream>
#include <random>
#include <imgui/imgui.h>
#include <glow/common/str_utils.hh>
#include <glow/data/TextureData.hh>
#include <glow/objects/TextureCubeMap.hh>
......@@ -166,17 +167,38 @@ int main()
glow::viewer::view(pos);
// Interactive
{
// Creating renderables is expensive, cache them whenever possible, and capture by value!
auto r = glow::viewer::make_renderable(pos);
glow::viewer::interactive([r](auto dt) {
auto r1 = glow::viewer::make_renderable(pos);
glow::viewer::interactive([r1](auto dt) {
static auto time = 0.f;
time += dt;
r->transform(tg::translation(tg::vec3(tg::sin(tg::angle32::from_radians(time * .5f)) * .5f, 0.f, 0.f)));
r1->transform(tg::translation(tg::vec3(tg::sin(tg::angle32::from_radians(time * .5f)) * .5f, 0.f, 0.f)));
glow::viewer::view(r);
// Always a cleared view, resetting accumulation each frame
glow::viewer::view_cleared(r1);
});
// Using imgui in an interactive view
auto r2 = glow::viewer::make_renderable(pos);
glow::viewer::interactive([r2](auto) {
static float configurable = 0.f;
ImGui::Begin("Interactive viewer");
auto const input = ImGui::SliderFloat("Height", &configurable, -3.f, 3.f);
ImGui::End();
r2->transform(tg::translation(tg::vec3(0.f, configurable, 0.f)));
{
auto v = glow::viewer::view(r2);
// Conditional clear
if (input)
glow::viewer::clear_accumulation();
}
});
}
}
// tg objects
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment