From ad619de1dc7cf56617e90a4f7917f01438eef6d5 Mon Sep 17 00:00:00 2001 From: Martin Opat Date: Fri, 24 Jan 2025 14:45:38 +0100 Subject: [PATCH] Some ui stuff --- src/gui/MainWindow.cpp | 7 +++++-- src/gui/MainWindow.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 2f2f0e0..3bc24c8 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -57,9 +57,11 @@ void loadData(float* d_data, const int idx, const int timestep) { void Window::saveImage() { unsigned char* pixels = new unsigned char[this->w * this->h * 3]; glReadPixels(0, 0, this->w, this->h, GL_RGB, GL_UNSIGNED_BYTE, pixels); - const char* filename = "output.ppm"; // TODO: make this the current time - std::ofstream imageFile(filename, std::ios::out | std::ios::binary); + char str[512]; + sprintf(str, "output%d.ppm", this->i++); + + std::ofstream imageFile(str, std::ios::out | std::ios::binary); imageFile << "P6\n" << this->w << " " << this->h << "\n255\n"; for (int i = 0; i < this->w * this->h * 3; i++) { imageFile << pixels[i]; @@ -86,6 +88,7 @@ void framebuffer_size_callback(GLFWwindow* window, int w, int h) { int Window::init(float* data) { this->data = data; + this->i = 0; // init glfw glfwInit(); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index add8050..90d10b3 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -37,6 +37,8 @@ private: void tick(); int init_quad(float* data); + int i; + std::unique_ptr shader; }; #endif // MAINWINDOW_H