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

View File

@ -3,12 +3,15 @@
#include "RenderModule.h" #include "RenderModule.h"
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include "imgui/imgui.h"
#include "imgui_dock.h"
using namespace SimpleMath::GL; using namespace SimpleMath::GL;
struct Renderer; struct Renderer;
static const GLfloat g_vertex_buffer_data[] = { 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.9f, -0.9f, 0.0f,
0.0f, 0.9f, 1.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 glDrawArrays(GL_TRIANGLES, 0, 3); // starting from vertex 0; 3 vertices total
glDisableVertexAttribArray(0); glDisableVertexAttribArray(0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
} }
void Renderer::RenderGui() { 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); glBindFramebuffer(GL_FRAMEBUFFER, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
bool render_color = false;
Matrix44f model_view_projection = Matrix44f::Identity(); Matrix44f model_view_projection = Matrix44f::Identity();
if (render_color) { if (render_color) {