removed unnecessary imgui install

This commit is contained in:
2025-01-21 00:49:47 +01:00
parent 1361cf9417
commit d25b7c3cf9
238 changed files with 26 additions and 110681 deletions

View File

@@ -10,6 +10,21 @@
#include "cuda_error.h"
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);
imageFile << "P6\n" << this->w << " " << this->h << "\n255\n";
for (int i = 0; i < this->w * this->h * 3; i++) {
imageFile << pixels[i];
}
imageFile.close();
delete[] pixels;
}
Window::Window(unsigned int w, unsigned int h) {
this->w = w;
this->h = h;
@@ -111,6 +126,10 @@ void Window::tick() {
// TODO: Load new date file here
this->widget->dateChanged = false;
}
if (this->widget->saveImage) {
saveImage();
this->widget->saveImage = false;
}
// tick render
glBindFramebuffer(GL_FRAMEBUFFER, 0);

View File

@@ -22,6 +22,7 @@ public:
int init(float* data);
void free(float* data);
void resize(unsigned int w, unsigned int h);
void saveImage();
private:
GLFWwindow* window;

View File

@@ -58,6 +58,7 @@ Widget::Widget(GLFWwindow* window) :
dateChanged(false),
paused(true),
renderOnce(false),
saveImage(false),
bgColor(Color3::init(0.1f, 0.1f, 0.1f)),
date(301),
samplesPerPixel(1),
@@ -171,6 +172,7 @@ void Widget::tick(double fps) {
ImGui::SameLine();
ImGui::Text(this->dateString);
ImGui::DragInt("Samples per pixel", &this->samplesPerPixel, 1, 1, 16, "%d", ImGuiSliderFlags_AlwaysClamp);
if (ImGui::Button("Save render")) this->saveImage = true;
ImGui::End();

View File

@@ -12,6 +12,7 @@ class Widget {
public:
bool paused;
bool dateChanged;
bool saveImage;
int date;
void tick(double fps);