From a4e684beb56d8883b0cb5ec999962352fce10602 Mon Sep 17 00:00:00 2001 From: rexy712 Date: Fri, 2 Oct 2020 06:56:39 -0700 Subject: [PATCH] Add fbo constructor that will bind existing textures/rbos in a single call --- include/graphics/fbo.hpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/include/graphics/fbo.hpp b/include/graphics/fbo.hpp index fec2ca3..7f83579 100644 --- a/include/graphics/fbo.hpp +++ b/include/graphics/fbo.hpp @@ -35,7 +35,9 @@ namespace gfx{ public: fbo(); - fbo(util::no_initialize_t); + template + explicit fbo(Args&&... args); + explicit fbo(util::no_initialize_t); fbo(const fbo&) = delete; fbo(fbo&& f); ~fbo(); @@ -58,8 +60,35 @@ namespace gfx{ bool bind()const; bool bind(gl_frame_buffer_manager& b)const; + private: + template + void i_attach(const rbo& r, GLenum point, Args&&... args); + template + void i_attach(const texture& r, GLenum point, Args&&... args); + }; + template + fbo::fbo(Args&&... args): + fbo() + { + i_attach(std::forward(args)...); + } + template + void fbo::i_attach(const rbo& r, GLenum point, Args&&... args){ + attach(r, point); + if constexpr(sizeof...(args) > 0){ + i_attach(std::forward(args)...); + } + } + template + void fbo::i_attach(const texture& t, GLenum point, Args&&... args){ + attach(t, point); + if constexpr(sizeof...(args) > 0){ + i_attach(std::forward(args)...); + } + } + } #endif