fix: segfault on resize

This commit is contained in:
Djairo Hougee 2025-01-11 18:37:18 +01:00
parent 9c7dd45858
commit db1b1a60ca
2 changed files with 3 additions and 8 deletions

View File

@ -24,11 +24,10 @@ Window::Window(unsigned int w, unsigned int h) {
} }
void framebuffer_size_callback(GLFWwindow* window, int w, int h) { void framebuffer_size_callback(GLFWwindow* window, int w, int h) {
// This function is called by glfw when the window is reized. // This function is called by glfw when the window is resized.
glViewport(0 , 0, w, h); glViewport(0 , 0, w, h);
Window* newWin = reinterpret_cast<Window*>(glfwGetWindowUserPointer(window)); Window* newWin = reinterpret_cast<Window*>(glfwGetWindowUserPointer(window));
newWin->resize(w, h); newWin->resize(w, h);
} }
int Window::init(float* data) { int Window::init(float* data) {
@ -48,6 +47,7 @@ int Window::init(float* data) {
} }
glfwMakeContextCurrent(this->window); glfwMakeContextCurrent(this->window);
glfwSetWindowUserPointer(this->window, reinterpret_cast<void*>(this));
// init glad(opengl) // init glad(opengl)
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {

View File

@ -15,16 +15,11 @@
static float* d_volume = nullptr; static float* d_volume = nullptr;
// FIXME: segfaults on window resize - the problem is _not_ in the raycasting function
// TODO: general // TODO: general
// * very similarly - actual code for loading new data as the simulation progresses - right now its effectively a static image loader * pause button once that dataloading is implemented // * 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. // * 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) // * time controls - arbitrary skipping to specified point (would require some changes to gpubuffer) (could have)
// * transfer function -> move the code in raycastkernel to its own class and add silhouette detection here as well.
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";
// std::string path = "data"; // std::string path = "data";