satdump/src-ui/loading_screen.cpp

48 lines
1.6 KiB
C++
Raw Normal View History

2023-08-16 14:13:14 -04:00
#include "imgui/imgui.h"
#include "imgui/imgui_impl_glfw.h"
#include "imgui/imgui_impl_opengl3.h"
#include "loading_screen.h"
2023-08-17 21:05:15 -04:00
#include "loader/loader.h"
2023-08-16 14:13:14 -04:00
namespace satdump
{
LoadingScreenSink::LoadingScreenSink(GLFWwindow* window, float scale, GLFWimage* img) : window{window},
scale{scale}
2023-08-16 14:13:14 -04:00
{
glGenTextures(1, &image_texture);
glBindTexture(GL_TEXTURE_2D, image_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img->width, img->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, img->pixels);
2023-08-17 21:05:15 -04:00
push_frame("Initializing");
2023-08-16 14:13:14 -04:00
}
LoadingScreenSink::~LoadingScreenSink()
{
}
void LoadingScreenSink::receive(slog::LogMsg log)
{
if (log.lvl == slog::LOG_INFO)
2023-08-17 21:05:15 -04:00
push_frame(log.str);
2023-08-16 14:13:14 -04:00
}
2023-08-17 21:05:15 -04:00
void LoadingScreenSink::push_frame(std::string str)
2023-08-16 14:13:14 -04:00
{
int display_w, display_h;
glfwGetFramebufferSize(window, &display_w, &display_h);
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
draw_loader(display_w, display_h, scale, &image_texture, str);
2023-08-16 14:13:14 -04:00
glViewport(0, 0, display_w, display_h);
glClearColor(0.0666f, 0.0666f, 0.0666f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
glfwSwapBuffers(window);
}
2023-08-16 15:00:06 -04:00
}