diff --git a/CMakeLists.txt b/CMakeLists.txt index 9aac8ba..472b3d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.25) -set(BLT_GRAPHICS_VERSION 0.9.14) +set(BLT_GRAPHICS_VERSION 0.9.15) 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 e60f09a..19e1781 100644 --- a/include/blt/gfx/framebuffer.h +++ b/include/blt/gfx/framebuffer.h @@ -41,8 +41,9 @@ namespace blt::gfx private: GLuint rboID; GLuint storage_type; + blt::i32 width_, height_; public: - rbo_t(): rboID(0), storage_type(0) + rbo_t(): rboID(0), storage_type(0), width_(-1), height_(-1) {} void create(); @@ -51,7 +52,7 @@ namespace blt::gfx void setStorage(GLuint storage_type, blt::i32 width, blt::i32 height); - void updateStorage(blt::i32 width, blt::i32 height) const; + void updateStorage(blt::i32 width, blt::i32 height); static void unbind(); @@ -96,6 +97,9 @@ namespace blt::gfx // this function takes ownership of the render buffer void attachRenderBuffer(rbo_t rbo, attachment_t attachment); + void blitTexture(const fbo_t& draw, blt::i32 x1_offset = 0, blt::i32 y1_offset = 0, blt::i32 x2_offset = 0, blt::i32 y2_offset = 0); + void blitDepth(fbo_t draw, blt::i32 x1_offset = 0, blt::i32 y1_offset = 0, blt::i32 x2_offset = 0, blt::i32 y2_offset = 0); + static bool validate(); static void unbind(); diff --git a/include/blt/gfx/texture.h b/include/blt/gfx/texture.h index 6020451..29d2152 100644 --- a/include/blt/gfx/texture.h +++ b/include/blt/gfx/texture.h @@ -166,6 +166,16 @@ namespace blt::gfx virtual void updateSize(blt::i32, blt::i32) {} + [[nodiscard]] int getHeight() const + { + return m_height; + } + + [[nodiscard]] int getWidth() const + { + return m_width; + } + virtual ~texture_gl() { glDeleteTextures(1, &textureID); diff --git a/src/blt/gfx/framebuffer.cpp b/src/blt/gfx/framebuffer.cpp index 65caba8..079c177 100644 --- a/src/blt/gfx/framebuffer.cpp +++ b/src/blt/gfx/framebuffer.cpp @@ -38,8 +38,10 @@ namespace blt::gfx glDeleteRenderbuffers(1, &rboID); } - void rbo_t::updateStorage(blt::i32 width, blt::i32 height) const + void rbo_t::updateStorage(blt::i32 width, blt::i32 height) { + width_ = width; + height_ = height; glRenderbufferStorage(GL_RENDERBUFFER, storage_type, width, height); } @@ -114,6 +116,23 @@ namespace blt::gfx texture->updateSize(width, height); } + void fbo_t::blitTexture(const fbo_t& draw, blt::i32 x1_offset, blt::i32 y1_offset, blt::i32 x2_offset, blt::i32 y2_offset) + { + if (texture_buffers.empty()) + { + BLT_ERROR("Trying to blit texture with no texture attached!"); + return; + } + glBindFramebuffer(GL_READ_FRAMEBUFFER, fboID); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, draw.fboID); + //glBlitFramebuffer(x1_offset, y1_offset, texture_buffers[0].) + } + + void fbo_t::blitDepth(fbo_t draw, blt::i32 x1_offset, blt::i32 y1_offset, blt::i32 x2_offset, blt::i32 y2_offset) + { + + } + fbo_t fbo_t::make_render_texture(blt::i32 width, blt::i32 height) { fbo_t fbo;