imgui scale

This commit is contained in:
Green Sky 2024-03-09 15:34:48 +01:00
parent 633f885c65
commit cf39f2d14c
No known key found for this signature in database
2 changed files with 15 additions and 9 deletions

View File

@ -90,19 +90,23 @@ const static std::vector<std::pair<ImGuiKey, doom_key_t>> g_all_keys {
float DoomIMGUI::render(float time_delta) { float DoomIMGUI::render(float time_delta) {
float doom_interval {1.f}; float doom_interval {1.f};
if (ImGui::Begin("doom")) { if (ImGui::Begin("doom", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
for (const auto& [imkey, dokey] : g_all_keys) { ImGui::SliderFloat("scale", &_size_scaler, 1.f, 5.f);
// TODO: unpress all keys on focus loss
if (ImGui::IsKeyPressed(imkey, false)) { if (ImGui::IsWindowFocused()) {
_doom.doomKeyDown(dokey); for (const auto& [imkey, dokey] : g_all_keys) {
} // TODO: unpress all keys on focus loss
if (ImGui::IsKeyReleased(imkey)) { if (ImGui::IsKeyPressed(imkey, false)) {
_doom.doomKeyUp(dokey); _doom.doomKeyDown(dokey);
}
if (ImGui::IsKeyReleased(imkey)) {
_doom.doomKeyUp(dokey);
}
} }
} }
doom_interval = _doom.render(time_delta); doom_interval = _doom.render(time_delta);
ImGui::Image(reinterpret_cast<void*>(_doom.getTexID()), {320, 200*1.2}); ImGui::Image(reinterpret_cast<void*>(_doom.getTexID()), {_size_scaler * 320, _size_scaler * 200 * 1.2f});
} }
ImGui::End(); ImGui::End();

View File

@ -6,6 +6,8 @@ class DoomIMGUI {
// inherit instead? // inherit instead?
Doom _doom; Doom _doom;
float _size_scaler {2.f};
public: public:
DoomIMGUI( DoomIMGUI(
TextureUploaderI& tu TextureUploaderI& tu