Support multisample textures in framebuffers

This commit is contained in:
Nikita Lisitsa 2022-11-30 17:34:21 +03:00
parent a758535700
commit d1884e4e83
2 changed files with 26 additions and 5 deletions

View file

@ -34,17 +34,20 @@ namespace psemek::gfx
void color(texture_1d const & tex, int attachment = 0);
void color(texture_2d const & tex, int attachment = 0);
void color(texture_2d_multisample 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(texture_cubemap const & tex, int attachment = 0);
void color(texture_cubemap const & tex, int face, int attachment = 0);
void color(renderbuffer const & rb, int attachment = 0);
void depth(texture_2d const & tex);
void depth(texture_2d_multisample const & tex);
void depth(texture_2d_array const & tex, int layer);
void depth(texture_cubemap const & tex);
void depth(texture_cubemap const & tex, int face);
void depth(renderbuffer const & rb);
void depth_stencil(texture_2d const & tex);
void depth_stencil(texture_2d_multisample const & tex);
void depth_stencil(texture_2d_array const & tex, int layer);
void depth_stencil(texture_cubemap const & tex);
void depth_stencil(texture_cubemap const & tex, int face);

View file

@ -70,19 +70,25 @@ namespace psemek::gfx
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);
gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER, gl::COLOR_ATTACHMENT0 + attachment, tex.target, 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);
gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER, gl::COLOR_ATTACHMENT0 + attachment, tex.target, tex.id(), 0);
}
void framebuffer::color(texture_2d_multisample const & tex, int attachment)
{
bind();
gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER, gl::COLOR_ATTACHMENT0 + attachment, tex.target, 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);
gl::FramebufferTexture3D(gl::DRAW_FRAMEBUFFER, gl::COLOR_ATTACHMENT0 + attachment, tex.target, tex.id(), 0, layer);
}
void framebuffer::color(texture_2d_array const & tex, int layer, int attachment)
@ -112,7 +118,13 @@ namespace psemek::gfx
void framebuffer::depth(texture_2d const & tex)
{
bind();
gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER, gl::DEPTH_ATTACHMENT, gl::TEXTURE_2D, tex.id(), 0);
gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER, gl::DEPTH_ATTACHMENT, tex.target, tex.id(), 0);
}
void framebuffer::depth(texture_2d_multisample const & tex)
{
bind();
gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER, gl::DEPTH_ATTACHMENT, tex.target, tex.id(), 0);
}
void framebuffer::depth(texture_2d_array const & tex, int layer)
@ -142,7 +154,13 @@ namespace psemek::gfx
void framebuffer::depth_stencil(texture_2d const & tex)
{
bind();
gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER, gl::DEPTH_STENCIL_ATTACHMENT, gl::TEXTURE_2D, tex.id(), 0);
gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER, gl::DEPTH_STENCIL_ATTACHMENT, tex.target, tex.id(), 0);
}
void framebuffer::depth_stencil(texture_2d_multisample const & tex)
{
bind();
gl::FramebufferTexture2D(gl::DRAW_FRAMEBUFFER, gl::DEPTH_STENCIL_ATTACHMENT, tex.target, tex.id(), 0);
}
void framebuffer::depth_stencil(texture_2d_array const & tex, int layer)