diff --git a/src/Magnum/Framebuffer.cpp b/src/Magnum/Framebuffer.cpp index d39e1f6a1..d05999cc8 100644 --- a/src/Magnum/Framebuffer.cpp +++ b/src/Magnum/Framebuffer.cpp @@ -236,7 +236,7 @@ Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, Multi #endif Framebuffer& Framebuffer::attachCubeMapTexture(const BufferAttachment attachment, CubeMapTexture& texture, CubeMapTexture::Coordinate coordinate, const Int level) { - (this->*Context::current()->state().framebuffer->texture2DImplementation)(attachment, GLenum(coordinate), texture.id(), level); + (this->*Context::current()->state().framebuffer->textureCubeMapImplementation)(attachment, GLenum(coordinate), texture.id(), level); return *this; } @@ -319,6 +319,10 @@ void Framebuffer::texture2DImplementationDSAEXT(BufferAttachment attachment, GLe _flags |= ObjectFlag::Created; glNamedFramebufferTexture2DEXT(_id, GLenum(attachment), textureTarget, textureId, mipLevel); } + +void Framebuffer::textureCubeMapImplementationDSA(const BufferAttachment attachment, const GLenum textureTarget, const GLuint textureId, const GLint mipLevel) { + glNamedFramebufferTextureLayer(_id, GLenum(attachment), textureId, mipLevel, textureTarget - GL_TEXTURE_CUBE_MAP_POSITIVE_X); +} #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) diff --git a/src/Magnum/Framebuffer.h b/src/Magnum/Framebuffer.h index 3a4e6d6ae..1ee212ee9 100644 --- a/src/Magnum/Framebuffer.h +++ b/src/Magnum/Framebuffer.h @@ -654,7 +654,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje * available, the framebuffer is bound before the operation (if not * already). * @see @ref detach(), @ref attachTexture(), - * @fn_gl2{NamedFramebufferTexture,FramebufferTexture}, + * @fn_gl2{NamedFramebufferTextureLayer,FramebufferTextureLayer}, * @fn_gl_extension{NamedFramebufferTexture2D,EXT,direct_state_access}, * eventually @fn_gl{BindFramebuffer} and @fn_gl2{FramebufferTexture2D,FramebufferTexture} */ @@ -776,6 +776,7 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje #ifndef MAGNUM_TARGET_GLES void MAGNUM_LOCAL texture2DImplementationDSA(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint level); void MAGNUM_LOCAL texture2DImplementationDSAEXT(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint level); + void MAGNUM_LOCAL textureCubeMapImplementationDSA(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint level); #endif #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) diff --git a/src/Magnum/Implementation/FramebufferState.cpp b/src/Magnum/Implementation/FramebufferState.cpp index bfbb64d0d..3104c91f8 100644 --- a/src/Magnum/Implementation/FramebufferState.cpp +++ b/src/Magnum/Implementation/FramebufferState.cpp @@ -74,7 +74,10 @@ FramebufferState::FramebufferState(Context& context, std::vector& e renderbufferImplementation = &Framebuffer::renderbufferImplementationDSA; texture1DImplementation = &Framebuffer::texture1DImplementationDSA; + /* DSA doesn't have texture target parameter so we need to use different + function to specify cube map face */ texture2DImplementation = &Framebuffer::texture2DImplementationDSA; + textureCubeMapImplementation = &Framebuffer::textureCubeMapImplementationDSA; textureLayerImplementation = &Framebuffer::textureLayerImplementationDSA; renderbufferStorageImplementation = &Renderbuffer::storageImplementationDSA; @@ -89,7 +92,9 @@ FramebufferState::FramebufferState(Context& context, std::vector& e renderbufferImplementation = &Framebuffer::renderbufferImplementationDSAEXT; texture1DImplementation = &Framebuffer::texture1DImplementationDSAEXT; + /* The EXT_DSA implementation is the same for both 2D and cube map textures */ texture2DImplementation = &Framebuffer::texture2DImplementationDSAEXT; + textureCubeMapImplementation = &Framebuffer::texture2DImplementationDSAEXT; textureLayerImplementation = &Framebuffer::textureLayerImplementationDSAEXT; renderbufferStorageImplementation = &Renderbuffer::storageImplementationDSAEXT; @@ -111,7 +116,9 @@ FramebufferState::FramebufferState(Context& context, std::vector& e #ifndef MAGNUM_TARGET_GLES texture1DImplementation = &Framebuffer::texture1DImplementationDefault; #endif + /* The default implementation is the same for both 2D and cube map textures */ texture2DImplementation = &Framebuffer::texture2DImplementationDefault; + textureCubeMapImplementation = &Framebuffer::texture2DImplementationDefault; #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) textureLayerImplementation = &Framebuffer::textureLayerImplementationDefault; #endif diff --git a/src/Magnum/Implementation/FramebufferState.h b/src/Magnum/Implementation/FramebufferState.h index e2f1ffeea..5547d1688 100644 --- a/src/Magnum/Implementation/FramebufferState.h +++ b/src/Magnum/Implementation/FramebufferState.h @@ -77,6 +77,7 @@ struct FramebufferState { void(Framebuffer::*texture1DImplementation)(Framebuffer::BufferAttachment, GLuint, GLint); #endif void(Framebuffer::*texture2DImplementation)(Framebuffer::BufferAttachment, GLenum, GLuint, GLint); + void(Framebuffer::*textureCubeMapImplementation)(Framebuffer::BufferAttachment, GLenum, GLuint, GLint); #if !(defined(MAGNUM_TARGET_WEBGL) && defined(MAGNUM_TARGET_GLES2)) void(Framebuffer::*textureLayerImplementation)(Framebuffer::BufferAttachment, GLuint, GLint, GLint); #endif