diff --git a/src/Magnum/DebugTools/TextureImage.cpp b/src/Magnum/DebugTools/TextureImage.cpp index 0f3c8ffb0..516dd69f3 100644 --- a/src/Magnum/DebugTools/TextureImage.cpp +++ b/src/Magnum/DebugTools/TextureImage.cpp @@ -26,6 +26,8 @@ #include "TextureImage.h" #include "Magnum/BufferImage.h" +#include "Magnum/Context.h" +#include "Magnum/Extensions.h" #include "Magnum/Framebuffer.h" #include "Magnum/Image.h" #include "Magnum/Texture.h" @@ -92,6 +94,13 @@ FloatReinterpretShader::FloatReinterpretShader() { #endif void textureSubImage(Texture2D& texture, const Int level, const Range2Di& range, Image2D& image) { + #ifndef MAGNUM_TARGET_GLES + if(Context::current().isExtensionSupported()) { + texture.subImage(level, range, image); + return; + } + #endif + #ifdef MAGNUM_TARGET_GLES if(image.type() == PixelType::Float) { const PixelFormat imageFormat = image.format(); @@ -165,6 +174,13 @@ void textureSubImage(CubeMapTexture& texture, const CubeMapCoordinate coordinate #ifndef MAGNUM_TARGET_GLES2 void textureSubImage(Texture2D& texture, const Int level, const Range2Di& range, BufferImage2D& image, const BufferUsage usage) { + #ifndef MAGNUM_TARGET_GLES + if(Context::current().isExtensionSupported()) { + texture.subImage(level, range, image, usage); + return; + } + #endif + Framebuffer fb{range}; fb.attachTexture(Framebuffer::ColorAttachment{0}, texture, level) .read(range, image, usage); diff --git a/src/Magnum/DebugTools/TextureImage.h b/src/Magnum/DebugTools/TextureImage.h index ad9297746..591c63d79 100644 --- a/src/Magnum/DebugTools/TextureImage.h +++ b/src/Magnum/DebugTools/TextureImage.h @@ -39,7 +39,8 @@ namespace Magnum { namespace DebugTools { Emulates @ref Texture::subImage() "*Texture::subImage()" call on platforms that don't support it (such as OpenGL ES) by creating a framebuffer object and using -@ref Framebuffer::read(). +@ref Framebuffer::read(). On desktop OpenGL, if @extension{ARB,get_texture_sub_image} +is available, it's just an alias to @ref Texture::subImage() "*Texture::subImage()". Note that only @ref Magnum::PixelFormat "PixelFormat" and @ref PixelType values that are marked as framebuffer readable are supported. In addition, on OpenGL