Skip to content

Commit

Permalink
Add darkened render texture as background to GeometryOutputUI
Browse files Browse the repository at this point in the history
  • Loading branch information
dfranx committed Feb 10, 2021
1 parent 9249413 commit 9af52b4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
+ add new file dialog
+ add PickPosition variable
+ add VertexShaderPosition variable
+ add darkened render texture to GeometryOutputUI
+ fix a bug where gizmo and bounding box would still render even when preview is paused

[v1.4.3]
Expand Down
18 changes: 15 additions & 3 deletions src/SHADERed/UI/Debug/GeometryOutputUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ namespace ed {
float wndHeight = ImGui::GetContentRegionAvail().y;
if (m_lastFBOHeight != wndHeight || m_lastFBOWidth != wndWidth) {
glBindTexture(GL_TEXTURE_2D, m_fboColor);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, wndWidth, wndHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, wndWidth, wndHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, m_fboDepth);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, wndWidth, wndHeight, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
Expand All @@ -357,12 +357,24 @@ namespace ed {
m_lastFBOHeight = wndHeight;
}

// draw the render texture contents but darkened
PixelInformation* px = m_data->Debugger.GetPixel();
if (px != nullptr && m_is3D == 0) {
ImVec2 curPos = ImGui::GetCursorPos();

if (px->RenderTexture != nullptr)
ImGui::Image((ImTextureID)px->RenderTexture->Texture, ImVec2(m_lastFBOWidth, m_lastFBOHeight), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0.6f, 0.6f, 0.6f, 1.0f));
else
ImGui::Image((ImTextureID)m_data->Renderer.GetTexture(), ImVec2(m_lastFBOWidth, m_lastFBOHeight), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0.6f, 0.6f, 0.6f, 1.0f));

ImGui::SetCursorPos(curPos);
}
// render the contents
m_render();

// draw the image to the window
// draw the contents on the window
ImVec2 uiPos = ImGui::GetCursorScreenPos();
ImGui::Image((ImTextureID)m_fboColor, ImVec2(m_lastFBOWidth, m_lastFBOHeight), ImVec2(0, 1), ImVec2(1, 0));
ImGui::Image((ImTextureID)m_fboColor, ImVec2(m_lastFBOWidth, m_lastFBOHeight), ImVec2(0, 1), ImVec2(1, 0), ImVec4(0.9f, 0.9f, 0.9f, 0.6f));

// camera controlls
if (ImGui::IsItemHovered()) {
Expand Down

0 comments on commit 9af52b4

Please sign in to comment.