Add fbo constructor that will bind existing textures/rbos in a single call

This commit is contained in:
rexy712
2020-10-02 06:56:39 -07:00
parent 9fea54d971
commit a4e684beb5

View File

@@ -35,7 +35,9 @@ namespace gfx{
public:
fbo();
fbo(util::no_initialize_t);
template<typename... Args>
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<typename... Args>
void i_attach(const rbo& r, GLenum point, Args&&... args);
template<typename... Args>
void i_attach(const texture& r, GLenum point, Args&&... args);
};
template<typename... Args>
fbo::fbo(Args&&... args):
fbo()
{
i_attach(std::forward<Args>(args)...);
}
template<typename... Args>
void fbo::i_attach(const rbo& r, GLenum point, Args&&... args){
attach(r, point);
if constexpr(sizeof...(args) > 0){
i_attach(std::forward<Args>(args)...);
}
}
template<typename... Args>
void fbo::i_attach(const texture& t, GLenum point, Args&&... args){
attach(t, point);
if constexpr(sizeof...(args) > 0){
i_attach(std::forward<Args>(args)...);
}
}
}
#endif