fix: stuff not actually rendering (pretty important)

This commit is contained in:
Djairo Hougee 2025-01-08 00:42:36 +01:00
parent d5a426e0c5
commit ff7638a245
6 changed files with 11 additions and 17 deletions

View File

@ -13,7 +13,7 @@ const int IMAGE_WIDTH = 800;
const int IMAGE_HEIGHT = 600;
const double epsilon = 1e-10f;
const double infty = 1e15f; // This vlalue is used to represent missing values in data
const double infty = 1e15f; // This value is used to represent missing values in data
// --------------------------- Raycasting Constants ---------------------------

View File

@ -70,6 +70,7 @@ int Window::init_quad(float* data) {
this->shader = std::make_unique<Shader>("./shaders/vertshader.glsl", "./shaders/fragshader.glsl");
this->shader->use();
glUniform1i(glGetUniformLocation(this->shader->ID, "currentFrameTex"), 0);
return 0;
}
@ -105,11 +106,6 @@ void Window::tick() {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDisable(GL_DEPTH_TEST);
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// render frame
glBindFramebuffer(GL_FRAMEBUFFER, this->current_quad->fb);
this->current_quad->render();
this->shader->use();
glBindVertexArray(this->current_quad->VAO);
@ -117,12 +113,9 @@ void Window::tick() {
glDrawArrays(GL_TRIANGLES, 0, 6); // draw current frame to texture
// check for events
// + swap buffers; TODO: check if necessary?
glfwSwapBuffers(this->window);
glfwPollEvents();
std::cout << "done ticking\n";
}
void Window::resize(unsigned int w, unsigned int h) {

View File

@ -12,7 +12,7 @@ class Window {
public:
unsigned int w;
unsigned int h;
float* data; //TODO: dynamic data loading
float* data;
Window(unsigned int w, unsigned int h);

View File

@ -67,7 +67,7 @@ Quad::Quad(unsigned int w, unsigned int h) {
void Quad::make_fbo(){
glGenFramebuffers(1, &fb);
glBindFramebuffer(GL_FRAMEBUFFER, fb);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, this->tex, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
@ -85,8 +85,8 @@ void Quad::cuda_init(float* data) {
void Quad::render() {
glBindTexture(GL_TEXTURE_2D, 0);
this->renderer->render();
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->PBO);
glBindTexture(GL_TEXTURE_2D, this->tex);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this->PBO);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, this->w, this->h, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
};

View File

@ -2,11 +2,7 @@
#include "linalg/linalg.h"
__host__ FrameBuffer::FrameBuffer(unsigned int w, unsigned int h) : w(w), h(h) {
this->buffer_size = w*h*sizeof(unsigned int);
cudaMalloc((void**)&this->buffer, this->buffer_size);
cudaMemset(this->buffer, 0, this->buffer_size);
}
__host__ FrameBuffer::FrameBuffer(unsigned int w, unsigned int h) : w(w), h(h) {}
__device__ void FrameBuffer::writePixel(int x, int y, float r, float g, float b) {
int i = y * this->w + x;

View File

@ -14,6 +14,11 @@
static float* d_volume = nullptr;
// TODO: general
// * 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))
// * very similarly - actual code for loading new data as the simulation progresses - right now its effectively a static image loader
//
void getTemperature(std::vector<float>& temperatureData, int idx = 0) {
std::string path = "data/trimmed";