improved cleanup

This commit is contained in:
Djairo Hougee 2025-01-08 00:58:45 +01:00
parent a41b468a61
commit b3db9a7045
1 changed files with 5 additions and 3 deletions

View File

@ -18,7 +18,6 @@ static float* d_volume = nullptr;
// * pass camera_info to the raycasting function - updated according to glfw. // * pass camera_info to the raycasting function - updated according to glfw.
// * on that note, code for handling input (mouse movement certainly, possibly free input / 4 pre-coded views, q/esc to quit, space for pause (would be were the 'simple' render idea would come in)) // * on that note, code for handling input (mouse movement certainly, possibly free input / 4 pre-coded views, q/esc to quit, space for pause (would be were the 'simple' render idea would come in))
// * very similarly - actual code for loading new data as the simulation progresses - right now its effectively a static image loader // * very similarly - actual code for loading new data as the simulation progresses - right now its effectively a static image loader
// * better cleanup; im sure im missing a bunch of frees that really should be there.
void getTemperature(std::vector<float>& temperatureData, int idx = 0) { void getTemperature(std::vector<float>& temperatureData, int idx = 0) {
std::string path = "data/trimmed"; std::string path = "data/trimmed";
@ -101,7 +100,9 @@ int main() {
// cudaDeviceSynchronize(); // cudaDeviceSynchronize();
Window window(IMAGE_WIDTH, IMAGE_HEIGHT); Window window(IMAGE_WIDTH, IMAGE_HEIGHT);
return window.init(d_volume); int out = window.init(d_volume);
cudaFree(d_volume);
// // Copy framebuffer back to CPU // // Copy framebuffer back to CPU
// unsigned char* hostFramebuffer = new unsigned char[IMAGE_WIDTH * IMAGE_HEIGHT * 3]; // unsigned char* hostFramebuffer = new unsigned char[IMAGE_WIDTH * IMAGE_HEIGHT * 3];
@ -111,11 +112,12 @@ int main() {
// saveImage("output.ppm", hostFramebuffer, IMAGE_WIDTH, IMAGE_HEIGHT); // saveImage("output.ppm", hostFramebuffer, IMAGE_WIDTH, IMAGE_HEIGHT);
// //
// // Cleanup //TODO: cleanup properly // // Cleanup //TODO: cleanup properly
// delete[] hostVolume; delete[] hostVolume;
// delete[] hostFramebuffer; // delete[] hostFramebuffer;
// cudaFree(d_volume); // cudaFree(d_volume);
// cudaFree(d_framebuffer); // cudaFree(d_framebuffer);
// //
// std::cout << "Phong-DVR rendering done. Image saved to output.ppm" << std::endl; // std::cout << "Phong-DVR rendering done. Image saved to output.ppm" << std::endl;
// return 0; // return 0;
return out;
} }