Drawing of the Color texture already works... yay ... depth will be trickier

simple_math_single_header
Martin Felis 2018-02-16 22:43:40 +01:00
parent 540e0d6db8
commit ea2b5d1e13
2 changed files with 80 additions and 39 deletions

View File

@ -149,6 +149,8 @@ int main(void)
double frame_delta_time = 0.0;
uint64_t frame_counter = 0;
bool draw_imgui_demo = false;
while(!glfwWindowShouldClose(gWindow)) {
frame_counter++;
@ -157,7 +159,7 @@ int main(void)
glfwGetWindowSize(gWindow, &width, &height);
glfwPollEvents();
// ImGui_ImplGlfwGL3_NewFrame();
ImGui_ImplGlfwGL3_NewFrame();
// imguiBeginFrame (gGuiInputState->mouseX,
// gGuiInputState->mouseY,
@ -188,45 +190,60 @@ int main(void)
assert (gTimer->mDeltaTime >= 0.0f);
int width, height;
glfwGetWindowSize(gWindow, &width, &height);
//#ifdef USE_DOCKS
// ImGui::SetNextWindowPos(ImVec2(0.0f, 20.0f));
// ImGui::SetNextWindowSize(ImVec2(width, height));
// if (ImGui::Begin("DockArea", NULL,
// ImGuiWindowFlags_NoTitleBar
// | ImGuiWindowFlags_NoResize
// | ImGuiWindowFlags_NoMove
// | ImGuiWindowFlags_NoBringToFrontOnFocus
// )) {
// ImGui::BeginDockspace();
//
// if (ImGui::BeginDock("dock1")) {
// ImGui::Text("HEllo 1");
// }
// ImGui::EndDock();
//
// if (ImGui::BeginDock("dock2")) {
// ImGui::Text("HEllo2");
// }
// ImGui::EndDock();
//
// if (ImGui::BeginDock("dock3")) {
// ImGui::Text("HEllo3");
// }
// ImGui::EndDock();
//
//
//#endif
ImGui::BeginMainMenuBar();
if (ImGui::BeginMenu("Dialogs"))
{
ImGui::Checkbox("ImGui Demo", &draw_imgui_demo);
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
if (draw_imgui_demo)
ImGui::ShowDemoWindow();
#ifdef USE_DOCKS
ImGui::SetNextWindowPos(ImVec2(0.0f, 10.0f));
ImGui::SetNextWindowSize(ImVec2(width, height));
if (ImGui::Begin("DockArea", NULL,
ImGuiWindowFlags_NoTitleBar
| ImGuiWindowFlags_NoResize
| ImGuiWindowFlags_NoMove
| ImGuiWindowFlags_NoBringToFrontOnFocus
)) {
ImGui::BeginDockspace();
if (ImGui::BeginDock("dock1")) {
ImGui::Text("HEllo 1");
}
ImGui::EndDock();
if (ImGui::BeginDock("dock2")) {
ImGui::Text("HEllo2");
}
ImGui::EndDock();
if (ImGui::BeginDock("dock3")) {
ImGui::Text("HEllo3");
}
ImGui::EndDock();
#endif
module_manager.Update(gTimer->mDeltaTime);
// #ifdef USE_DOCKS
// ImGui::EndDockspace();
// }
#ifdef USE_DOCKS
ImGui::EndDockspace();
}
ImGui::End();
#endif
//
// ImGui::End();
// #endif
//
// ImGui::Render();
ImGui::Render();
usleep(16000);

View File

@ -3,12 +3,15 @@
#include "RenderModule.h"
#include <GLFW/glfw3.h>
#include "imgui/imgui.h"
#include "imgui_dock.h"
using namespace SimpleMath::GL;
struct Renderer;
static const GLfloat g_vertex_buffer_data[] = {
-0.7f, -0.9f, 0.0f,
-0.9f, -0.9f, 0.0f,
0.9f, -0.9f, 0.0f,
0.0f, 0.9f, 1.0f
};
@ -228,16 +231,37 @@ void Renderer::RenderGl() {
glDrawArrays(GL_TRIANGLES, 0, 3); // starting from vertex 0; 3 vertices total
glDisableVertexAttribArray(0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void Renderer::RenderGui() {
bool render_color = true;
GLuint texture;
if (render_color) {
texture = mRenderTarget.mColorTexture;
} else {
texture = mRenderTarget.mDepthTexture;
}
if (ImGui::BeginDock("Scene")) {
ImGui::Text("Scene");
const ImVec2 content_avail = ImGui::GetContentRegionAvail();
ImGui::Image((void*) texture,
content_avail,
ImVec2(0.0f, 1.0f),
ImVec2(1.0f, 0.0f)
);
}
ImGui::EndDock();
return;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0);
bool render_color = false;
Matrix44f model_view_projection = Matrix44f::Identity();
if (render_color) {