Initial tests to get docking working
parent
e0e57a2b4f
commit
2f874b6d0d
|
@ -142,6 +142,7 @@ int main(void)
|
|||
imguiCreate();
|
||||
GuiInputState gui_input_state;
|
||||
gGuiInputState = &gui_input_state;
|
||||
ImGui::InitDockContext();
|
||||
|
||||
// Timer
|
||||
Timer timer;
|
||||
|
@ -169,6 +170,7 @@ int main(void)
|
|||
// Start the imgui frame such that widgets can be submitted
|
||||
handle_mouse();
|
||||
glfwGetWindowSize(gWindow, &width, &height);
|
||||
|
||||
imguiBeginFrame (gGuiInputState->mouseX,
|
||||
gGuiInputState->mouseY,
|
||||
gGuiInputState->mouseButton,
|
||||
|
|
|
@ -127,10 +127,24 @@ static bool module_step(struct module_state *state, float dt) {
|
|||
assert (gWindow != nullptr);
|
||||
glfwGetWindowSize(gWindow, &width, &height);
|
||||
state->renderer->updateShaders();
|
||||
state->renderer->resize (width, height);
|
||||
|
||||
bgfx::reset (width, height);
|
||||
|
||||
int dock_top_offset = 20.0f;
|
||||
int dock_width = 400;
|
||||
ImGui::RootDock(
|
||||
ImVec2(width - dock_width, dock_top_offset),
|
||||
ImVec2(dock_width, height - dock_top_offset)
|
||||
);
|
||||
// ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4 (0.5f, 0.5f, 0.5f, 0.5f));
|
||||
|
||||
state->renderer->resize (0, 20.0f, width - dock_width, height - 20.0f);
|
||||
// state->renderer->resize (0, 20.0f, width, height - 20.0f);
|
||||
|
||||
state->renderer->paintGL();
|
||||
|
||||
// ImGui::PopStyleColor();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1165,14 +1179,14 @@ namespace bgfx {
|
|||
|
||||
|
||||
void Renderer::initialize(int width, int height) {
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
this->view_width = width;
|
||||
this->view_height = height;
|
||||
|
||||
uint32_t debug = BGFX_DEBUG_TEXT;
|
||||
uint32_t reset = BGFX_RESET_VSYNC;
|
||||
|
||||
reset = BGFX_RESET_VSYNC | BGFX_RESET_MAXANISOTROPY | BGFX_RESET_MSAA_X16;
|
||||
bgfx::reset(width, height, reset);
|
||||
bgfx::reset(view_width, view_height, reset);
|
||||
|
||||
bgfx::setViewClear(0
|
||||
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
|
||||
|
@ -1180,7 +1194,7 @@ void Renderer::initialize(int width, int height) {
|
|||
, 1.0f
|
||||
, 0
|
||||
);
|
||||
bgfx::setViewRect(0, 0, 0, width, height);
|
||||
bgfx::setViewRect(0, view_offset_x, view_offset_y, view_width, view_height);
|
||||
|
||||
bgfx::RendererType::Enum renderer = bgfx::getRendererType();
|
||||
flipV = false
|
||||
|
@ -1206,7 +1220,7 @@ void Renderer::initialize(int width, int height) {
|
|||
mCurrentLightProbe = LightProbe::Bolonga;
|
||||
|
||||
initialized = true;
|
||||
resize (width, height);
|
||||
resize (view_offset_x, view_offset_y, view_width, view_height);
|
||||
bgfx::frame();
|
||||
}
|
||||
|
||||
|
@ -1264,12 +1278,12 @@ void Renderer::shutdown() {
|
|||
cameras.clear();
|
||||
}
|
||||
|
||||
void Renderer::resize (int width, int height) {
|
||||
void Renderer::resize (int x, int y, int width, int height) {
|
||||
if (initialized) {
|
||||
bgfx::reset (width, height);
|
||||
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
this->view_offset_x = x;
|
||||
this->view_offset_y = y;
|
||||
this->view_width = width;
|
||||
this->view_height = height;
|
||||
|
||||
for (uint32_t i = 0; i < cameras.size(); i++) {
|
||||
cameras[i].width = static_cast<float>(width);
|
||||
|
@ -1280,7 +1294,7 @@ void Renderer::resize (int width, int height) {
|
|||
|
||||
void Renderer::paintGLSimple() {
|
||||
// Set view 0 default viewport.
|
||||
bgfx::setViewRect(0, 0, 0, width, height);
|
||||
bgfx::setViewRect(0, view_offset_x, view_offset_y, view_width, view_height);
|
||||
|
||||
// This dummy draw call is here to make sure that view 0 is cleared
|
||||
// if no other draw calls are submitted to view 0.
|
||||
|
@ -1319,7 +1333,7 @@ void Renderer::paintGL() {
|
|||
bgfx::dbgTextClear();
|
||||
|
||||
// debug font is 8 pixels wide
|
||||
int num_chars = width / 8;
|
||||
int num_chars = view_width / 8;
|
||||
bgfx::dbgTextPrintf(num_chars - 18, 0, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs);
|
||||
|
||||
// This dummy draw call is here to make sure that view 0 is cleared
|
||||
|
@ -1384,26 +1398,27 @@ void Renderer::paintGL() {
|
|||
float proj[16];
|
||||
bx::mtxIdentity(view);
|
||||
bx::mtxOrthoRh(proj, 0.f, 1.f, 1.f, 0.f, 0.f, 100.0f);
|
||||
bgfx::setViewRect(RenderState::Skybox, 0, 0, width, height);
|
||||
|
||||
bgfx::setViewRect(RenderState::Skybox, view_offset_x, view_offset_y, view_width, view_height);
|
||||
bgfx::setViewTransform(RenderState::Skybox, view, proj);
|
||||
|
||||
bgfx::setViewRect(RenderState::ShadowMap, 0, 0, lights[0].shadowMapSize, lights[0].shadowMapSize);
|
||||
bgfx::setViewFrameBuffer(RenderState::ShadowMap, lights[0].shadowMapFB);
|
||||
bgfx::setViewTransform(RenderState::ShadowMap, lights[0].mtxView, lights[0].mtxProj);
|
||||
|
||||
bgfx::setViewRect(RenderState::Scene, 0, 0, width, height);
|
||||
bgfx::setViewRect(RenderState::Scene, view_offset_x, view_offset_y, view_width, view_height);
|
||||
bgfx::setViewTransform(RenderState::Scene, cameras[activeCameraIndex].mtxView, cameras[activeCameraIndex].mtxProj);
|
||||
|
||||
bgfx::setViewRect(RenderState::SceneTextured, 0, 0, width, height);
|
||||
bgfx::setViewRect(RenderState::SceneTextured, view_offset_x, view_offset_y, view_width, view_height);
|
||||
bgfx::setViewTransform(RenderState::SceneTextured, cameras[activeCameraIndex].mtxView, cameras[activeCameraIndex].mtxProj);
|
||||
|
||||
bgfx::setViewRect(RenderState::Lines, 0, 0, width, height);
|
||||
bgfx::setViewRect(RenderState::Lines, view_offset_x, view_offset_y, view_width, view_height);
|
||||
bgfx::setViewTransform(RenderState::Lines, cameras[activeCameraIndex].mtxView, cameras[activeCameraIndex].mtxProj);
|
||||
|
||||
bgfx::setViewRect(RenderState::LinesOccluded, 0, 0, width, height);
|
||||
bgfx::setViewRect(RenderState::LinesOccluded, view_offset_x, view_offset_y, view_width, view_height);
|
||||
bgfx::setViewTransform(RenderState::LinesOccluded, cameras[activeCameraIndex].mtxView, cameras[activeCameraIndex].mtxProj);
|
||||
|
||||
bgfx::setViewRect(RenderState::Debug, 0, 0, width, height);
|
||||
bgfx::setViewRect(RenderState::Debug, view_offset_x, view_offset_y, view_width, view_height);
|
||||
bgfx::setViewTransform(RenderState::Debug, cameras[activeCameraIndex].mtxView, cameras[activeCameraIndex].mtxProj);
|
||||
|
||||
|
||||
|
@ -1641,7 +1656,7 @@ void Renderer::paintGL() {
|
|||
|
||||
float thickness = 0.143f;
|
||||
float miter = 0.0f;
|
||||
float aspect = static_cast<float>(width) / height;
|
||||
float aspect = static_cast<float>(view_width) / static_cast<float>(view_height);
|
||||
|
||||
Vector4f params (thickness, miter, aspect, 0.0f);
|
||||
|
||||
|
@ -1670,15 +1685,15 @@ void Renderer::paintGL() {
|
|||
// process submitted rendering primitives.
|
||||
bgfx::frame();
|
||||
|
||||
ImGui::SetNextWindowSize (ImVec2(400.f, 300.0f), ImGuiSetCond_Once);
|
||||
ImGui::SetNextWindowPos (ImVec2(10.f, 300.0f), ImGuiSetCond_Once);
|
||||
// ImGui::SetNextWindowSize (ImVec2(400.f, 300.0f), ImGuiSetCond_Once);
|
||||
// ImGui::SetNextWindowPos (ImVec2(10.f, 300.0f), ImGuiSetCond_Once);
|
||||
//
|
||||
if (ImGui::BeginDock("Render Settings")) {
|
||||
|
||||
ImGui::Begin("Render Settings");
|
||||
|
||||
if(ImGui::DragFloat3 ("Light0 Pos", lights[0].pos, 1.0f, -10.0f, 10.0f)) {
|
||||
if(ImGui::DragFloat3 ("Light0 Pos", lights[0].pos.data(), 1.0f, -10.0f, 10.0f)) {
|
||||
}
|
||||
|
||||
if(ImGui::DragFloat3 ("Light0 Dir", lights[0].dir, 1.0f, -10.0f, 10.0f)) {
|
||||
if(ImGui::DragFloat3 ("Light0 Dir", lights[0].dir.data(), 1.0f, -10.0f, 10.0f)) {
|
||||
}
|
||||
|
||||
float light_at[3];
|
||||
|
@ -1705,8 +1720,9 @@ void Renderer::paintGL() {
|
|||
0.10f
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
ImGui::EndDock();
|
||||
|
||||
// clear debug commands as they have to be issued every frame
|
||||
debugCommands.clear();
|
||||
|
|
|
@ -332,8 +332,10 @@ struct Renderer {
|
|||
bool drawDebug;
|
||||
bool drawFloor = true;
|
||||
bool drawSkybox = true;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t view_offset_x = 0;
|
||||
uint32_t view_offset_y = 0;
|
||||
uint32_t view_width = 1;
|
||||
uint32_t view_height = 1;
|
||||
|
||||
bgfx::UniformHandle sceneDefaultTextureSampler;
|
||||
bgfx::TextureHandle sceneDefaultTexture;
|
||||
|
@ -372,7 +374,7 @@ struct Renderer {
|
|||
void shutdown();
|
||||
void paintGL();
|
||||
void paintGLSimple();
|
||||
void resize (int width, int height);
|
||||
void resize (int x, int y, int width, int height);
|
||||
|
||||
// check whether shader files were modified and reload them. Returns
|
||||
// true on success, otherwise false
|
||||
|
|
|
@ -231,10 +231,9 @@ static void module_unload(struct module_state *state, void* write_serializer) {
|
|||
}
|
||||
|
||||
void ShowModulesWindow(struct module_state *state) {
|
||||
ImGui::SetNextWindowSize (ImVec2(400.f, 300.0f), ImGuiSetCond_Once);
|
||||
ImGui::SetNextWindowPos (ImVec2(400.f, 16.0f), ImGuiSetCond_Once);
|
||||
ImGui::Begin("Modules");
|
||||
|
||||
// ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4 (0.5f, 0.5f, 0.5f, 0.8f));
|
||||
if (ImGui::BeginDock("Modules")) {
|
||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4 (0.5f, 0.0f, 0.0f, 1.f));
|
||||
// ImGui::Columns(2);
|
||||
int selected = state->modules_window_selected_index;
|
||||
for (int i = 0; i < gModuleManager->mModules.size(); i++) {
|
||||
|
@ -282,8 +281,13 @@ void ShowModulesWindow(struct module_state *state) {
|
|||
selected_module->id = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::EndDock();
|
||||
|
||||
// ImGui::PopStyleColor ();
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
static bool module_step(struct module_state *state, float dt) {
|
||||
|
|
Loading…
Reference in New Issue