Hejhej! I'm trying to work my way through this lecture
https://www.youtube.com/watch?v=ifD31g_ZdEo&list=PLplnkTzzqsZS3R5DjmCQsqupu43oS9CFN&index=12
combined with this tutorial:
https://learnopengl.com/Advanced-OpenGL/Framebuffers
I was stuck a couple of times, but I really have no Idea now what to do.
first picture: The teapot before I used a framebuffer
2nd: the teapot drawn on the quad
3rd: potential problem? The size seems to be reassigned
4th: potential problem: The renderbuffer only uses a fragment of the sace it should.
I'm assuming, that I have to create a framebuffer, bind it. Attach a texture to it, then draw to that framebuffer via drawarrays. Then I read from that texture in the next render call in the fragment shader and draw that to the quad (using 0-1 st coordinates).
I think I am doing so, but the size gets reassigned midprocess to the texture size of the bricks.
Is there anything else I can post here that would help?
#framebuffer cropped
1 messages · Page 1 of 1 (latest)
Check that you call glViewport() when changing where you render
It sounds like you set it correctly when you render to texture, but forget to update viewport state when switching rendering to default (or some other) framebuffer.
thanks a lot! I just found it by chance myself, but that was the answer. That was driving me crazy 😄
It looks super low res, because it would be this 512 texture scaled up to screen size right?
I'm still wondering a bit that it is dependant on the texture of the teapot. I would've thought that it should be dependant on the size of the framebuffer texture, which should've been screensize and not 512. So "it works" but I'm still not sure about a few things...
unsigned int framebuffer;
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glGenTextures(1, &textureColorbuffer);
glBindTexture(GL_TEXTURE_2D, textureColorbuffer);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, screenWidth, screenHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
unsigned int rbo;
glGenRenderbuffers(1, &rbo);
glBindRenderbuffer(GL_RENDERBUFFER, rbo);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, screenWidth, screenHeight); // use a single renderbuffer object for both a depth AND stencil buffer.
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo); // now actually attach it
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureColorbuffer, 0);
GLenum drawBuffers[1] = {GL_COLOR_ATTACHMENT0};
glDrawBuffers(1, drawBuffers);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
std::cout << "ERROR::FRAMEBUFFER:: Framebuffer is not complete!" << std::endl;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
So why does it use the texture from here?
glGenBuffers(1, &difTex);
glActiveTexture(GL_TEXTURE0);
glBindBuffer(GL_TEXTURE_2D, difTex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imgWidth, imgHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, &brickTexture[0]);
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
Anyway: Huge thanks for clearing some things and answering 🙂
I mainly don't get where the 4th and 5th step happen:
Looks like glBindBuffer() should be glBindTexture() instead