2D_Game_Engine
Loading...
Searching...
No Matches
framebuffer.cpp
Go to the documentation of this file.
1#include <pch.hpp>
2#include <framebuffer.hpp>
3#include <global.hpp>
4#include <window.hpp>
5
7 glGenFramebuffers(1,&m_FramebufferID);
8 Bind();
9
10 glGenTextures(1,&m_ColorbufferID);
11 glBindTexture(GL_TEXTURE_2D,m_ColorbufferID);
12 glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA16F,Window::Width,Window::Height,0,GL_RGBA,GL_FLOAT,nullptr);
13 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
14 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
15
16 glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,m_ColorbufferID,0);
17
18 GLenum framebuffer_status=glCheckFramebufferStatus(GL_FRAMEBUFFER);
19 if(framebuffer_status!=GL_FRAMEBUFFER_COMPLETE){
20 std::cerr<<"glCheckFramebufferStatus returned: "<<framebuffer_status<<'\n';
21 }
22}
23
25 glDeleteTextures(1,&m_ColorbufferID);
26 glDeleteFramebuffers(1,&m_FramebufferID);
27}
28
29void Framebuffer::Bind() const{
30 glBindFramebuffer(GL_FRAMEBUFFER,m_FramebufferID);
31}
32
34 glBindFramebuffer(GL_FRAMEBUFFER,0);
35}
void Bind() const
void Unbind() const
float Height
Definition window.hpp:43
float Width
Definition window.cpp:227