diff --git a/libs/gfx/include/psemek/gfx/framebuffer.hpp b/libs/gfx/include/psemek/gfx/framebuffer.hpp index b461f22c..00174aff 100644 --- a/libs/gfx/include/psemek/gfx/framebuffer.hpp +++ b/libs/gfx/include/psemek/gfx/framebuffer.hpp @@ -24,7 +24,10 @@ namespace psemek::gfx void bind() const; + void color(texture_1d const & tex, int attachment = 0); void color(texture_2d const & tex, int attachment = 0); + void color(texture_3d const & tex, int layer, int attachment = 0); + void color(texture_2d_array const & tex, int layer, int attachment = 0); void color(renderbuffer const & rb, int attachment = 0); void depth(renderbuffer const & rb); diff --git a/libs/gfx/source/framebuffer.cpp b/libs/gfx/source/framebuffer.cpp index 307bc567..b0a4349a 100644 --- a/libs/gfx/source/framebuffer.cpp +++ b/libs/gfx/source/framebuffer.cpp @@ -57,12 +57,30 @@ namespace psemek::gfx gl::BindFramebuffer(gl::DRAW_FRAMEBUFFER, id_); } + void framebuffer::color(texture_1d const & tex, int attachment) + { + bind(); + gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER, gl::COLOR_ATTACHMENT0 + attachment, gl::TEXTURE_1D, tex.id(), 0); + } + void framebuffer::color(texture_2d const & tex, int attachment) { bind(); gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER, gl::COLOR_ATTACHMENT0 + attachment, gl::TEXTURE_2D, tex.id(), 0); } + void framebuffer::color(texture_3d const & tex, int layer, int attachment) + { + bind(); + gl::FramebufferTexture3D(gl::DRAW_FRAMEBUFFER, gl::COLOR_ATTACHMENT0 + attachment, gl::TEXTURE_3D, tex.id(), 0, layer); + } + + void framebuffer::color(texture_2d_array const & tex, int layer, int attachment) + { + bind(); + gl::FramebufferTextureLayer(gl::DRAW_FRAMEBUFFER, gl::COLOR_ATTACHMENT0 + attachment, tex.id(), 0, layer); + } + void framebuffer::color(renderbuffer const & rb, int attachment) { bind();