diff --git a/CMakeLists.txt b/CMakeLists.txt index c6ad609..0b998ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.25) -set(BLT_GRAPHICS_VERSION 0.9.12) +set(BLT_GRAPHICS_VERSION 0.9.13) set(BLT_GRAPHICS_TEST_VERSION 0.0.1) project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION}) diff --git a/include/blt/gfx/framebuffer.h b/include/blt/gfx/framebuffer.h index adca019..3c75463 100644 --- a/include/blt/gfx/framebuffer.h +++ b/include/blt/gfx/framebuffer.h @@ -19,9 +19,32 @@ #ifndef BLT_WITH_GRAPHICS_FRAMEBUFFER_H #define BLT_WITH_GRAPHICS_FRAMEBUFFER_H +#include "blt/gfx/gl_includes.h" + namespace blt::gfx { - + class fbo_t + { + public: + enum class fbo_draw_t : GLuint + { + DRAW = GL_DRAW_FRAMEBUFFER, + READ = GL_READ_FRAMEBUFFER, + BOTH = GL_FRAMEBUFFER + }; + private: + GLuint fboID; + public: + void create(); + + void bind(fbo_draw_t type = fbo_draw_t::BOTH) const; + + bool validate(); + + static void unbind(); + + void destroy(); + }; } #endif //BLT_WITH_GRAPHICS_FRAMEBUFFER_H diff --git a/src/blt/gfx/framebuffer.cpp b/src/blt/gfx/framebuffer.cpp index 5e9a8f1..a82e647 100644 --- a/src/blt/gfx/framebuffer.cpp +++ b/src/blt/gfx/framebuffer.cpp @@ -18,5 +18,29 @@ namespace blt::gfx { - + + void fbo_t::create() + { + glGenFramebuffers(1, &fboID); + } + + void fbo_t::bind(fbo_draw_t type) const + { + glBindFramebuffer(static_cast(type), fboID); + } + + void fbo_t::unbind() + { + glBindFramebuffer(GL_FRAMEBUFFER, 0); + } + + void fbo_t::destroy() + { + + } + + bool fbo_t::validate() + { + return glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE; + } } \ No newline at end of file