ImGui
This commit is contained in:
@@ -15,9 +15,16 @@ project(
|
||||
source/ *.cpp
|
||||
)
|
||||
|
||||
file(GLOB IMGUI_SOURCES
|
||||
../Libraries/imgui/*.h
|
||||
../Libraries/imgui/*.cpp
|
||||
"../Libraries/imgui/backends/imgui_impl_glfw.cpp"
|
||||
"../Libraries/imgui/backends/imgui_impl_glfw.h"
|
||||
"../Libraries/imgui/backends/imgui_impl_opengl3.cpp"
|
||||
"../Libraries/imgui/backends/imgui_impl_opengl3.h")
|
||||
add_compile_definitions(_EXPORTING)
|
||||
|
||||
add_library(HydraEngine SHARED ${SOURCES})
|
||||
add_library(HydraEngine SHARED ${SOURCES} ${IMGUI_SOURCES})
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +50,9 @@ include_directories(HydraEngine, "../Libraries/stb-master/")
|
||||
#********** BOX3d ********
|
||||
target_link_libraries(HydraEngine PRIVATE "C:/Code/HydraV3/Libraries/box3d/src/Debug/box3dd.lib")
|
||||
include_directories(HydraEngine, "../Libraries/box3d/include/")
|
||||
|
||||
#********** IMGUI ********
|
||||
include_directories(HydraEngine, "../Libraries/imgui/")
|
||||
include_directories(HydraEngine, "../Libraries/imgui/backends")
|
||||
|
||||
include_directories(HydraClient "${CMAKE_SOURCE_DIR}/HydraEngine/includes")
|
||||
if(WIN32)
|
||||
|
||||
@@ -163,7 +163,6 @@ void HydraActorManager::SetPosition(HydraID actorID, glm::dvec3 position)
|
||||
HydraPositionComponent &pos_comp = ecs->GetComponent<HydraPositionComponent>(actorID);
|
||||
pos_comp.position = position;
|
||||
|
||||
|
||||
if(!pos_comp.needs_update)
|
||||
{
|
||||
ecs->GetSystem<HydraTransformSystem>()->UpdateTransform(actorID);
|
||||
|
||||
@@ -69,6 +69,8 @@
|
||||
#include "../task/renderer/HydraEndRenderTask.hpp"
|
||||
|
||||
#include "../mesh/HydraMeshManager.h"
|
||||
#include "../gui/HydraGuiManager.h"
|
||||
|
||||
HydraTaskScheduler *const HydraEngine::TaskScheduler()
|
||||
{
|
||||
return m_task_scheduler;
|
||||
@@ -208,6 +210,7 @@ void HydraEngine::_CreateManagers()
|
||||
m_material_buffer_manager = new HydraMaterialBufferManager();
|
||||
m_light_buffer_manager = new HydraLightBufferManager();
|
||||
m_shadow_buffer_manager = new HydraShadowBufferManager();
|
||||
m_gui_manager = new HydraGUIManager();
|
||||
|
||||
}
|
||||
|
||||
@@ -232,6 +235,7 @@ void HydraEngine::_InitialiseManagers()
|
||||
|
||||
HydraID create_shadow_buffer_task_id = m_task_scheduler->CreateTask<HydraInitialiseShadowBufferTask>(HydraThreadAffinity::Render);
|
||||
m_task_scheduler->WaitForTask(create_shadow_buffer_task_id);
|
||||
m_gui_manager->Intialise();
|
||||
|
||||
}
|
||||
|
||||
@@ -474,6 +478,11 @@ void HydraEngine::_GameLoop()
|
||||
HydraRenderPipelineTask* render_def_task = static_cast<HydraRenderPipelineTask*>(m_task_scheduler->GetTask(render_def_task_id));
|
||||
render_def_task->Initialise(m_deferred_pipeline);
|
||||
m_task_scheduler->WaitForTask(render_def_task_id);
|
||||
|
||||
m_gui_manager->BeginFrame();
|
||||
m_gui_manager->DrawWindows();
|
||||
m_gui_manager->EndFrame();
|
||||
|
||||
|
||||
HydraID end_task_id = m_task_scheduler->CreateTask<HydraEndRenderTask>(HydraThreadAffinity::Render);
|
||||
m_task_scheduler->WaitForTask(end_task_id);
|
||||
@@ -489,7 +498,7 @@ void HydraEngine::_Shutdown()
|
||||
|
||||
|
||||
//Shutdown the buffer and vertex buffer managers
|
||||
|
||||
m_gui_manager->Shutdown();
|
||||
HydraID shutdown_buffer_mgr_id = m_task_scheduler->CreateTask<HydraShutdownBufferManagerTask>(HydraThreadAffinity::Render);
|
||||
m_task_scheduler->WaitForTask(shutdown_buffer_mgr_id);
|
||||
|
||||
@@ -513,6 +522,7 @@ void HydraEngine::_Shutdown()
|
||||
delete m_texture_buffer_manager;
|
||||
delete m_material_buffer_manager;
|
||||
delete m_light_buffer_manager;
|
||||
delete m_gui_manager;
|
||||
}
|
||||
|
||||
bool HydraEngine::KeyPressed(HYDRA_KEY_CODES key)
|
||||
|
||||
@@ -32,6 +32,7 @@ class HydraPointShadowSourceSystem;
|
||||
class HydraPhysicsSystem;
|
||||
class HydraTickActorsSystem;
|
||||
class HydraShadowCasterSystem;
|
||||
class HydraGUIManager;
|
||||
|
||||
class CLASS_DEFINE HydraEngine : public HydraObject
|
||||
{
|
||||
@@ -98,6 +99,7 @@ private:
|
||||
HydraMaterialBufferManager* m_material_buffer_manager = nullptr;
|
||||
HydraLightBufferManager* m_light_buffer_manager = nullptr;
|
||||
HydraShadowBufferManager* m_shadow_buffer_manager = nullptr;
|
||||
HydraGUIManager* m_gui_manager = nullptr;
|
||||
|
||||
std::shared_ptr<HydraMeshSystem> m_mesh_system;
|
||||
std::shared_ptr<HydraTransformSystem> m_transform_system;
|
||||
|
||||
@@ -13,7 +13,7 @@ void HydraObject::DebugLog(std::string log_entry)
|
||||
#ifdef __unix__ /* __unix__ is usually defined by compilers targeting Unix systems */
|
||||
std::cout << log_entry + "\r\n";
|
||||
#elif defined(_WIN32) || defined(WIN32) /* _Win32 is usually defined by compilers targeting 32 or 64 bit Windows systems */
|
||||
OutputDebugString(log_entry.c_str());
|
||||
//OutputDebugString(log_entry.c_str());
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#include "HydraGuiManager.h"
|
||||
#include "HydraSceneGraphWindow.h"
|
||||
#include "../scheduler/HydraTaskScheduler.h"
|
||||
#include "../task/gui/HydraInitialiseGUITask.hpp"
|
||||
#include "../task/gui/HydraShutdownGUITask.hpp"
|
||||
#include "../task/gui/HydraStartGUIFrameTask.hpp"
|
||||
#include "../task/gui/HydraDrawWindowTask.hpp"
|
||||
#include "../task/gui/HydraEndGUIFrameTask.hpp"
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_glfw.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
|
||||
void HydraGUIManager::Intialise()
|
||||
{
|
||||
HydraID task_id = GetEngine()->TaskScheduler()->CreateTask<HydraInitialiseGUITask>(HydraThreadAffinity::Render);//, barrier_id);
|
||||
HydraInitialiseGUITask* task = static_cast<HydraInitialiseGUITask*>(GetEngine()->TaskScheduler()->GetTask(task_id));
|
||||
|
||||
GetEngine()->TaskScheduler()->WaitForTask(task_id);
|
||||
|
||||
std::unique_ptr<HydraSceneGraphWindow> window = std::make_unique<HydraSceneGraphWindow>();
|
||||
AddWindow(std::move(window));
|
||||
}
|
||||
|
||||
void HydraGUIManager::Shutdown()
|
||||
{
|
||||
for(uint32_t i = 0; i < m_windows.size(); i++)
|
||||
{
|
||||
m_windows[i].release();
|
||||
}
|
||||
m_windows.clear();
|
||||
HydraID task_id = GetEngine()->TaskScheduler()->CreateTask<HydraShutdownGUITask>(HydraThreadAffinity::Render);//, barrier_id);
|
||||
GetEngine()->TaskScheduler()->WaitForTask(task_id);
|
||||
}
|
||||
|
||||
void HydraGUIManager::BeginFrame()
|
||||
{
|
||||
HydraID task_id = GetEngine()->TaskScheduler()->CreateTask<HydraStartGUIFrameTask>(HydraThreadAffinity::Render);//, barrier_id);
|
||||
GetEngine()->TaskScheduler()->WaitForTask(task_id);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void HydraGUIManager::DrawWindows()
|
||||
{
|
||||
for(uint32_t i = 0; i < m_windows.size(); i++)
|
||||
{
|
||||
HydraID task_id = GetEngine()->TaskScheduler()->CreateTask<HydraDrawWindowTask>(HydraThreadAffinity::Render);//, barrier_id);
|
||||
HydraDrawWindowTask* task = static_cast<HydraDrawWindowTask*>(GetEngine()->TaskScheduler()->GetTask(task_id));
|
||||
task->Initialise(m_windows[i].get());
|
||||
GetEngine()->TaskScheduler()->WaitForTask(task_id);
|
||||
}
|
||||
}
|
||||
|
||||
void HydraGUIManager::EndFrame()
|
||||
{
|
||||
HydraID task_id = GetEngine()->TaskScheduler()->CreateTask<HydraEndGUIFrameTask>(HydraThreadAffinity::Render);//, barrier_id);
|
||||
GetEngine()->TaskScheduler()->WaitForTask(task_id);
|
||||
}
|
||||
|
||||
void HydraGUIManager::AddWindow(std::unique_ptr<HydraGuiWindow> window)
|
||||
{
|
||||
m_windows.push_back(std::move(window));
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef HYDRAGUIMANAGER
|
||||
#define HYDRAGUIMANAGER
|
||||
#include "../engine/HydraObject.h"
|
||||
#include "HydraGuiWindow.h"
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
class HydraGUIManager : public HydraObject
|
||||
{
|
||||
public:
|
||||
void Intialise();
|
||||
void Shutdown();
|
||||
|
||||
void BeginFrame();
|
||||
void DrawWindows();
|
||||
void EndFrame();
|
||||
|
||||
void AddWindow(std::unique_ptr<HydraGuiWindow> window);
|
||||
private:
|
||||
std::vector<std::unique_ptr<HydraGuiWindow>> m_windows;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /* HYDRAGUIMANAGER */
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef HYDRAGUIWINDOW
|
||||
#define HYDRAGUIWINDOW
|
||||
|
||||
#include "../engine/HydraObject.h"
|
||||
|
||||
|
||||
class HydraGuiWindow : public HydraObject
|
||||
{
|
||||
public:
|
||||
virtual void DrawComponents() = 0;
|
||||
private:
|
||||
};
|
||||
|
||||
#endif /* HYDRAGUIWINDOW */
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "HydraSceneGraphWindow.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_glfw.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
|
||||
void HydraSceneGraphWindow::DrawComponents()
|
||||
{
|
||||
float f = 0.0f;
|
||||
bool val1 = false;
|
||||
bool val2 = true;
|
||||
uint32_t counter = 0;
|
||||
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
|
||||
|
||||
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
||||
ImGui::Checkbox("Demo Window", &val1); // Edit bools storing our window open/close state
|
||||
ImGui::Checkbox("Another Window", &val2);
|
||||
|
||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||
|
||||
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||
counter++;
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("counter = %d", counter);
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||
ImGui::End();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef HYDRASCENEGRAPHYWINDOW
|
||||
#define HYDRASCENEGRAPHYWINDOW
|
||||
#include "../engine/HydraObject.h"
|
||||
#include "HydraGuiWindow.h"
|
||||
|
||||
class HydraSceneGraphWindow : public HydraGuiWindow
|
||||
{
|
||||
public:
|
||||
void DrawComponents() override;
|
||||
private:
|
||||
};
|
||||
|
||||
#endif /* HYDRASCENEGRAPHYWINDOW */
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef HYDRADRAWWINDOWTASK
|
||||
#define HYDRADRAWWINDOWTASK
|
||||
#include "../HydraTask.h"
|
||||
#include "../../engine/HydraEngine.h"
|
||||
#include "../../renderer/HydraRenderer.h"
|
||||
#include "../../windowmanager/HydraWindowManager.h"
|
||||
#include "../../gui/HydraGuiWindow.h"
|
||||
#include "../../GlewIncludes.h"
|
||||
#include <GLMIncludes.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_glfw.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
|
||||
class HydraDrawWindowTask : public HydraTask
|
||||
{
|
||||
private:
|
||||
HydraGuiWindow* m_window = nullptr;
|
||||
|
||||
protected:
|
||||
public:
|
||||
void Process() override
|
||||
{
|
||||
m_window->DrawComponents();
|
||||
}
|
||||
void Initialise(HydraGuiWindow* window)
|
||||
{
|
||||
m_window = window;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* HYDRADRAWWINDOWTASK */
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef HYDRAENDGUIFRAMETASK
|
||||
#define HYDRAENDGUIFRAMETASK
|
||||
#include "../HydraTask.h"
|
||||
#include "../../engine/HydraEngine.h"
|
||||
#include "../../renderer/HydraRenderer.h"
|
||||
#include "../../windowmanager/HydraWindowManager.h"
|
||||
#include "../../GlewIncludes.h"
|
||||
#include <GLMIncludes.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_glfw.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
|
||||
class HydraEndGUIFrameTask : public HydraTask
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
protected:
|
||||
public:
|
||||
void Process() override
|
||||
{
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
ImGui::EndFrame();
|
||||
}
|
||||
void Initialise()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* HYDRAENDGUIFRAMETASK */
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef HYDRAINITIALISEGUITASK
|
||||
#define HYDRAINITIALISEGUITASK
|
||||
#include "../HydraTask.h"
|
||||
#include "../../engine/HydraEngine.h"
|
||||
#include "../../renderer/HydraRenderer.h"
|
||||
#include "../../windowmanager/HydraWindowManager.h"
|
||||
#include "../../GlewIncludes.h"
|
||||
#include <GLMIncludes.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_glfw.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
|
||||
class HydraInitialiseGUITask : public HydraTask
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
protected:
|
||||
public:
|
||||
void Process() override
|
||||
{
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // IF using Docking Branch
|
||||
|
||||
// Setup Platform/Renderer backends
|
||||
|
||||
ImGui_ImplGlfw_InitForOpenGL(GetEngine()->WindowManager()->GetWindow(), true); // Second param install_callback=true will install GLFW callbacks and chain to existing ones.
|
||||
ImGui_ImplOpenGL3_Init();
|
||||
}
|
||||
void Initialise()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* HYDRAINITIALISEGUITASK */
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef HYDRASHUTDOWNGUITASK
|
||||
#define HYDRASHUTDOWNGUITASK
|
||||
|
||||
#include "../HydraTask.h"
|
||||
#include "../../engine/HydraEngine.h"
|
||||
#include "../../renderer/HydraRenderer.h"
|
||||
#include "../../windowmanager/HydraWindowManager.h"
|
||||
#include "../../GlewIncludes.h"
|
||||
#include <GLMIncludes.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_glfw.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
|
||||
class HydraShutdownGUITask : public HydraTask
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
protected:
|
||||
public:
|
||||
void Process() override
|
||||
{
|
||||
// Setup Dear ImGui context
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
void Initialise()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* HYDRASHUTDOWNGUITASK */
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef HYDRASTARTGUIFRAMETASK
|
||||
#define HYDRASTARTGUIFRAMETASK
|
||||
|
||||
#include "../HydraTask.h"
|
||||
#include "../../engine/HydraEngine.h"
|
||||
#include "../../renderer/HydraRenderer.h"
|
||||
#include "../../windowmanager/HydraWindowManager.h"
|
||||
#include "../../GlewIncludes.h"
|
||||
#include <GLMIncludes.h>
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_glfw.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
|
||||
class HydraStartGUIFrameTask : public HydraTask
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
protected:
|
||||
public:
|
||||
void Process() override
|
||||
{
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
}
|
||||
void Initialise()
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* HYDRASHUTDOWNGUITASK */
|
||||
@@ -24,8 +24,10 @@ public:
|
||||
b3BodyEvents events = b3World_GetBodyEvents(m_world_id);
|
||||
|
||||
HydraTaskScheduler* task_scheduler = GetEngine()->TaskScheduler();
|
||||
// HydraID barrier_id = task_scheduler->CreateBarrier();
|
||||
|
||||
|
||||
std::vector<HydraID> tasks;
|
||||
|
||||
uint32_t job_count = 0;
|
||||
for(uint32_t i = 0; i < events.moveCount; i ++)
|
||||
{
|
||||
HydraID task_id = task_scheduler->CreateTask<HydraSetWorldTransformTask>(HydraThreadAffinity::General);//, barrier_id);
|
||||
@@ -37,10 +39,12 @@ public:
|
||||
HydraID* entity_id = reinterpret_cast<HydraID*>(events.moveEvents[i].userData);
|
||||
|
||||
set_task->Initialise(*entity_id, position, rotation);
|
||||
//task_scheduler->StartTask(task_id);
|
||||
task_scheduler->WaitForTask(task_id);
|
||||
|
||||
|
||||
}
|
||||
//task_scheduler->WaitForBarrier(barrier_id);
|
||||
|
||||
|
||||
}
|
||||
void Initialise(b3WorldId world_id, float delta_t_seconds)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user