From 74e43a4f312d36f54baf92c6e9f3ed023ebfe7be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 12 Apr 2016 14:27:16 +0200 Subject: [PATCH] DebugTools: fallback to Texture::subImage() on desktop. I still have to fill up the missing parts to make it orthogonal, but NO DAMN TIME. --- src/Magnum/DebugTools/TextureImage.cpp | 16 ++++++++++++++++ src/Magnum/DebugTools/TextureImage.h | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) 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