From 4ec94c97879aafef15f7663135745e4ba61e62cf Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 17 May 2021 00:15:33 +0200 Subject: Extract first public LiterateLB version --- tangle/util/noise.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tangle/util/noise.h (limited to 'tangle/util/noise.h') diff --git a/tangle/util/noise.h b/tangle/util/noise.h new file mode 100644 index 0000000..22ad548 --- /dev/null +++ b/tangle/util/noise.h @@ -0,0 +1,39 @@ +#pragma once +#include "assets.h" +#include "texture.h" + +#include +#include +#include + +struct NoiseSource { + const assets::File* current; + sf::Texture texture; + + NoiseSource(cudaSurfaceObject_t& noise) { + current = &assets::noise::files[0]; + texture.loadFromMemory(current->data, current->size); + noise = bindTextureToCuda(texture); + } + + void interact(); +}; + +void NoiseSource::interact() { + ImGui::Image(texture, sf::Vector2f(32,20)); + ImGui::SameLine(); + if (ImGui::BeginCombo("Noise", current->name.c_str())) { + for (unsigned i=0; i < assets::noise::file_count; ++i) { + bool is_selected = (current == &assets::noise::files[i]); + if (ImGui::Selectable(assets::noise::files[i].name.c_str(), is_selected)) { + current = &assets::noise::files[i]; + texture.loadFromMemory(current->data, current->size); + break; + } + if (is_selected) { + ImGui::SetItemDefaultFocus(); + } + } + ImGui::EndCombo(); + } +} -- cgit v1.2.3