mirror of
https://github.com/SatDump/SatDump
synced 2026-08-13 17:47:30 -04:00
62 lines
1.5 KiB
C++
62 lines
1.5 KiB
C++
|
|
#include "render.h"
|
||
|
|
#include "logger.h"
|
||
|
|
|
||
|
|
std::shared_ptr<std::vector<std::shared_ptr<ProcessingModule>>> uiCallList;
|
||
|
|
std::shared_ptr<std::mutex> uiCallListMutex;
|
||
|
|
|
||
|
|
void render()
|
||
|
|
{
|
||
|
|
// Setup Dear ImGui context
|
||
|
|
IMGUI_CHECKVERSION();
|
||
|
|
ImGui::CreateContext();
|
||
|
|
ImGuiIO &io = ImGui::GetIO();
|
||
|
|
(void)io;
|
||
|
|
io.IniFilename = NULL;
|
||
|
|
|
||
|
|
// Setup Platform/Renderer bindings
|
||
|
|
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||
|
|
ImGui_ImplOpenGL3_Init("#version 150");
|
||
|
|
|
||
|
|
// Main loop
|
||
|
|
while (!glfwWindowShouldClose(window))
|
||
|
|
{
|
||
|
|
glfwPollEvents();
|
||
|
|
|
||
|
|
// Start the Dear ImGui frame
|
||
|
|
ImGui_ImplOpenGL3_NewFrame();
|
||
|
|
ImGui_ImplGlfw_NewFrame();
|
||
|
|
ImGui::NewFrame();
|
||
|
|
|
||
|
|
int wwidth, wheight;
|
||
|
|
glfwGetWindowSize(window, &wwidth, &wheight);
|
||
|
|
|
||
|
|
// User rendering
|
||
|
|
{
|
||
|
|
uiCallListMutex->lock();
|
||
|
|
for (std::shared_ptr<ProcessingModule> module : *uiCallList)
|
||
|
|
{
|
||
|
|
module->drawUI();
|
||
|
|
}
|
||
|
|
uiCallListMutex->unlock();
|
||
|
|
}
|
||
|
|
|
||
|
|
// Rendering
|
||
|
|
ImGui::Render();
|
||
|
|
int display_w, display_h;
|
||
|
|
glfwGetFramebufferSize(window, &display_w, &display_h);
|
||
|
|
glViewport(0, 0, display_w, display_h);
|
||
|
|
|
||
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
||
|
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||
|
|
|
||
|
|
glfwSwapBuffers(window);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Cleanup
|
||
|
|
ImGui_ImplOpenGL3_Shutdown();
|
||
|
|
ImGui_ImplGlfw_Shutdown();
|
||
|
|
ImGui::DestroyContext();
|
||
|
|
|
||
|
|
glfwDestroyWindow(window);
|
||
|
|
glfwTerminate();
|
||
|
|
}
|