added imgui support
This commit is contained in:
parent
9cc37dc4cf
commit
dd9feb9720
@ -20,6 +20,7 @@ set(USE_SERIALIZER True)
|
||||
set(USE_INPUT True)
|
||||
set(USE_BULLET True)
|
||||
set(USE_SOL2 True)
|
||||
set(USE_IMGUI True)
|
||||
set(SFML_MODULES audio graphics)
|
||||
|
||||
set(CMAKE_TEMPLATE_PATH "../CMakeTemplate")
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
{
|
||||
return {
|
||||
{TOGGLE_CONSOLE,input::KEYBOARD},
|
||||
{EXIT_GAME,input::KEYBOARD},
|
||||
{MOVE_CURSOR_LEFT,input::KEYBOARD},
|
||||
{MOVE_CURSOR_RIGHT,input::KEYBOARD}
|
||||
};
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "scene/scenetree.h"
|
||||
#include "sparrowshell/sparrowshell.h"
|
||||
#include "scene/physicsdebugnode.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
Engine::Engine() :
|
||||
m_window(nullptr),
|
||||
@ -81,6 +82,33 @@ void Engine::update()
|
||||
m_input->updateEvents();
|
||||
checkSpecialInputs();
|
||||
|
||||
// initialize imgui frame
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.DeltaTime = float(getDeltaTime()) / 1000.;
|
||||
ImGui::NewFrame();
|
||||
|
||||
// test gui
|
||||
{
|
||||
static bool testGuiOpen = true;
|
||||
if(testGuiOpen)
|
||||
{
|
||||
ImGui::Begin("Test imgui Window", &testGuiOpen);
|
||||
ImGui::Text("Hello, world!");
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||
bool physicsDebugEnabled = (m_physicsDebugNode != nullptr);
|
||||
if(ImGui::Checkbox("Toggle physics debug", &physicsDebugEnabled))
|
||||
{
|
||||
if(physicsDebugEnabled)
|
||||
enablePhysicsDebug();
|
||||
else
|
||||
disablePhysicsDebug();
|
||||
}
|
||||
if(ImGui::Button("EXIT GAME"))
|
||||
stop();
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
// update Physics
|
||||
if(m_world != nullptr)
|
||||
{
|
||||
@ -214,7 +242,12 @@ void Engine::checkSpecialInputs()
|
||||
else if(action.action == m_toggleShellAction)
|
||||
m_sparrowshell->toggleShell();
|
||||
else if(action.action == m_exitGameAction)
|
||||
m_running = false;
|
||||
{
|
||||
if(m_sparrowshell->isVisible())
|
||||
m_sparrowshell->toggleShell();
|
||||
else
|
||||
m_running = false;
|
||||
}
|
||||
else if(action.action == m_showMouseAction)
|
||||
toggleMouseVisibility();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user