Initial integration of docking that saves layout and does not crash

simple_math_single_header
Martin Felis 2017-07-02 20:18:34 +02:00
parent 45efe57988
commit a47adeaa20
6 changed files with 52 additions and 8 deletions

View File

@ -2,7 +2,6 @@
namespace ImGui
{
@ -17,4 +16,4 @@ IMGUI_API void SaveDock();
IMGUI_API void Print();
} // namespace ImGui
} // namespace ImGui

View File

@ -64,6 +64,7 @@ INCLUDE_DIRECTORIES (
3rdparty/bgfx/3rdparty/glsl-optimizer/src/
3rdparty/bgfx/3rdparty/glsl-optimizer/src/mesa/
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/imgui_docking_minimal/include
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/bgfx/3rdparty/ocornut-imgui
${CMAKE_CURRENT_BINARY_DIR}/src
)
@ -86,7 +87,7 @@ SET ( protot_SRCS
src/RuntimeModuleManager.cc
3rdparty/glfw/deps/glad.c
3rdparty/imgui_docking_minimal/imgui/imgui_dock.cpp
3rdparty/imgui_docking_minimal/src/imgui_dock.cpp
)
SET (PROTOT_SOURCE_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -15,6 +15,7 @@
#include "Timer.h"
#include "RuntimeModuleManager.h"
#include "imgui/imgui.h"
#include "imgui_dock.h"
#include "Globals.h"
#include "Serializer.h"
@ -143,6 +144,7 @@ int main(void)
imguiCreate();
GuiInputState gui_input_state;
gGuiInputState = &gui_input_state;
ImGui::LoadDock();
// Timer
Timer timer;
@ -228,6 +230,9 @@ int main(void)
gRenderer = nullptr;
ImGui::SaveDock();
ImGui::ShutdownDock();
imguiDestroy();
bgfx::shutdown();
}

View File

@ -2,7 +2,9 @@
#include "Globals.h"
#include "RenderModule.h"
#include "3rdparty/ocornut-imgui/imgui.h"
#include "3rdparty/ocornut-imgui/imgui_internal.h"
#include "imgui/imgui.h"
#include "imgui_dock.h"
#define GLFW_EXPOSE_NATIVE_GLX
#define GLFW_EXPOSE_NATIVE_X11
#include <GLFW/glfw3.h>
@ -43,6 +45,10 @@ typedef Vector3f Vector3f;
typedef MatrixNNf MatrixNNf;
typedef VectorNf VectorNf;
static bool show_scene0 = true;
static bool show_scene1 = true;
static bool show_scene2 = true;
struct Renderer;
struct module_state {
@ -128,7 +134,7 @@ static bool module_step(struct module_state *state, float dt) {
bgfx::reset (width, height);
int dock_top_offset = 0.0f;
int dock_width = 400;
int dock_width = 0;
// ImGui::RootDock(
// ImVec2(width - dock_width, dock_top_offset),
// ImVec2(dock_width, height - dock_top_offset)
@ -139,6 +145,7 @@ static bool module_step(struct module_state *state, float dt) {
ImGuizmo::Enable(true);
state->renderer->paintGL();
state->renderer->DrawGui();
return true;
}
@ -1700,10 +1707,6 @@ void Renderer::paintGL() {
}
}
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
bgfx::frame();
// if (ImGui::BeginDock("Render Settings")) {
if(ImGui::DragFloat3 ("Light0 Pos", lights[0].pos.data(), 1.0f, -10.0f, 10.0f)) {
}
@ -1739,10 +1742,45 @@ void Renderer::paintGL() {
// ImGui::EndDock();
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
bgfx::frame();
// clear debug commands as they have to be issued every frame
debugCommands.clear();
}
void Renderer::DrawGui() {
ImGuiStyle& style = ImGui::GetStyle();
if (ImGui::GetIO().DisplaySize.y > 0) {
ImVec2 pos = ImVec2(0, 25);
ImVec2 size = ImGui::GetIO().DisplaySize;
size.y -= pos.y;
ImGui::RootDock(pos, ImVec2(size.x, size.y - 25.0f));
// Draw status bar (no docking)
ImGui::SetNextWindowSize(ImVec2(size.x, 25.0f), ImGuiSetCond_Always);
ImGui::SetNextWindowPos(ImVec2(0, size.y - 32.0f), ImGuiSetCond_Always);
ImGui::Begin("statusbar", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoResize);
ImGui::Text("FPS: %f", ImGui::GetIO().Framerate);
ImGui::End();
}
if (ImGui::BeginDock("Docks", &show_scene0)) {
ImGui::Print();
}
ImGui::EndDock();
if (ImGui::BeginDock("Dummy1", &show_scene1)) {
ImGui::Text("Placeholder!");
}
ImGui::EndDock();
// if (ImGui::BeginDock("Dummy2", &show_scene2)) {
// ImGui::Text("Placeholder2!");
// }
// ImGui::EndDock();
}
bool Renderer::updateShaders() {
bool result = true;
for (int i = 0; i < RenderState::Count; i++) {

View File

@ -417,6 +417,7 @@ struct Renderer {
void initialize(int width, int height);
void shutdown();
void paintGL();
void DrawGui();
void resize (int x, int y, int width, int height);
// check whether shader files were modified and reload them. Returns