fix: stuff not actually rendering (pretty important)

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

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