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

@@ -5,8 +5,8 @@
#include <cmath>
// --------------------------- Basic Constants ---------------------------
const int INITIAL_WINDOW_WIDTH = 800;
const int INITIAL_WINDOW_HEIGHT = 600;
const int INITIAL_WINDOW_WIDTH = 1920;
const int INITIAL_WINDOW_HEIGHT = 1080;
const double epsilon = 1e-10f;
const double infty = 1e15f; // This value is used to represent missing values in data
@@ -34,7 +34,7 @@ const float MAX_SPEED = 14.0f;
// --------------------------- Raycasting Constants ---------------------------
const float minAllowedDensity = 0.001f;
const float stepSize = 0.02f;
const float stepSize = 0.002;
// --------------------------- Illumination Constants ---------------------------

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);

View File

@@ -1,25 +1,13 @@
#include <algorithm>
#include <cmath>
#include "consts.h"
#include <cuda_runtime.h>
#include <fstream>
#include "gui/MainWindow.h"
#include "hurricanedata/datareader.h"
#include "illumination/illumination.h"
#include "img/handler.h"
#include <iostream>
#include "linalg/linalg.h"
#include <vector>
#include <numeric>
static float* d_volume = nullptr;
// TODO: general
// * actual code for loading new data as the simulation progresses - right now its effectively a static image loader
// * save frames to file while running program -> then export to gif on close.
// * time controls - arbitrary skipping to specified point (would require some changes to gpubuffer) (could have)
void getTemperature(std::vector<float>& temperatureData, int idx = 0) {
std::string path = "data/trimmed";
// std::string path = "data";
@@ -57,7 +45,6 @@ int main() {
std::vector<float> data;
// getTemperature(data, 254); // 20121028
getSpeed(data, 254); // 20121028
// getSpeed(data, 294);
std::cout << "DATA size: " << data.size() << std::endl;
@@ -80,31 +67,6 @@ int main() {
}
}
// // Store the half-way up slice data into a file TODO: Remove this debug
// std::ofstream myfile;
// myfile.open("halfwayup.txt");
// for (int i = 0; i < VOLUME_WIDTH; i++) {
// for (int j = 0; j < VOLUME_HEIGHT; j++) {
// myfile << hostVolume[i + j*VOLUME_WIDTH + VOLUME_DEPTH/2*VOLUME_WIDTH*VOLUME_HEIGHT] << " ";
// }
// myfile << std::endl;
// }
// myfile.close();
// // Print min, max, avg., and median values TODO: Remove this debug
// float minVal = *std::min_element(hostVolume, hostVolume + VOLUME_WIDTH * VOLUME_HEIGHT * VOLUME_DEPTH, [](float a, float b) {
// if (a <= epsilon) return false;
// if (b <= epsilon) return true;
// return a < b;
// });
// float maxVal = *std::max_element(hostVolume, hostVolume + VOLUME_WIDTH * VOLUME_HEIGHT * VOLUME_DEPTH);
// std::cout << "minVal: " << minVal << " maxVal: " << maxVal << std::endl;
// // print min, max, avg., and median values <--- the code actually does not work when this snippet is enabled so probably TODO: Delete this later
// std::sort(hostVolume, hostVolume + VOLUME_WIDTH * VOLUME_HEIGHT * VOLUME_DEPTH);
// float sum = std::accumulate(hostVolume, hostVolume + VOLUME_WIDTH * VOLUME_HEIGHT * VOLUME_DEPTH, 0.0f);
// float avg = sum / (VOLUME_WIDTH * VOLUME_HEIGHT * VOLUME_DEPTH);
// std::cout << "min: " << hostVolume[0] << " max: " << hostVolume[VOLUME_WIDTH * VOLUME_HEIGHT * VOLUME_DEPTH - 1] << " avg: " << avg << " median: " << hostVolume[VOLUME_WIDTH * VOLUME_HEIGHT * VOLUME_DEPTH / 2] << std::endl;
// Allocate + copy data to GPU
size_t volumeSize = sizeof(float) * VOLUME_WIDTH * VOLUME_HEIGHT * VOLUME_DEPTH;
cudaMalloc((void**)&d_volume, volumeSize);