Browse Source

Fix Framebuffer::attachCubeMapTexture() behaving as a layered attachment.

The DSA function does not accept any texture target parameter so the
cube map texture was bound as a whole (and thus behaving as a layered
attachment) instead of just a single face. Thanks to @chpatrick for the
report.
pull/126/head
Vladimír Vondruš 11 years ago
parent
commit
291b5bd3a8
  1. 6
      src/Magnum/Framebuffer.cpp
  2. 3
      src/Magnum/Framebuffer.h
  3. 7
      src/Magnum/Implementation/FramebufferState.cpp
  4. 1
      src/Magnum/Implementation/FramebufferState.h

6
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))

3
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))

7
src/Magnum/Implementation/FramebufferState.cpp

@ -74,7 +74,10 @@ FramebufferState::FramebufferState(Context& context, std::vector<std::string>& 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<std::string>& 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<std::string>& 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

1
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

Loading…
Cancel
Save