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 enum BitmapScrnMode : int { SCR5, SCR6, SCR7, SCR8, SCR11, SCR12, OTHER };
34 int bitmapScrnMode = 0;
35 int bitmapPage = 0; // 0-3 or 0-1 depending on screen mode, -1 for all pages TODO extended VRAM
36 int bitmapLines = 1; // 0->192, 1->212, 2->256
37 int bitmapColor0 = 16; // 0..15, 16->no replacement
38 int bitmapZoom = 0; // 0->1x, 1->2x, ..., 7->8x
39 gl::vec4 bitmapGridColor{0.0f, 0.0f, 0.0f, 0.5f}; // RGBA
40 gl::vec4 rasterBeamColor{1.0f, 0.0f, 0.0f, 0.8f}; // RGBA
41 bool overrideAll = false;
42 bool overrideMode = false;
43 bool overridePage = false;
44 bool overrideLines = false;
45 bool overrideColor0 = false;
46 bool bitmapGrid = true;
47 bool rasterBeam = false;
48
49 std::optional<gl::Texture> bitmapTex; // TODO also deallocate when needed
50 std::optional<gl::Texture> bitmapGridTex;
51
52 static constexpr auto persistentElements = std::tuple{
54 PersistentElement {"overrideAll", &ImGuiBitmapViewer::overrideAll},
55 PersistentElement {"overrideMode", &ImGuiBitmapViewer::overrideMode},
56 PersistentElement {"overridePage", &ImGuiBitmapViewer::overridePage},
57 PersistentElement {"overrideLines", &ImGuiBitmapViewer::overrideLines},
58 PersistentElement {"overrideColor0", &ImGuiBitmapViewer::overrideColor0},
59 PersistentElementMax{"scrnMode", &ImGuiBitmapViewer::bitmapScrnMode, OTHER}, // SCR5..SCR12
60 PersistentElement {"page", &ImGuiBitmapViewer::bitmapPage},
61 PersistentElementMax{"lines", &ImGuiBitmapViewer::bitmapLines, 3},
62 PersistentElementMax{"color0", &ImGuiBitmapViewer::bitmapColor0, 16 + 1},
63 PersistentElementMax{"zoom", &ImGuiBitmapViewer::bitmapZoom, 8},
64 PersistentElement {"showGrid", &ImGuiBitmapViewer::bitmapGrid},
65 PersistentElement {"gridColor", &ImGuiBitmapViewer::bitmapGridColor},
66 PersistentElement {"showRasterBeam", &ImGuiBitmapViewer::rasterBeam},
67 PersistentElement {"rasterBeamColor",&ImGuiBitmapViewer::rasterBeamColor}
68 };
69};
70
71} // namespace openmsx
72
73#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 >