Skip to content

Commit

Permalink
Hack to fix ImGUI
Browse files Browse the repository at this point in the history
  • Loading branch information
albertvaka committed Jun 20, 2024
1 parent b3c3ad3 commit 7ac61f3
Showing 1 changed file with 16 additions and 33 deletions.
49 changes: 16 additions & 33 deletions engine/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,24 @@ void main_loop()
BeginTextureMode(Window::windowRenderTexture);

#ifdef _IMGUI
SetMouseScale(1, 1); // HACK: ImGUI isn't scaled so keep the mouse scale at 1, the correct scale will be set in Input::Update
rlImGuiBegin();
#endif

float uncappedDt = GetFrameTime();

float dt = uncappedDt;
bool slowDown = false;
constexpr float kMinDt = 0.06f; // less than 17 FPS
if (uncappedDt > kMinDt)
{
//Slow game down instead of epic jumps
dt = kMinDt;
slowDown = true;
}

Input::Update(dt);

if (SceneManager::newScene != nullptr) {
if (SceneManager::currentScene == nullptr) {
// This branch is only taken the first time. We have this here so
Expand All @@ -134,43 +149,11 @@ void main_loop()

SceneManager::newScene = nullptr;
GameCamera::SetZoom(1.f);
GameCamera::SetTopLeft(0,0);
GameCamera::SetTopLeft(0, 0);
Input::IgnoreInput(false);
SceneManager::currentScene->EnterScene();
}

float uncappedDt = GetFrameTime();

float dt = uncappedDt;
bool slowDown = false;
constexpr float kMinDt = 0.06f; // less than 17 FPS
if (uncappedDt > kMinDt)
{
//Slow game down instead of epic jumps
dt = kMinDt;
slowDown = true;
}

//Input
/*
#ifdef _IMGUI
ImGuiIO& io = ImGui::GetIO();
if (!io.WantCaptureKeyboard)
#endif
{
//Keyboard::_UpdateInputState();
}
#ifdef _IMGUI
if (!io.WantCaptureMouse)
#endif
{
//Mouse::_UpdateInputState();
}
*/

Input::Update(dt);

if (IsKeyPressed(KeyboardKey::KEY_ENTER) && IsKeyDown(KeyboardKey::KEY_LEFT_ALT)) {
Window::SetFullScreen(!Window::IsFullScreen());
}
Expand Down

0 comments on commit 7ac61f3

Please sign in to comment.