diff --git a/src/solanaceae/doom.cpp b/src/solanaceae/doom.cpp index 8e052b6..ec63300 100644 --- a/src/solanaceae/doom.cpp +++ b/src/solanaceae/doom.cpp @@ -27,12 +27,6 @@ void my_doom_gettime(int* sec, int* usec) { } } -//static const char* doom_argv[] { - //"self.exe", - //"-timedemo", - //"", -//}; - Doom::Doom( TextureUploaderI& tu ) : _tu(tu) { @@ -56,8 +50,6 @@ Doom::Doom( // does not actually work doom_set_resolution(_width, _height); - // HATE - //doom_init(2, const_cast(doom_argv), 0); doom_init(0, nullptr, 0); std::vector tmp_vec(4 * _width * _height, 0x00); // the api requires data for texture creation @@ -75,9 +67,11 @@ float Doom::render(float time_delta) { doom_update(); + // TODO: use RGB instead? const uint8_t* new_image = doom_get_framebuffer(4); _tu.updateRGBA(_render_texture, new_image, 4 * _width * _height); + // TODO: allow more? return 1.f/60.f; } diff --git a/src/solanaceae/doom_imgui.cpp b/src/solanaceae/doom_imgui.cpp index 0cd1dc8..daf62d8 100644 --- a/src/solanaceae/doom_imgui.cpp +++ b/src/solanaceae/doom_imgui.cpp @@ -93,15 +93,13 @@ float DoomIMGUI::render(float time_delta) { if (ImGui::Begin("doom", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) { ImGui::SliderFloat("scale", &_size_scaler, 1.f, 5.f); - if (ImGui::IsWindowFocused()) { - for (const auto& [imkey, dokey] : g_all_keys) { - // TODO: unpress all keys on focus loss - if (ImGui::IsKeyPressed(imkey, false)) { - _doom.doomKeyDown(dokey); - } - if (ImGui::IsKeyReleased(imkey)) { - _doom.doomKeyUp(dokey); - } + const bool window_focused = ImGui::IsWindowFocused(); + for (const auto& [imkey, dokey] : g_all_keys) { + if (window_focused && ImGui::IsKeyPressed(imkey, false)) { + _doom.doomKeyDown(dokey); + } + if (ImGui::IsKeyReleased(imkey)) { + _doom.doomKeyUp(dokey); } }