diff options
author | Adrian Kummerlaender | 2021-05-17 00:15:33 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2021-05-17 00:15:33 +0200 |
commit | 4ec94c97879aafef15f7663135745e4ba61e62cf (patch) | |
tree | 322ae3f003892513f529842ff0b3fd100573b680 /tangle/util/colormap.h | |
download | LiterateLB-4ec94c97879aafef15f7663135745e4ba61e62cf.tar LiterateLB-4ec94c97879aafef15f7663135745e4ba61e62cf.tar.gz LiterateLB-4ec94c97879aafef15f7663135745e4ba61e62cf.tar.bz2 LiterateLB-4ec94c97879aafef15f7663135745e4ba61e62cf.tar.lz LiterateLB-4ec94c97879aafef15f7663135745e4ba61e62cf.tar.xz LiterateLB-4ec94c97879aafef15f7663135745e4ba61e62cf.tar.zst LiterateLB-4ec94c97879aafef15f7663135745e4ba61e62cf.zip |
Extract first public LiterateLB version
Diffstat (limited to 'tangle/util/colormap.h')
-rw-r--r-- | tangle/util/colormap.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tangle/util/colormap.h b/tangle/util/colormap.h new file mode 100644 index 0000000..c01cea8 --- /dev/null +++ b/tangle/util/colormap.h @@ -0,0 +1,38 @@ +#pragma once +#include "assets.h" +#include "texture.h" + +#include <imgui.h> +#include <imgui-SFML.h> +#include <SFML/Graphics.hpp> + +struct ColorPalette { + const assets::File* current; + sf::Texture texture; + + ColorPalette(cudaSurfaceObject_t& palette) { + current = &assets::palette::files[5]; + texture.loadFromMemory(current->data, current->size); + palette = bindTextureToCuda(texture); + } + + void interact(); +}; + +void ColorPalette::interact() { + if (ImGui::BeginCombo("Color palette", current->name.c_str())) { + for (unsigned i=0; i < assets::palette::file_count; ++i) { + bool is_selected = (current == &assets::palette::files[i]); + if (ImGui::Selectable(assets::palette::files[i].name.c_str(), is_selected)) { + current = &assets::palette::files[i]; + texture.loadFromMemory(current->data, current->size); + break; + } + if (is_selected) { + ImGui::SetItemDefaultFocus(); + } + } + ImGui::EndCombo(); + } + ImGui::Image(texture, sf::Vector2f(400.,40.)); +} |