openMSX
ImGuiBitmapViewer.hh
Go to the documentation of this file.
1#ifndef IMGUI_BITMAP_VIEWER_HH
2#define IMGUI_BITMAP_VIEWER_HH
3
4#include "ImGuiPart.hh"
5
6#include "GLUtil.hh"
7#include "gl_vec.hh"
8
9#include <cstdint>
10#include <optional>
11#include <span>
12
13namespace openmsx {
14
15class ImGuiBitmapViewer final : public ImGuiPart
16{
17public:
19
20 [[nodiscard]] zstring_view iniName() const override { return "bitmap viewer"; }
21 void save(ImGuiTextBuffer& buf) override;
22 void loadLine(std::string_view name, zstring_view value) override;
23 void paint(MSXMotherBoard* motherBoard) override;
24
25private:
26 void renderBitmap(std::span<const uint8_t> vram, std::span<const uint32_t, 16> palette16,
27 int mode, int lines, int page, uint32_t* output) const;
28
29public:
30 bool showBitmapViewer = false;
31
32private:
33 int bitmapManual = 0; // 0 -> use VDP settings, 1 -> use manual settings
34 enum BitmapScrnMode : int { SCR5, SCR6, SCR7, SCR8, SCR11, SCR12, OTHER };
35 int bitmapScrnMode = 0;
36 int bitmapPage = 0; // 0-3 or 0-1 depending on screen mode TODO extended VRAM
37 int bitmapLines = 1; // 0->192, 1->212, 2->256
38 int bitmapColor0 = 16; // 0..15, 16->no replacement
39 int bitmapZoom = 0; // 0->1x, 1->2x, ..., 7->8x
40 bool bitmapGrid = true;
41 gl::vec4 bitmapGridColor{0.0f, 0.0f, 0.0f, 0.5f}; // RGBA
42
43 std::optional<gl::Texture> bitmapTex; // TODO also deallocate when needed
44 std::optional<gl::Texture> bitmapGridTex;
45
46 static constexpr auto persistentElements = std::tuple{
47 PersistentElement {"show", &ImGuiBitmapViewer::showBitmapViewer},
48 PersistentElementMax{"override", &ImGuiBitmapViewer::bitmapManual, 2},
49 PersistentElementMax{"scrnMode", &ImGuiBitmapViewer::bitmapScrnMode, OTHER}, // SCR5..SCR12
50 PersistentElementMax{"page", &ImGuiBitmapViewer::bitmapPage, 4},
51 PersistentElementMax{"lines", &ImGuiBitmapViewer::bitmapLines, 3},
52 PersistentElementMax{"color0", &ImGuiBitmapViewer::bitmapColor0, 16 + 1},
53 PersistentElementMax{"zoom", &ImGuiBitmapViewer::bitmapZoom, 8},
54 PersistentElement {"showGrid", &ImGuiBitmapViewer::bitmapGrid},
55 PersistentElement {"gridColor",&ImGuiBitmapViewer::bitmapGridColor}
56 };
57};
58
59} // namespace openmsx
60
61#endif
void loadLine(std::string_view name, zstring_view value) override
void paint(MSXMotherBoard *motherBoard) override
void save(ImGuiTextBuffer &buf) override
zstring_view iniName() const override
ImGuiPart(ImGuiManager &manager_)
Definition ImGuiPart.hh:12
Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.
This file implemented 3 utility functions:
Definition Autofire.cc:11
PersistentElement(zstring_view, T C::*) -> PersistentElement< C, T >