diff --git a/doc/opengl-support.dox b/doc/opengl-support.dox index 938b75587..f0f515158 100644 --- a/doc/opengl-support.dox +++ b/doc/opengl-support.dox @@ -60,10 +60,10 @@ following: @extension{ARB,texture_float} | done @extension{ARB,depth_buffer_float} | done @extension{ARB,texture_rg} | done -@extension{ARB,framebuffer_object} | missing texture layer attachments +@extension{ARB,framebuffer_object} | done @extension{EXT,gpu_shader4} | done @extension{EXT,packed_float} | done -@extension{EXT,texture_array} | missing texture layer attachments +@extension{EXT,texture_array} | done @extension{EXT,texture_compression_rgtc} | done @extension{EXT,texture_shared_exponent} | done @extension{EXT,framebuffer_sRGB} | | diff --git a/src/Magnum/Framebuffer.cpp b/src/Magnum/Framebuffer.cpp index 141877e8a..4bb281504 100644 --- a/src/Magnum/Framebuffer.cpp +++ b/src/Magnum/Framebuffer.cpp @@ -27,15 +27,23 @@ #include -#ifndef MAGNUM_TARGET_GLES2 -#include "Magnum/BufferImage.h" -#endif #include "Magnum/Context.h" #include "Magnum/Extensions.h" #include "Magnum/Image.h" #include "Magnum/Renderbuffer.h" #include "Magnum/Texture.h" +#ifndef MAGNUM_TARGET_GLES2 +#include "Magnum/BufferImage.h" +#include "Magnum/TextureArray.h" +#endif + +#ifndef MAGNUM_TARGET_GLES +#include "Magnum/CubeMapTextureArray.h" +#include "Magnum/MultisampleTexture.h" +#include "Magnum/RectangleTexture.h" +#endif + #include "Implementation/DebugState.h" #include "Implementation/State.h" #include "Implementation/FramebufferState.h" @@ -152,28 +160,71 @@ Framebuffer& Framebuffer::attachRenderbuffer(const BufferAttachment attachment, } #ifndef MAGNUM_TARGET_GLES -Framebuffer& Framebuffer::attachTexture1D(const BufferAttachment attachment, Texture1D& texture, const Int level) { - (this->*Context::current()->state().framebuffer->texture1DImplementation)(attachment, texture, level); +Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, Texture1D& texture, const Int level) { + (this->*Context::current()->state().framebuffer->texture1DImplementation)(attachment, texture.id(), level); return *this; } #endif -Framebuffer& Framebuffer::attachTexture2D(BufferAttachment attachment, Texture2D& texture, Int mipLevel) { - /** @todo Check for texture target compatibility */ - (this->*Context::current()->state().framebuffer->texture2DImplementation)(attachment, GLenum(texture.target()), texture.id(), mipLevel); +Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, Texture2D& texture, const Int level) { + (this->*Context::current()->state().framebuffer->texture2DImplementation)(attachment, GL_TEXTURE_2D, texture.id(), level); + return *this; +} + +#ifndef MAGNUM_TARGET_GLES +Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, RectangleTexture& texture, const Int level) { + (this->*Context::current()->state().framebuffer->texture2DImplementation)(attachment, GL_TEXTURE_RECTANGLE, texture.id(), level); return *this; } +Framebuffer& Framebuffer::attachTexture(const BufferAttachment attachment, MultisampleTexture2D& texture, const Int level) { + (this->*Context::current()->state().framebuffer->texture2DImplementation)(attachment, GL_TEXTURE_2D_MULTISAMPLE, texture.id(), level); + return *this; +} +#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); return *this; } -Framebuffer& Framebuffer::attachTexture3D(Framebuffer::BufferAttachment attachment, Texture3D& texture, Int level, Int layer) { - /** @todo Check for texture target compatibility */ - (this->*Context::current()->state().framebuffer->texture3DImplementation)(attachment, texture, level, layer); +Framebuffer& Framebuffer::attachTextureLayer(Framebuffer::BufferAttachment attachment, Texture3D& texture, Int level, Int layer) { + (this->*Context::current()->state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); + return *this; +} + +#ifndef MAGNUM_TARGET_GLES +Framebuffer& Framebuffer::attachTextureLayer(Framebuffer::BufferAttachment attachment, Texture1DArray& texture, Int level, Int layer) { + (this->*Context::current()->state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); + return *this; +} +#endif + +#ifndef MAGNUM_TARGET_GLES2 +Framebuffer& Framebuffer::attachTextureLayer(Framebuffer::BufferAttachment attachment, Texture2DArray& texture, Int level, Int layer) { + (this->*Context::current()->state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); + return *this; +} +#endif + +#ifndef MAGNUM_TARGET_GLES +Framebuffer& Framebuffer::attachTextureLayer(Framebuffer::BufferAttachment attachment, CubeMapTextureArray& texture, Int level, Int layer) { + (this->*Context::current()->state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); + return *this; +} + +Framebuffer& Framebuffer::attachTextureLayer(Framebuffer::BufferAttachment attachment, MultisampleTexture2DArray& texture, Int level, Int layer) { + (this->*Context::current()->state().framebuffer->textureLayerImplementation)(attachment, texture.id(), level, layer); return *this; } +#endif + +#ifdef MAGNUM_BUILD_DEPRECATED +Framebuffer& Framebuffer::attachTexture2D(BufferAttachment attachment, Texture2D& texture, Int mipLevel) { + (this->*Context::current()->state().framebuffer->texture2DImplementation)(attachment, GLenum(texture.target()), texture.id(), mipLevel); + return *this; +} +#endif void Framebuffer::renderbufferImplementationDefault(BufferAttachment attachment, Renderbuffer& renderbuffer) { glFramebufferRenderbuffer(GLenum(bindInternal()), GLenum(attachment), GL_RENDERBUFFER, renderbuffer.id()); @@ -184,12 +235,12 @@ void Framebuffer::renderbufferImplementationDSA(BufferAttachment attachment, Ren glNamedFramebufferRenderbufferEXT(_id, GLenum(attachment), GL_RENDERBUFFER, renderbuffer.id()); } -void Framebuffer::texture1DImplementationDefault(BufferAttachment attachment, Texture1D& texture, GLint mipLevel) { - glFramebufferTexture1D(GLenum(bindInternal()), GLenum(attachment), GLenum(texture.target()), texture.id(), mipLevel); +void Framebuffer::texture1DImplementationDefault(BufferAttachment attachment, GLuint textureId, GLint mipLevel) { + glFramebufferTexture1D(GLenum(bindInternal()), GLenum(attachment), GL_TEXTURE_1D, textureId, mipLevel); } -void Framebuffer::texture1DImplementationDSA(BufferAttachment attachment, Texture1D& texture, GLint mipLevel) { - glNamedFramebufferTexture1DEXT(_id, GLenum(attachment), GLenum(texture.target()), texture.id(), mipLevel); +void Framebuffer::texture1DImplementationDSA(BufferAttachment attachment, GLuint textureId, GLint mipLevel) { + glNamedFramebufferTexture1DEXT(_id, GLenum(attachment), GL_TEXTURE_1D, textureId, mipLevel); } #endif @@ -203,24 +254,23 @@ void Framebuffer::texture2DImplementationDSA(BufferAttachment attachment, GLenum } #endif -void Framebuffer::texture3DImplementationDefault(BufferAttachment attachment, Texture3D& texture, GLint mipLevel, GLint layer) { - /** @todo Check for texture target compatibility */ - /** @todo Re-enable when extension loader is available for ES */ - #ifndef MAGNUM_TARGET_GLES - glFramebufferTexture3D(GLenum(bindInternal()), GLenum(attachment), GLenum(texture.target()), texture.id(), mipLevel, layer); +void Framebuffer::textureLayerImplementationDefault(BufferAttachment attachment, GLuint textureId, GLint mipLevel, GLint layer) { + /** @todo Re-enable when extension loader is available for ES 2.0 */ + #ifndef MAGNUM_TARGET_GLES2 + glFramebufferTextureLayer(GLenum(bindInternal()), GLenum(attachment), textureId, mipLevel, layer); #else static_cast(attachment); - static_cast(texture); + static_cast(textureId); static_cast(mipLevel); static_cast(layer); CORRADE_INTERNAL_ASSERT(false); - //glFramebufferTexture3DOES(GLenum(bindInternal()), GLenum(attachment), GLenum(texture.target()), texture.id(), mipLevel, layer); + //glFramebufferTexture3DOES(GLenum(bindInternal()), GLenum(attachment), GL_TEXTURE_3D_OES, texture.id(), mipLevel, layer); #endif } #ifndef MAGNUM_TARGET_GLES -void Framebuffer::texture3DImplementationDSA(BufferAttachment attachment, Texture3D& texture, GLint mipLevel, GLint layer) { - glNamedFramebufferTexture3DEXT(_id, GLenum(attachment), GLenum(texture.target()), texture.id(), mipLevel, layer); +void Framebuffer::textureLayerImplementationDSA(BufferAttachment attachment, GLuint textureId, GLint mipLevel, GLint layer) { + glNamedFramebufferTextureLayerEXT(_id, GLenum(attachment), textureId, mipLevel, layer); } #endif diff --git a/src/Magnum/Framebuffer.h b/src/Magnum/Framebuffer.h index 20fbc65ae..24a71991a 100644 --- a/src/Magnum/Framebuffer.h +++ b/src/Magnum/Framebuffer.h @@ -474,26 +474,27 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje #ifndef MAGNUM_TARGET_GLES /** - * @brief Attach 1D texture to given buffer + * @brief Attach texture to given buffer * @param attachment %Buffer attachment - * @param texture 1D texture + * @param texture Texture * @param level Mip level * @return Reference to self (for method chaining) * * If @extension{EXT,direct_state_access} is not available and the * framebufferbuffer is not currently bound, it is bound before the * operation. - * @see @fn_gl{BindFramebuffer}, @fn_gl2{FramebufferTexture1D,FramebufferTexture} - * or @fn_gl_extension{NamedFramebufferTexture1D,EXT,direct_state_access} + * @see @ref attachCubeMapTexture(), @fn_gl{BindFramebuffer}, + * @fn_gl2{FramebufferTexture1D,FramebufferTexture} or + * @fn_gl_extension{NamedFramebufferTexture1D,EXT,direct_state_access} * @requires_gl Only 2D and 3D textures are available in OpenGL ES. */ - Framebuffer& attachTexture1D(BufferAttachment attachment, Texture1D& texture, Int level); + Framebuffer& attachTexture(BufferAttachment attachment, Texture1D& texture, Int level); #endif /** - * @brief Attach 2D texture to given buffer + * @brief Attach texture to given buffer * @param attachment %Buffer attachment - * @param texture 2D texture + * @param texture Texture * @param level Mip level * @return Reference to self (for method chaining) * @@ -504,7 +505,21 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje * @fn_gl2{FramebufferTexture2D,FramebufferTexture} or * @fn_gl_extension{NamedFramebufferTexture2D,EXT,direct_state_access} */ - Framebuffer& attachTexture2D(BufferAttachment attachment, Texture2D& texture, Int level); + Framebuffer& attachTexture(BufferAttachment attachment, Texture2D& texture, Int level); + + #ifndef MAGNUM_TARGET_GLES + /** @overload + * @requires_gl31 %Extension @extension{ARB,texture_rectangle} + * @requires_gl Rectangle textures are not available in OpenGL ES. + */ + Framebuffer& attachTexture(BufferAttachment attachment, RectangleTexture& texture, Int level); + + /** @overload + * @requires_gl32 %Extension @extension{ARB,texture_multisample} + * @requires_gl Multisample textures are not available in OpenGL ES. + */ + Framebuffer& attachTexture(BufferAttachment attachment, MultisampleTexture2D& texture, Int level); + #endif /** * @brief Attach cube map texture to given buffer @@ -524,21 +539,78 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje Framebuffer& attachCubeMapTexture(BufferAttachment attachment, CubeMapTexture& texture, CubeMapTexture::Coordinate coordinate, Int level); /** - * @brief Attach 3D texture to given buffer + * @brief Attach texture layer to given buffer * @param attachment %Buffer attachment - * @param texture 3D texture + * @param texture Texture * @param level Mip level - * @param layer Layer of 2D image within a 3D texture + * @param layer Layer * @return Reference to self (for method chaining) * * If @extension{EXT,direct_state_access} is not available and the * framebufferbuffer is not currently bound, it is bound before the * operation. - * @see @fn_gl{BindFramebuffer}, @fn_gl2{FramebufferTexture3D,FramebufferTexture} - * or @fn_gl_extension{NamedFramebufferTexture3D,EXT,direct_state_access} - * @requires_es_extension %Extension @es_extension{OES,texture_3D} + * @see @fn_gl{BindFramebuffer}, @fn_gl2{FramebufferTextureLayer,FramebufferTexture} + * or @fn_gl_extension{NamedFramebufferTextureLayer,EXT,direct_state_access}, + * @fn_gles_extension{FramebufferTexture3D,OES,texture_3D} in OpenGL ES 2.0 + * @requires_gles30 %Extension @es_extension{OES,texture_3D} + */ + Framebuffer& attachTextureLayer(BufferAttachment attachment, Texture3D& texture, Int level, Int layer); + + #ifndef MAGNUM_TARGET_GLES + /** @overload + * @requires_gl30 %Extension @extension{EXT,texture_array} + * @requires_gl Only 2D array textures are available in OpenGL ES. + */ + Framebuffer& attachTextureLayer(BufferAttachment attachment, Texture1DArray& texture, Int level, Int layer); + #endif + + #ifndef MAGNUM_TARGET_GLES2 + /** @overload + * @requires_gl30 %Extension @extension{EXT,texture_array} + * @requires_gles30 %Array textures are not available in OpenGL ES 2.0. + */ + Framebuffer& attachTextureLayer(BufferAttachment attachment, Texture2DArray& texture, Int level, Int layer); + #endif + + #ifndef MAGNUM_TARGET_GLES + /** @overload + * @requires_gl40 %Extension @extension{ARB,texture_cube_map_array} + * @requires_gl Cube map texture arrays are not available in OpenGL ES. */ - Framebuffer& attachTexture3D(BufferAttachment attachment, Texture3D& texture, Int level, Int layer); + Framebuffer& attachTextureLayer(BufferAttachment attachment, CubeMapTextureArray& texture, Int level, Int layer); + + /** @overload + * @requires_gl32 %Extension @extension{ARB,texture_multisample} + * @requires_gl Multisample textures are not available in OpenGL ES. + */ + Framebuffer& attachTextureLayer(BufferAttachment attachment, MultisampleTexture2DArray& texture, Int level, Int layer); + #endif + + #ifdef MAGNUM_BUILD_DEPRECATED + #ifndef MAGNUM_TARGET_GLES + /** + * @copybrief attachTexture() + * @deprecated Use one of @ref Magnum::Framebuffer::attachTexture() "attachTexture()" overloads instead. + */ + Framebuffer& attachTexture1D(BufferAttachment attachment, Texture1D& texture, Int level) { + return attachTexture(attachment, texture, level); + } + #endif + + /** + * @copybrief attachTexture() + * @deprecated Use one of @ref Magnum::Framebuffer::attachTexture() "attachTexture()" overloads instead. + */ + Framebuffer& attachTexture2D(BufferAttachment attachment, Texture2D& texture, Int level); + + /** + * @copybrief attachTextureLayer() + * @deprecated Use one of @ref Magnum::Framebuffer::attachTextureLayer() "attachTextureLayer()" overloads instead. + */ + Framebuffer& attachTexture3D(BufferAttachment attachment, Texture3D& texture, Int level, Int layer) { + return attachTextureLayer(attachment, texture, level, layer); + } + #endif /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT @@ -555,8 +627,8 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje #endif #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL texture1DImplementationDefault(BufferAttachment attachment, Texture1D& texture, GLint level); - void MAGNUM_LOCAL texture1DImplementationDSA(BufferAttachment attachment, Texture1D& texture, GLint level); + void MAGNUM_LOCAL texture1DImplementationDefault(BufferAttachment attachment, GLuint textureId, GLint level); + void MAGNUM_LOCAL texture1DImplementationDSA(BufferAttachment attachment, GLuint textureId, GLint level); #endif void MAGNUM_LOCAL texture2DImplementationDefault(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint level); @@ -564,9 +636,9 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje void MAGNUM_LOCAL texture2DImplementationDSA(BufferAttachment attachment, GLenum textureTarget, GLuint textureId, GLint level); #endif - void MAGNUM_LOCAL texture3DImplementationDefault(BufferAttachment attachment, Texture3D& texture, GLint level, GLint layer); + void MAGNUM_LOCAL textureLayerImplementationDefault(BufferAttachment attachment, GLuint textureId, GLint level, GLint layer); #ifndef MAGNUM_TARGET_GLES - void MAGNUM_LOCAL texture3DImplementationDSA(BufferAttachment attachment, Texture3D& texture, GLint level, GLint layer); + void MAGNUM_LOCAL textureLayerImplementationDSA(BufferAttachment attachment, GLuint textureId, GLint level, GLint layer); #endif }; diff --git a/src/Magnum/Implementation/FramebufferState.cpp b/src/Magnum/Implementation/FramebufferState.cpp index 5ef927e74..4b6a99803 100644 --- a/src/Magnum/Implementation/FramebufferState.cpp +++ b/src/Magnum/Implementation/FramebufferState.cpp @@ -49,7 +49,7 @@ FramebufferState::FramebufferState(Context& context, std::vector& e renderbufferImplementation = &Framebuffer::renderbufferImplementationDSA; texture1DImplementation = &Framebuffer::texture1DImplementationDSA; texture2DImplementation = &Framebuffer::texture2DImplementationDSA; - texture3DImplementation = &Framebuffer::texture3DImplementationDSA; + textureLayerImplementation = &Framebuffer::textureLayerImplementationDSA; renderbufferStorageImplementation = &Renderbuffer::storageImplementationDSA; } else @@ -65,7 +65,7 @@ FramebufferState::FramebufferState(Context& context, std::vector& e texture1DImplementation = &Framebuffer::texture1DImplementationDefault; #endif texture2DImplementation = &Framebuffer::texture2DImplementationDefault; - texture3DImplementation = &Framebuffer::texture3DImplementationDefault; + textureLayerImplementation = &Framebuffer::textureLayerImplementationDefault; renderbufferStorageImplementation = &Renderbuffer::storageImplementationDefault; } diff --git a/src/Magnum/Implementation/FramebufferState.h b/src/Magnum/Implementation/FramebufferState.h index 9df8a9bb3..f8ecde63c 100644 --- a/src/Magnum/Implementation/FramebufferState.h +++ b/src/Magnum/Implementation/FramebufferState.h @@ -42,10 +42,10 @@ struct FramebufferState { void(Framebuffer::*renderbufferImplementation)(Framebuffer::BufferAttachment, Renderbuffer&); #ifndef MAGNUM_TARGET_GLES - void(Framebuffer::*texture1DImplementation)(Framebuffer::BufferAttachment, Texture1D&, GLint); + void(Framebuffer::*texture1DImplementation)(Framebuffer::BufferAttachment, GLuint, GLint); #endif void(Framebuffer::*texture2DImplementation)(Framebuffer::BufferAttachment, GLenum, GLuint, GLint); - void(Framebuffer::*texture3DImplementation)(Framebuffer::BufferAttachment, Texture3D&, GLint, GLint); + void(Framebuffer::*textureLayerImplementation)(Framebuffer::BufferAttachment, GLuint, GLint, GLint); void(Renderbuffer::*renderbufferStorageImplementation)(RenderbufferFormat, const Vector2i&); void(Renderbuffer::*renderbufferStorageMultisampleImplementation)(GLsizei, RenderbufferFormat, const Vector2i&); diff --git a/src/Magnum/Test/FramebufferGLTest.cpp b/src/Magnum/Test/FramebufferGLTest.cpp index 217843e1a..f7e4be20e 100644 --- a/src/Magnum/Test/FramebufferGLTest.cpp +++ b/src/Magnum/Test/FramebufferGLTest.cpp @@ -24,9 +24,7 @@ */ #include "Magnum/configure.h" -#ifndef MAGNUM_TARGET_GLES2 -#include "Magnum/BufferImage.h" -#endif +#include "Magnum/Color.h" #include "Magnum/ColorFormat.h" #include "Magnum/Context.h" #include "Magnum/Extensions.h" @@ -38,6 +36,16 @@ #include "Magnum/TextureFormat.h" #include "Magnum/Test/AbstractOpenGLTester.h" +#ifndef MAGNUM_TARGET_GLES2 +#include "Magnum/BufferImage.h" +#include "Magnum/TextureArray.h" +#endif + +#ifndef MAGNUM_TARGET_GLES +#include "Magnum/CubeMapTextureArray.h" +#include "Magnum/RectangleTexture.h" +#endif + namespace Magnum { namespace Test { class FramebufferGLTest: public AbstractOpenGLTester { @@ -298,8 +306,8 @@ void FramebufferGLTest::attachTexture1D() { depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, 128); Framebuffer framebuffer({{}, {128, 1}}); - framebuffer.attachTexture1D(Framebuffer::ColorAttachment(0), color, 0) - .attachTexture1D(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0); + framebuffer.attachTexture(Framebuffer::ColorAttachment(0), color, 0) + .attachTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::ReadDraw), Framebuffer::Status::Complete); @@ -327,7 +335,7 @@ void FramebufferGLTest::attachTexture2D() { MAGNUM_VERIFY_NO_ERROR(); - framebuffer.attachTexture2D(Framebuffer::ColorAttachment(0), color, 0); + framebuffer.attachTexture(Framebuffer::ColorAttachment(0), color, 0); MAGNUM_VERIFY_NO_ERROR(); @@ -342,11 +350,11 @@ void FramebufferGLTest::attachTexture2D() { Texture2D depthStencil; #ifndef MAGNUM_TARGET_GLES2 depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, Vector2i(128)); - framebuffer.attachTexture2D(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0); + framebuffer.attachTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0); #else depthStencil.setStorage(1, TextureFormat::DepthStencil, Vector2i(128)); - framebuffer.attachTexture2D(Framebuffer::BufferAttachment::Depth, depthStencil, 0) - .attachTexture2D(Framebuffer::BufferAttachment::Stencil, depthStencil, 0); + framebuffer.attachTexture(Framebuffer::BufferAttachment::Depth, depthStencil, 0) + .attachTexture(Framebuffer::BufferAttachment::Stencil, depthStencil, 0); #endif } @@ -356,7 +364,7 @@ void FramebufferGLTest::attachTexture2D() { Texture2D depth; depth.setStorage(1, TextureFormat::DepthComponent16, Vector2i(128)); - framebuffer.attachTexture2D(Framebuffer::BufferAttachment::Depth, depth, 0); + framebuffer.attachTexture(Framebuffer::BufferAttachment::Depth, depth, 0); } #endif @@ -371,8 +379,6 @@ void FramebufferGLTest::attachTexture3D() { #elif defined(MAGNUM_TARGET_GLES2) if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not available.")); - #else - CORRADE_SKIP("Not properly implemented yet."); #endif Texture3D color; @@ -383,7 +389,7 @@ void FramebufferGLTest::attachTexture3D() { #endif Framebuffer framebuffer({{}, Vector2i(128)}); - framebuffer.attachTexture3D(Framebuffer::ColorAttachment(0), color, 0, 0); + framebuffer.attachTextureLayer(Framebuffer::ColorAttachment(0), color, 0, 0); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::ReadDraw), Framebuffer::Status::Complete); @@ -394,17 +400,16 @@ void FramebufferGLTest::attachTexture1DArray() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - Texture2D color(Texture2D::Target::Texture1DArray); + Texture1DArray color; color.setStorage(1, TextureFormat::RGBA8, {128, 8}); - Texture2D depthStencil(Texture2D::Target::Texture1DArray); + Texture1DArray depthStencil; depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, {128, 8}); Framebuffer framebuffer({{}, {128, 1}}); - framebuffer.attachTexture2D(Framebuffer::ColorAttachment(0), color, 0) - .attachTexture2D(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0); + framebuffer.attachTextureLayer(Framebuffer::ColorAttachment(0), color, 0, 3) + .attachTextureLayer(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0, 3); - CORRADE_EXPECT_FAIL("Not properly implemented yet."); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::ReadDraw), Framebuffer::Status::Complete); } @@ -415,21 +420,20 @@ void FramebufferGLTest::attachTexture2DArray() { #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); - #else - CORRADE_SKIP("Not properly implemented yet."); + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not available.")); #endif - Texture3D color(Texture3D::Target::Texture2DArray); + Texture2DArray color; color.setStorage(1, TextureFormat::RGBA8, {128, 128, 8}); - Texture3D depthStencil(Texture3D::Target::Texture2DArray); + Texture2DArray depthStencil; depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, {128, 128, 8}); Framebuffer framebuffer({{}, Vector2i(128)}); - framebuffer.attachTexture3D(Framebuffer::ColorAttachment(0), color, 0, 0) - .attachTexture3D(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0, 0); + framebuffer.attachTextureLayer(Framebuffer::ColorAttachment(0), color, 0, 3) + .attachTextureLayer(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0, 3); - CORRADE_EXPECT_FAIL("Not properly implemented yet."); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::ReadDraw), Framebuffer::Status::Complete); } @@ -450,15 +454,15 @@ void FramebufferGLTest::attachRectangleTexture() { if(!Context::current()->isExtensionSupported()) CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not available.")); - Texture2D color(Texture2D::Target::Rectangle); - color.setStorage(1, TextureFormat::RGBA8, Vector2i(128)); + RectangleTexture color; + color.setStorage(TextureFormat::RGBA8, Vector2i(128)); - Texture2D depthStencil(Texture2D::Target::Rectangle); - depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, Vector2i(128)); + RectangleTexture depthStencil; + depthStencil.setStorage(TextureFormat::Depth24Stencil8, Vector2i(128)); Framebuffer framebuffer({{}, Vector2i(128)}); - framebuffer.attachTexture2D(Framebuffer::ColorAttachment(0), color, 0) - .attachTexture2D(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0); + framebuffer.attachTexture(Framebuffer::ColorAttachment(0), color, 0) + .attachTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0); MAGNUM_VERIFY_NO_ERROR(); CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::ReadDraw), Framebuffer::Status::Complete); @@ -516,7 +520,23 @@ void FramebufferGLTest::attachCubeMapTexture() { #ifndef MAGNUM_TARGET_GLES void FramebufferGLTest::attachCubeMapTextureArray() { - CORRADE_SKIP("Not implemented yet."); + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available.")); + if(!Context::current()->isExtensionSupported()) + CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not available.")); + + CubeMapTextureArray color; + color.setStorage(1, TextureFormat::RGBA8, {128, 128, 18}); + + CubeMapTextureArray depthStencil; + depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, {128, 128, 18}); + + Framebuffer framebuffer({{}, Vector2i(128)}); + framebuffer.attachTextureLayer(Framebuffer::ColorAttachment(0), color, 0, 3) + .attachTextureLayer(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0, 3); + + MAGNUM_VERIFY_NO_ERROR(); + CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::ReadDraw), Framebuffer::Status::Complete); } #endif @@ -547,8 +567,8 @@ void FramebufferGLTest::multipleColorOutputs() { depth.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128)); Framebuffer framebuffer({{}, Vector2i(128)}); - framebuffer.attachTexture2D(Framebuffer::ColorAttachment(0), color1, 0) - .attachTexture2D(Framebuffer::ColorAttachment(1), color2, 0) + framebuffer.attachTexture(Framebuffer::ColorAttachment(0), color1, 0) + .attachTexture(Framebuffer::ColorAttachment(1), color2, 0) .attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depth) .mapForDraw({{0, Framebuffer::ColorAttachment(1)}, {1, Framebuffer::ColorAttachment(0)}}); diff --git a/src/Magnum/TextureTools/DistanceField.cpp b/src/Magnum/TextureTools/DistanceField.cpp index b76bbd05e..b5ba59b17 100644 --- a/src/Magnum/TextureTools/DistanceField.cpp +++ b/src/Magnum/TextureTools/DistanceField.cpp @@ -149,7 +149,7 @@ void distanceField(Texture2D& input, Texture2D& output, const Range2Di& rectangl #endif Framebuffer framebuffer(rectangle); - framebuffer.attachTexture2D(Framebuffer::ColorAttachment(0), output, 0); + framebuffer.attachTexture(Framebuffer::ColorAttachment(0), output, 0); framebuffer.bind(FramebufferTarget::Draw); framebuffer.clear(FramebufferClear::Color);