2021-06-02 17:20:15 +04:30
|
|
|
#include "ltpch.h"
|
|
|
|
#include "dxUserInterface.h"
|
|
|
|
#include "dxSharedContext.h"
|
|
|
|
|
|
|
|
#include <imgui.h>
|
|
|
|
#include <imgui_impl_win32.h>
|
|
|
|
#include <imgui_impl_dx11.h>
|
|
|
|
|
|
|
|
#define GLFW_EXPOSE_NATIVE_WIN32
|
|
|
|
#include <glfw/glfw3.h>
|
|
|
|
#include <glfw/glfw3native.h>
|
|
|
|
|
|
|
|
namespace Light {
|
|
|
|
|
2021-06-19 15:12:42 +04:30
|
|
|
dxUserInterface::dxUserInterface(GLFWwindow* windowHandle, std::shared_ptr<dxSharedContext> sharedContext)
|
2021-06-02 17:20:15 +04:30
|
|
|
{
|
2021-06-19 15:12:42 +04:30
|
|
|
// create context
|
2021-06-02 17:20:15 +04:30
|
|
|
IMGUI_CHECKVERSION();
|
|
|
|
ImGui::CreateContext();
|
2021-06-19 15:12:42 +04:30
|
|
|
|
|
|
|
// configure io
|
2021-06-02 17:20:15 +04:30
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
|
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
|
|
|
|
2021-07-16 19:59:14 +04:30
|
|
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
|
|
|
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
|
|
|
|
|
|
|
|
io.ConfigFlags |= ImGuiBackendFlags_PlatformHasViewports;
|
|
|
|
io.ConfigFlags |= ImGuiBackendFlags_RendererHasViewports;
|
|
|
|
|
2021-06-19 15:12:42 +04:30
|
|
|
// style
|
2021-06-02 17:20:15 +04:30
|
|
|
ImGui::StyleColorsDark();
|
|
|
|
|
2021-06-19 15:12:42 +04:30
|
|
|
// init
|
2021-06-02 17:20:15 +04:30
|
|
|
ImGui_ImplWin32_Init(glfwGetWin32Window(windowHandle));
|
2021-07-01 19:25:46 +04:30
|
|
|
ImGui_ImplDX11_Init(sharedContext->GetDevice().Get(), sharedContext->GetDeviceContext().Get());
|
2021-06-02 17:20:15 +04:30
|
|
|
}
|
|
|
|
|
|
|
|
dxUserInterface::~dxUserInterface()
|
|
|
|
{
|
|
|
|
ImGui_ImplDX11_Shutdown();
|
|
|
|
ImGui_ImplWin32_Shutdown();
|
|
|
|
ImGui::DestroyContext();
|
|
|
|
}
|
|
|
|
|
|
|
|
void dxUserInterface::Begin()
|
|
|
|
{
|
|
|
|
ImGui_ImplDX11_NewFrame();
|
|
|
|
ImGui_ImplWin32_NewFrame();
|
|
|
|
ImGui::NewFrame();
|
|
|
|
|
2021-07-01 19:25:46 +04:30
|
|
|
//** #TEMP_IMGUI_DEMO_TEMP# **//
|
2021-06-02 17:20:15 +04:30
|
|
|
ImGui::ShowDemoWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void dxUserInterface::End()
|
|
|
|
{
|
|
|
|
ImGui::Render();
|
|
|
|
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
2021-07-16 19:59:14 +04:30
|
|
|
|
|
|
|
ImGui::UpdatePlatformWindows();
|
|
|
|
ImGui::RenderPlatformWindowsDefault();
|
2021-06-02 17:20:15 +04:30
|
|
|
}
|
|
|
|
|
|
|
|
void dxUserInterface::LogDebugData()
|
|
|
|
{
|
2021-06-19 15:12:42 +04:30
|
|
|
// #todo: improve
|
2021-06-02 17:20:15 +04:30
|
|
|
LT_ENGINE_INFO("________________________________________");
|
|
|
|
LT_ENGINE_INFO("UserInterface::");
|
|
|
|
LT_ENGINE_INFO(" API : ImGui");
|
|
|
|
LT_ENGINE_INFO(" Version: {}", ImGui::GetVersion());
|
2021-07-01 19:25:46 +04:30
|
|
|
LT_ENGINE_INFO(" GraphicsAPI : DirectX");
|
2021-06-02 17:20:15 +04:30
|
|
|
LT_ENGINE_INFO("________________________________________");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|