Browse Source

DebugTools: fallback to Texture::subImage() on desktop.

I still have to fill up the missing parts to make it orthogonal, but NO
DAMN TIME.
pull/141/head
Vladimír Vondruš 10 years ago
parent
commit
74e43a4f31
  1. 16
      src/Magnum/DebugTools/TextureImage.cpp
  2. 3
      src/Magnum/DebugTools/TextureImage.h

16
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<Extensions::GL::ARB::get_texture_sub_image>()) {
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<Extensions::GL::ARB::get_texture_sub_image>()) {
texture.subImage(level, range, image, usage);
return;
}
#endif
Framebuffer fb{range};
fb.attachTexture(Framebuffer::ColorAttachment{0}, texture, level)
.read(range, image, usage);

3
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

Loading…
Cancel
Save