diff --git a/libs/gfx/include/psemek/gfx/framebuffer.hpp b/libs/gfx/include/psemek/gfx/framebuffer.hpp index dbe8e357..3ce0a458 100644 --- a/libs/gfx/include/psemek/gfx/framebuffer.hpp +++ b/libs/gfx/include/psemek/gfx/framebuffer.hpp @@ -32,7 +32,10 @@ namespace psemek::gfx 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(texture_2d const & tex); void depth(renderbuffer const & rb); + void depth_stencil(texture_2d const & tex); + void depth_stencil(renderbuffer const & rb); GLenum status() const; bool complete() const; diff --git a/libs/gfx/source/framebuffer.cpp b/libs/gfx/source/framebuffer.cpp index 63c8569b..897c7663 100644 --- a/libs/gfx/source/framebuffer.cpp +++ b/libs/gfx/source/framebuffer.cpp @@ -90,7 +90,25 @@ namespace psemek::gfx gl::FramebufferRenderbuffer(gl::DRAW_FRAMEBUFFER, gl::COLOR_ATTACHMENT0 + attachment, gl::RENDERBUFFER, rb.id()); } + void framebuffer::depth(texture_2d const & tex) + { + bind(); + gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER, gl::DEPTH_ATTACHMENT, gl::TEXTURE_2D, tex.id(), 0); + } + void framebuffer::depth(renderbuffer const & rb) + { + bind(); + gl::FramebufferRenderbuffer(gl::DRAW_FRAMEBUFFER, gl::DEPTH_ATTACHMENT, gl::RENDERBUFFER, rb.id()); + } + + void framebuffer::depth_stencil(texture_2d const & tex) + { + bind(); + gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER, gl::DEPTH_STENCIL_ATTACHMENT, gl::TEXTURE_2D, tex.id(), 0); + } + + void framebuffer::depth_stencil(renderbuffer const & rb) { bind(); gl::FramebufferRenderbuffer(gl::DRAW_FRAMEBUFFER, gl::DEPTH_STENCIL_ATTACHMENT, gl::RENDERBUFFER, rb.id());