38 lines
1.0 KiB
C++
38 lines
1.0 KiB
C++
//
|
|
// Created by spenc on 5/21/2025.
|
|
//
|
|
|
|
#include "Viewport.h"
|
|
#include <imgui.h>
|
|
|
|
namespace OX
|
|
{
|
|
int Viewport::s_nextID = 0;
|
|
|
|
void Viewport::Draw(Core &core) const
|
|
{
|
|
// Construct title
|
|
std::string title = m_name + " (" + std::to_string(m_id) + ")";
|
|
|
|
// Remove window padding
|
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
|
|
|
|
// Begin full viewport window
|
|
ImGui::Begin(title.c_str(), nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
|
|
|
|
// Get size of available region
|
|
ImVec2 viewportSize = ImGui::GetContentRegionAvail();
|
|
|
|
// === Fullscreen image ===
|
|
GLuint textureID = core.GetRenderer().GetRenderTarget(); // You must define this method
|
|
if (textureID != 0) {
|
|
ImGui::Image(textureID, viewportSize, ImVec2(0, 1), ImVec2(1, 0));
|
|
} else {
|
|
ImGui::Text("No Render Target.");
|
|
}
|
|
|
|
ImGui::End();
|
|
ImGui::PopStyleVar(); // Restore padding
|
|
}
|
|
};
|