mirror of https://github.com/mosra/magnum.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2105 lines
90 KiB
2105 lines
90 KiB
|
13 years ago
|
/*
|
||
|
|
This file is part of Magnum.
|
||
|
|
|
||
|
8 years ago
|
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
|
||
|
12 years ago
|
Vladimír Vondruš <mosra@centrum.cz>
|
||
|
13 years ago
|
|
||
|
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||
|
|
copy of this software and associated documentation files (the "Software"),
|
||
|
|
to deal in the Software without restriction, including without limitation
|
||
|
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||
|
|
and/or sell copies of the Software, and to permit persons to whom the
|
||
|
|
Software is furnished to do so, subject to the following conditions:
|
||
|
|
|
||
|
|
The above copyright notice and this permission notice shall be included
|
||
|
|
in all copies or substantial portions of the Software.
|
||
|
|
|
||
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||
|
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||
|
|
DEALINGS IN THE SOFTWARE.
|
||
|
|
*/
|
||
|
|
|
||
|
10 years ago
|
#include <Corrade/TestSuite/Compare/Container.h>
|
||
|
|
|
||
|
12 years ago
|
#include "Magnum/Context.h"
|
||
|
10 years ago
|
#include "Magnum/CubeMapTexture.h"
|
||
|
12 years ago
|
#include "Magnum/Extensions.h"
|
||
|
|
#include "Magnum/Framebuffer.h"
|
||
|
|
#include "Magnum/Image.h"
|
||
|
11 years ago
|
#include "Magnum/PixelFormat.h"
|
||
|
12 years ago
|
#include "Magnum/Renderbuffer.h"
|
||
|
|
#include "Magnum/RenderbufferFormat.h"
|
||
|
|
#include "Magnum/Texture.h"
|
||
|
|
#include "Magnum/TextureFormat.h"
|
||
|
11 years ago
|
#include "Magnum/Math/Color.h"
|
||
|
9 years ago
|
#include "Magnum/OpenGLTester.h"
|
||
|
13 years ago
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
#include "Magnum/BufferImage.h"
|
||
|
12 years ago
|
#include "Magnum/MultisampleTexture.h"
|
||
|
12 years ago
|
#include "Magnum/TextureArray.h"
|
||
|
|
#endif
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
#include "Magnum/CubeMapTextureArray.h"
|
||
|
11 years ago
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
12 years ago
|
#include "Magnum/RectangleTexture.h"
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
namespace Magnum { namespace Test {
|
||
|
|
|
||
|
9 years ago
|
struct FramebufferGLTest: OpenGLTester {
|
||
|
11 years ago
|
explicit FramebufferGLTest();
|
||
|
|
|
||
|
|
void construct();
|
||
|
|
void constructCopy();
|
||
|
|
void constructMove();
|
||
|
11 years ago
|
void wrap();
|
||
|
11 years ago
|
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
11 years ago
|
void label();
|
||
|
8 years ago
|
#endif
|
||
|
11 years ago
|
|
||
|
|
void attachRenderbuffer();
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
11 years ago
|
void attachRenderbufferMultisample();
|
||
|
8 years ago
|
#endif
|
||
|
11 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void attachTexture1D();
|
||
|
|
#endif
|
||
|
|
void attachTexture2D();
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
11 years ago
|
void attachTexture3D();
|
||
|
8 years ago
|
#endif
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void attachTexture1DArray();
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void attachTexture2DArray();
|
||
|
|
void attachTexture2DMultisample();
|
||
|
|
#endif
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
11 years ago
|
void attachTexture2DMultisampleArray();
|
||
|
11 years ago
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
11 years ago
|
void attachRectangleTexture();
|
||
|
|
#endif
|
||
|
|
void attachCubeMapTexture();
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
11 years ago
|
void attachCubeMapTextureArray();
|
||
|
|
#endif
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
void attachLayeredTexture3D();
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void attachLayeredTexture1DArray();
|
||
|
|
#endif
|
||
|
|
void attachLayeredTexture2DArray();
|
||
|
|
void attachLayeredCubeMapTexture();
|
||
|
|
void attachLayeredCubeMapTextureArray();
|
||
|
|
void attachLayeredTexture2DMultisampleArray();
|
||
|
|
#endif
|
||
|
11 years ago
|
void detach();
|
||
|
11 years ago
|
|
||
|
|
void multipleColorOutputs();
|
||
|
|
|
||
|
|
void clear();
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void clearColorI();
|
||
|
|
void clearColorUI();
|
||
|
|
void clearColorF();
|
||
|
|
void clearDepth();
|
||
|
|
void clearStencil();
|
||
|
|
void clearDepthStencil();
|
||
|
|
#endif
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
11 years ago
|
void invalidate();
|
||
|
8 years ago
|
#endif
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void invalidateSub();
|
||
|
|
#endif
|
||
|
|
void read();
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void readBuffer();
|
||
|
|
#endif
|
||
|
10 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void copyImageTexture1D();
|
||
|
|
#endif
|
||
|
|
void copyImageTexture2D();
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void copyImageTexture1DArray();
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void copyImageRectangleTexture();
|
||
|
|
#endif
|
||
|
|
void copyImageCubeMapTexture();
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void copySubImageTexture1D();
|
||
|
|
#endif
|
||
|
|
void copySubImageTexture2D();
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
10 years ago
|
void copySubImageTexture3D();
|
||
|
8 years ago
|
#endif
|
||
|
10 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void copySubImageTexture1DArray();
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void copySubImageTexture2DArray();
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void copySubImageRectangleTexture();
|
||
|
|
#endif
|
||
|
|
void copySubImageCubeMapTexture();
|
||
|
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
void copySubImageCubeMapTextureArray();
|
||
|
|
#endif
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
11 years ago
|
void blit();
|
||
|
8 years ago
|
#endif
|
||
|
12 years ago
|
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
12 years ago
|
private:
|
||
|
|
TextureFormat rgbaFormatES2, depthStencilFormatES2;
|
||
|
|
#endif
|
||
|
13 years ago
|
};
|
||
|
|
|
||
|
|
FramebufferGLTest::FramebufferGLTest() {
|
||
|
13 years ago
|
addTests({&FramebufferGLTest::construct,
|
||
|
|
&FramebufferGLTest::constructCopy,
|
||
|
|
&FramebufferGLTest::constructMove,
|
||
|
11 years ago
|
&FramebufferGLTest::wrap,
|
||
|
13 years ago
|
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
13 years ago
|
&FramebufferGLTest::label,
|
||
|
8 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
|
&FramebufferGLTest::attachRenderbuffer,
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
13 years ago
|
&FramebufferGLTest::attachRenderbufferMultisample,
|
||
|
8 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
&FramebufferGLTest::attachTexture1D,
|
||
|
|
#endif
|
||
|
|
&FramebufferGLTest::attachTexture2D,
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
13 years ago
|
&FramebufferGLTest::attachTexture3D,
|
||
|
8 years ago
|
#endif
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
&FramebufferGLTest::attachTexture1DArray,
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
&FramebufferGLTest::attachTexture2DArray,
|
||
|
12 years ago
|
&FramebufferGLTest::attachTexture2DMultisample,
|
||
|
13 years ago
|
#endif
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
13 years ago
|
&FramebufferGLTest::attachTexture2DMultisampleArray,
|
||
|
11 years ago
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
&FramebufferGLTest::attachRectangleTexture,
|
||
|
|
#endif
|
||
|
|
&FramebufferGLTest::attachCubeMapTexture,
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
13 years ago
|
&FramebufferGLTest::attachCubeMapTextureArray,
|
||
|
|
#endif
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
&FramebufferGLTest::attachLayeredTexture3D,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
&FramebufferGLTest::attachLayeredTexture1DArray,
|
||
|
|
#endif
|
||
|
|
&FramebufferGLTest::attachLayeredTexture2DArray,
|
||
|
|
&FramebufferGLTest::attachLayeredCubeMapTexture,
|
||
|
|
&FramebufferGLTest::attachLayeredCubeMapTextureArray,
|
||
|
|
&FramebufferGLTest::attachLayeredTexture2DMultisampleArray,
|
||
|
|
#endif
|
||
|
11 years ago
|
&FramebufferGLTest::detach,
|
||
|
13 years ago
|
|
||
|
|
&FramebufferGLTest::multipleColorOutputs,
|
||
|
|
|
||
|
|
&FramebufferGLTest::clear,
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
&FramebufferGLTest::clearColorI,
|
||
|
|
&FramebufferGLTest::clearColorUI,
|
||
|
|
&FramebufferGLTest::clearColorF,
|
||
|
|
&FramebufferGLTest::clearDepth,
|
||
|
|
&FramebufferGLTest::clearStencil,
|
||
|
|
&FramebufferGLTest::clearDepthStencil,
|
||
|
|
#endif
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
13 years ago
|
&FramebufferGLTest::invalidate,
|
||
|
8 years ago
|
#endif
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
13 years ago
|
&FramebufferGLTest::invalidateSub,
|
||
|
12 years ago
|
#endif
|
||
|
13 years ago
|
&FramebufferGLTest::read,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
&FramebufferGLTest::readBuffer,
|
||
|
|
#endif
|
||
|
10 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
&FramebufferGLTest::copyImageTexture1D,
|
||
|
|
#endif
|
||
|
|
&FramebufferGLTest::copyImageTexture2D,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
&FramebufferGLTest::copyImageTexture1DArray,
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
&FramebufferGLTest::copyImageRectangleTexture,
|
||
|
|
#endif
|
||
|
|
&FramebufferGLTest::copyImageCubeMapTexture,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
&FramebufferGLTest::copySubImageTexture1D,
|
||
|
|
#endif
|
||
|
|
&FramebufferGLTest::copySubImageTexture2D,
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
10 years ago
|
&FramebufferGLTest::copySubImageTexture3D,
|
||
|
8 years ago
|
#endif
|
||
|
10 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
&FramebufferGLTest::copySubImageTexture1DArray,
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
&FramebufferGLTest::copySubImageTexture2DArray,
|
||
|
|
#endif
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
&FramebufferGLTest::copySubImageRectangleTexture,
|
||
|
|
#endif
|
||
|
|
&FramebufferGLTest::copySubImageCubeMapTexture,
|
||
|
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
&FramebufferGLTest::copySubImageCubeMapTextureArray,
|
||
|
|
#endif
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
&FramebufferGLTest::blit
|
||
|
|
#endif
|
||
|
|
});
|
||
|
12 years ago
|
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
if(Context::current().isExtensionSupported<Extensions::GL::EXT::texture_storage>()) {
|
||
|
12 years ago
|
rgbaFormatES2 = TextureFormat::RGBA8;
|
||
|
|
depthStencilFormatES2 = TextureFormat::Depth24Stencil8;
|
||
|
|
} else {
|
||
|
|
rgbaFormatES2 = TextureFormat::RGBA;
|
||
|
|
depthStencilFormatES2 = TextureFormat::DepthStencil;
|
||
|
|
}
|
||
|
|
#endif
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
|
void FramebufferGLTest::construct() {
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
{
|
||
|
|
const Framebuffer framebuffer({{32, 16}, {128, 256}});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_VERIFY(framebuffer.id() > 0);
|
||
|
|
CORRADE_COMPARE(framebuffer.viewport(), Range2Di({32, 16}, {128, 256}));
|
||
|
|
}
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
|
void FramebufferGLTest::constructCopy() {
|
||
|
13 years ago
|
CORRADE_VERIFY(!(std::is_constructible<Framebuffer, const Framebuffer&>{}));
|
||
|
|
CORRADE_VERIFY(!(std::is_assignable<Framebuffer, const Framebuffer&>{}));
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
|
void FramebufferGLTest::constructMove() {
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
Framebuffer a({{32, 16}, {128, 256}});
|
||
|
|
const Int id = a.id();
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_VERIFY(id > 0);
|
||
|
|
|
||
|
|
Framebuffer b(std::move(a));
|
||
|
|
|
||
|
|
CORRADE_COMPARE(a.id(), 0);
|
||
|
|
CORRADE_COMPARE(b.id(), id);
|
||
|
|
CORRADE_COMPARE(b.viewport(), Range2Di({32, 16}, {128, 256}));
|
||
|
|
|
||
|
|
Framebuffer c({{128, 256}, {32, 16}});
|
||
|
|
const Int cId = c.id();
|
||
|
|
c = std::move(b);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_VERIFY(cId > 0);
|
||
|
|
CORRADE_COMPARE(b.id(), cId);
|
||
|
|
CORRADE_COMPARE(c.id(), id);
|
||
|
|
CORRADE_COMPARE(c.viewport(), Range2Di({32, 16}, {128, 256}));
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void FramebufferGLTest::wrap() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
GLuint id;
|
||
|
|
glGenFramebuffers(1, &id);
|
||
|
|
|
||
|
|
/* Releasing won't delete anything */
|
||
|
|
{
|
||
|
|
auto framebuffer = Framebuffer::wrap(id, {}, ObjectFlag::DeleteOnDestruction);
|
||
|
|
CORRADE_COMPARE(framebuffer.release(), id);
|
||
|
|
}
|
||
|
|
|
||
|
|
/* ...so we can wrap it again */
|
||
|
|
Framebuffer::wrap(id, {});
|
||
|
|
glDeleteFramebuffers(1, &id);
|
||
|
|
}
|
||
|
|
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
13 years ago
|
void FramebufferGLTest::label() {
|
||
|
13 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
/* No-Op version is tested in AbstractObjectGLTest */
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::KHR::debug>() &&
|
||
|
|
!Context::current().isExtensionSupported<Extensions::GL::EXT::debug_label>())
|
||
|
13 years ago
|
CORRADE_SKIP("Required extension is not available");
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(32)});
|
||
|
|
|
||
|
|
CORRADE_COMPARE(framebuffer.label(), "");
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
framebuffer.setLabel("MyFramebuffer");
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(framebuffer.label(), "MyFramebuffer");
|
||
|
|
}
|
||
|
8 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
13 years ago
|
void FramebufferGLTest::attachRenderbuffer() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer color;
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA8, Vector2i(128));
|
||
|
|
#else
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA4, Vector2i(128));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
/* Separate depth and stencil renderbuffers are not supported (or at least
|
||
|
|
on my NVidia, thus we need to do this juggling with one renderbuffer */
|
||
|
|
Renderbuffer depthStencil;
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
|
||
|
13 years ago
|
#endif
|
||
|
|
{
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
13 years ago
|
Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string();
|
||
|
|
#endif
|
||
|
8 years ago
|
depthStencil.setStorage(
|
||
|
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
RenderbufferFormat::Depth24Stencil8,
|
||
|
|
#else
|
||
|
|
RenderbufferFormat::DepthStencil,
|
||
|
|
#endif
|
||
|
|
Vector2i(128));
|
||
|
13 years ago
|
}
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
13 years ago
|
else depthStencil.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), color)
|
||
|
|
.attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depthStencil);
|
||
|
|
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
|
||
|
13 years ago
|
#endif
|
||
|
|
{
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::BufferAttachment::Stencil, depthStencil);
|
||
|
|
}
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
13 years ago
|
void FramebufferGLTest::attachRenderbufferMultisample() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#elif defined(MAGNUM_TARGET_GLES2)
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ANGLE::framebuffer_multisample>() &&
|
||
|
|
!Context::current().isExtensionSupported<Extensions::GL::NV::framebuffer_multisample>())
|
||
|
13 years ago
|
CORRADE_SKIP("Required extension is not available.");
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer color;
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
color.setStorageMultisample(Renderbuffer::maxSamples(), RenderbufferFormat::RGBA8, Vector2i(128));
|
||
|
|
#else
|
||
|
|
color.setStorageMultisample(Renderbuffer::maxSamples(), RenderbufferFormat::RGBA4, Vector2i(128));
|
||
|
|
#endif
|
||
|
|
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
13 years ago
|
MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::OES::packed_depth_stencil);
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer depthStencil;
|
||
|
|
depthStencil.setStorageMultisample(Renderbuffer::maxSamples(), RenderbufferFormat::Depth24Stencil8, Vector2i(128));
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), color)
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
.attachRenderbuffer(Framebuffer::BufferAttachment::DepthStencil, depthStencil);
|
||
|
|
#else
|
||
|
|
.attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depthStencil)
|
||
|
|
.attachRenderbuffer(Framebuffer::BufferAttachment::Stencil, depthStencil);
|
||
|
|
#endif
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
}
|
||
|
8 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void FramebufferGLTest::attachTexture1D() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
|
||
|
|
Texture1D color;
|
||
|
|
color.setStorage(1, TextureFormat::RGBA8, 128);
|
||
|
|
|
||
|
|
Texture1D depthStencil;
|
||
|
|
depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, 128);
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, {128, 1}});
|
||
|
12 years ago
|
framebuffer.attachTexture(Framebuffer::ColorAttachment(0), color, 0)
|
||
|
|
.attachTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0);
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void FramebufferGLTest::attachTexture2D() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
Texture2D color;
|
||
|
8 years ago
|
color.setStorage(1,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
TextureFormat::RGBA8,
|
||
|
|
#elif !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
rgbaFormatES2,
|
||
|
|
#else
|
||
|
|
TextureFormat::RGBA,
|
||
|
|
#endif
|
||
|
|
Vector2i(128));
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
12 years ago
|
framebuffer.attachTexture(Framebuffer::ColorAttachment(0), color, 0);
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
|
||
|
13 years ago
|
#endif
|
||
|
|
{
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
13 years ago
|
Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string();
|
||
|
|
#endif
|
||
|
|
|
||
|
12 years ago
|
/** @todo Is there any better way to select proper sized/unsized format on ES2? */
|
||
|
13 years ago
|
Texture2D depthStencil;
|
||
|
8 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) || defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
depthStencil.setStorage(1,
|
||
|
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
TextureFormat::Depth24Stencil8,
|
||
|
|
#else
|
||
|
|
TextureFormat::DepthStencil,
|
||
|
|
#endif
|
||
|
|
Vector2i(128));
|
||
|
12 years ago
|
framebuffer.attachTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0);
|
||
|
13 years ago
|
#else
|
||
|
12 years ago
|
depthStencil.setStorage(1, depthStencilFormatES2, Vector2i(128));
|
||
|
12 years ago
|
framebuffer.attachTexture(Framebuffer::BufferAttachment::Depth, depthStencil, 0)
|
||
|
|
.attachTexture(Framebuffer::BufferAttachment::Stencil, depthStencil, 0);
|
||
|
13 years ago
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
else if(Context::current().isExtensionSupported<Extensions::GL::OES::depth_texture>()) {
|
||
|
13 years ago
|
Debug() << "Using" << Extensions::GL::OES::depth_texture::string();
|
||
|
|
|
||
|
|
Texture2D depth;
|
||
|
|
depth.setStorage(1, TextureFormat::DepthComponent16, Vector2i(128));
|
||
|
12 years ago
|
framebuffer.attachTexture(Framebuffer::BufferAttachment::Depth, depth, 0);
|
||
|
13 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
13 years ago
|
void FramebufferGLTest::attachTexture3D() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#elif defined(MAGNUM_TARGET_GLES2)
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Texture3D color;
|
||
|
8 years ago
|
color.setStorage(1,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
TextureFormat::RGBA8,
|
||
|
|
#else
|
||
|
|
rgbaFormatES2,
|
||
|
|
#endif
|
||
|
|
Vector3i(128));
|
||
|
13 years ago
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
12 years ago
|
framebuffer.attachTextureLayer(Framebuffer::ColorAttachment(0), color, 0, 0);
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
}
|
||
|
8 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void FramebufferGLTest::attachTexture1DArray() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_array>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not available."));
|
||
|
13 years ago
|
|
||
|
12 years ago
|
Texture1DArray color;
|
||
|
13 years ago
|
color.setStorage(1, TextureFormat::RGBA8, {128, 8});
|
||
|
|
|
||
|
12 years ago
|
Texture1DArray depthStencil;
|
||
|
13 years ago
|
depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, {128, 8});
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, {128, 1}});
|
||
|
12 years ago
|
framebuffer.attachTextureLayer(Framebuffer::ColorAttachment(0), color, 0, 3)
|
||
|
|
.attachTextureLayer(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0, 3);
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void FramebufferGLTest::attachTexture2DArray() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_array>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not available."));
|
||
|
13 years ago
|
#endif
|
||
|
|
|
||
|
12 years ago
|
Texture2DArray color;
|
||
|
13 years ago
|
color.setStorage(1, TextureFormat::RGBA8, {128, 128, 8});
|
||
|
|
|
||
|
12 years ago
|
Texture2DArray depthStencil;
|
||
|
13 years ago
|
depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, {128, 128, 8});
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
12 years ago
|
framebuffer.attachTextureLayer(Framebuffer::ColorAttachment(0), color, 0, 3)
|
||
|
|
.attachTextureLayer(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0, 3);
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
13 years ago
|
void FramebufferGLTest::attachTexture2DMultisample() {
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_multisample>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not available."));
|
||
|
12 years ago
|
#else
|
||
|
10 years ago
|
if(!Context::current().isVersionSupported(Version::GLES310))
|
||
|
12 years ago
|
CORRADE_SKIP("OpenGL ES 3.1 is not supported.");
|
||
|
|
#endif
|
||
|
12 years ago
|
|
||
|
|
MultisampleTexture2D color;
|
||
|
9 years ago
|
/* Mesa software implementation supports only 1 sample so we have to clamp */
|
||
|
|
color.setStorage(Math::min(4, MultisampleTexture2D::maxColorSamples()),
|
||
|
|
TextureFormat::RGBA8, {128, 128});
|
||
|
12 years ago
|
|
||
|
|
MultisampleTexture2D depthStencil;
|
||
|
9 years ago
|
/* Mesa software implementation supports only 1 sample so we have to clamp */
|
||
|
|
depthStencil.setStorage(Math::min(4, MultisampleTexture2D::maxDepthSamples()),
|
||
|
|
TextureFormat::Depth24Stencil8, {128, 128});
|
||
|
12 years ago
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
|
framebuffer.attachTexture(Framebuffer::ColorAttachment(0), color)
|
||
|
|
.attachTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
}
|
||
|
12 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
13 years ago
|
void FramebufferGLTest::attachTexture2DMultisampleArray() {
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_multisample>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not available."));
|
||
|
11 years ago
|
#else
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_storage_multisample_2d_array>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
12 years ago
|
|
||
|
|
MultisampleTexture2DArray color;
|
||
|
9 years ago
|
/* Mesa software implementation supports only 1 sample so we have to clamp */
|
||
|
|
color.setStorage(Math::min(4, MultisampleTexture2DArray::maxColorSamples()),
|
||
|
|
TextureFormat::RGBA8, {128, 128, 8});
|
||
|
12 years ago
|
|
||
|
|
MultisampleTexture2DArray depthStencil;
|
||
|
9 years ago
|
/* Mesa software implementation supports only 1 sample so we have to clamp */
|
||
|
|
depthStencil.setStorage(Math::min(4, MultisampleTexture2DArray::maxDepthSamples()),
|
||
|
|
TextureFormat::Depth24Stencil8, {128, 128, 8});
|
||
|
12 years ago
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
|
framebuffer.attachTextureLayer(Framebuffer::ColorAttachment(0), color, 3)
|
||
|
|
.attachTextureLayer(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 3);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
}
|
||
|
11 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
13 years ago
|
void FramebufferGLTest::attachRectangleTexture() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not available."));
|
||
|
|
|
||
|
12 years ago
|
RectangleTexture color;
|
||
|
|
color.setStorage(TextureFormat::RGBA8, Vector2i(128));
|
||
|
13 years ago
|
|
||
|
12 years ago
|
RectangleTexture depthStencil;
|
||
|
|
depthStencil.setStorage(TextureFormat::Depth24Stencil8, Vector2i(128));
|
||
|
13 years ago
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
12 years ago
|
framebuffer.attachTexture(Framebuffer::ColorAttachment(0), color)
|
||
|
|
.attachTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil);
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void FramebufferGLTest::attachCubeMapTexture() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
|
|
||
|
|
CubeMapTexture color;
|
||
|
8 years ago
|
color.setStorage(1,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
TextureFormat::RGBA8,
|
||
|
|
#elif !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
rgbaFormatES2,
|
||
|
|
#else
|
||
|
|
TextureFormat::RGBA,
|
||
|
|
#endif
|
||
|
|
Vector2i(128));
|
||
|
10 years ago
|
framebuffer.attachCubeMapTexture(Framebuffer::ColorAttachment(0), color, CubeMapCoordinate::NegativeZ, 0);
|
||
|
13 years ago
|
|
||
|
|
CubeMapTexture depthStencil;
|
||
|
|
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
|
||
|
13 years ago
|
#endif
|
||
|
|
{
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
13 years ago
|
Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string();
|
||
|
|
#endif
|
||
|
|
|
||
|
8 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) || defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
depthStencil.setStorage(1,
|
||
|
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
TextureFormat::Depth24Stencil8,
|
||
|
|
#else
|
||
|
|
TextureFormat::DepthStencil,
|
||
|
|
#endif
|
||
|
|
Vector2i(128));
|
||
|
10 years ago
|
framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, CubeMapCoordinate::NegativeZ, 0);
|
||
|
13 years ago
|
#else
|
||
|
12 years ago
|
depthStencil.setStorage(1, depthStencilFormatES2, Vector2i(128));
|
||
|
10 years ago
|
framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::Depth, depthStencil, CubeMapCoordinate::NegativeZ, 0)
|
||
|
|
.attachCubeMapTexture(Framebuffer::BufferAttachment::Stencil, depthStencil, CubeMapCoordinate::NegativeZ, 0);
|
||
|
13 years ago
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
else if(Context::current().isExtensionSupported<Extensions::GL::OES::depth_texture>()) {
|
||
|
13 years ago
|
Debug() << "Using" << Extensions::GL::OES::depth_texture::string();
|
||
|
|
|
||
|
|
depthStencil.setStorage(1, TextureFormat::DepthComponent16, Vector2i(128));
|
||
|
10 years ago
|
framebuffer.attachCubeMapTexture(Framebuffer::BufferAttachment::Depth, depthStencil, CubeMapCoordinate::NegativeZ, 0);
|
||
|
13 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
13 years ago
|
void FramebufferGLTest::attachCubeMapTextureArray() {
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_cube_map_array>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not available."));
|
||
|
11 years ago
|
#else
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_cube_map_array>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
12 years ago
|
|
||
|
|
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();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
void FramebufferGLTest::attachLayeredTexture3D() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::geometry_shader4>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::geometry_shader4::string() + std::string(" is not available."));
|
||
|
|
#else
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::geometry_shader>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::geometry_shader::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Texture3D color;
|
||
|
|
color.setStorage(1, TextureFormat::RGBA8, Vector3i{128});
|
||
|
|
|
||
|
|
Framebuffer framebuffer{{{}, Vector2i{128}}};
|
||
|
|
framebuffer.attachLayeredTexture(Framebuffer::ColorAttachment{0}, color, 0);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void FramebufferGLTest::attachLayeredTexture1DArray() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::geometry_shader4>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::geometry_shader4::string() + std::string(" is not available."));
|
||
|
|
|
||
|
|
Texture1DArray color;
|
||
|
|
color.setStorage(1, TextureFormat::RGBA8, {128, 8});
|
||
|
|
|
||
|
|
Texture1DArray depthStencil;
|
||
|
|
depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, {128, 8});
|
||
|
|
|
||
|
|
Framebuffer framebuffer{{{}, {128, 1}}};
|
||
|
|
framebuffer.attachLayeredTexture(Framebuffer::ColorAttachment{0}, color, 0)
|
||
|
|
.attachLayeredTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void FramebufferGLTest::attachLayeredTexture2DArray() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::geometry_shader4>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::geometry_shader4::string() + std::string(" is not available."));
|
||
|
|
#else
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::geometry_shader>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::geometry_shader::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Texture2DArray color;
|
||
|
|
color.setStorage(1, TextureFormat::RGBA8, {128, 128, 8});
|
||
|
|
|
||
|
|
Texture2DArray depthStencil;
|
||
|
|
depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, {128, 128, 8});
|
||
|
|
|
||
|
|
Framebuffer framebuffer{{{}, Vector2i{128}}};
|
||
|
|
framebuffer.attachLayeredTexture(Framebuffer::ColorAttachment{0}, color, 0)
|
||
|
|
.attachLayeredTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
|
}
|
||
|
|
|
||
|
|
void FramebufferGLTest::attachLayeredCubeMapTexture() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::geometry_shader4>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::geometry_shader4::string() + std::string(" is not available."));
|
||
|
|
#else
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::geometry_shader>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::geometry_shader::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
CubeMapTexture color;
|
||
|
|
color.setStorage(1, TextureFormat::RGBA8, Vector2i{128});
|
||
|
|
|
||
|
|
CubeMapTexture depthStencil;
|
||
|
|
depthStencil.setStorage(1, TextureFormat::Depth24Stencil8, Vector2i{128});
|
||
|
|
|
||
|
|
Framebuffer framebuffer{{{}, Vector2i{128}}};
|
||
|
|
framebuffer.attachLayeredTexture(Framebuffer::ColorAttachment{0}, color, 0)
|
||
|
|
.attachLayeredTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
|
}
|
||
|
|
|
||
|
|
void FramebufferGLTest::attachLayeredCubeMapTextureArray() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::geometry_shader4>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::geometry_shader4::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_cube_map_array>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not available."));
|
||
|
|
#else
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::geometry_shader>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::geometry_shader::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_cube_map_array>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
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.attachLayeredTexture(Framebuffer::ColorAttachment{0}, color, 0)
|
||
|
|
.attachLayeredTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil, 0);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
|
}
|
||
|
|
|
||
|
|
void FramebufferGLTest::attachLayeredTexture2DMultisampleArray() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::geometry_shader4>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::geometry_shader4::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_multisample>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_multisample::string() + std::string(" is not available."));
|
||
|
|
#else
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::geometry_shader>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::geometry_shader::string() + std::string(" is not available."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_storage_multisample_2d_array>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::OES::texture_storage_multisample_2d_array::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
MultisampleTexture2DArray color;
|
||
|
9 years ago
|
/* Mesa software implementation supports only 1 sample so we have to clamp */
|
||
|
|
color.setStorage(Math::min(4, MultisampleTexture2DArray::maxColorSamples()),
|
||
|
|
TextureFormat::RGBA8, {128, 128, 8});
|
||
|
11 years ago
|
|
||
|
|
MultisampleTexture2DArray depthStencil;
|
||
|
9 years ago
|
/* Mesa software implementation supports only 1 sample so we have to clamp */
|
||
|
|
depthStencil.setStorage(Math::min(4, MultisampleTexture2DArray::maxDepthSamples()),
|
||
|
|
TextureFormat::Depth24Stencil8, {128, 128, 8});
|
||
|
11 years ago
|
|
||
|
|
Framebuffer framebuffer{{{}, Vector2i{128}}};
|
||
|
|
framebuffer.attachLayeredTexture(Framebuffer::ColorAttachment{0}, color)
|
||
|
|
.attachLayeredTexture(Framebuffer::BufferAttachment::DepthStencil, depthStencil);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
void FramebufferGLTest::detach() {
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
|
framebuffer.detach(Framebuffer::ColorAttachment(0))
|
||
|
|
.detach(Framebuffer::BufferAttachment::Depth)
|
||
|
|
.detach(Framebuffer::BufferAttachment::Stencil);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
void FramebufferGLTest::multipleColorOutputs() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#elif defined(MAGNUM_TARGET_GLES2)
|
||
|
8 years ago
|
#ifdef MAGNUM_TARGET_WEBGL
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::WEBGL::draw_buffers>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::WEBGL::draw_buffers::string() + std::string(" is not available."));
|
||
|
|
#else
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::draw_buffers>() &&
|
||
|
|
!Context::current().isExtensionSupported<Extensions::GL::NV::draw_buffers>())
|
||
|
11 years ago
|
CORRADE_SKIP("No required extension available.");
|
||
|
13 years ago
|
#endif
|
||
|
8 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
|
Texture2D color1;
|
||
|
8 years ago
|
color1.setStorage(1,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
TextureFormat::RGBA8,
|
||
|
|
#elif !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
rgbaFormatES2,
|
||
|
|
#else
|
||
|
|
TextureFormat::RGBA,
|
||
|
|
#endif
|
||
|
|
Vector2i(128));
|
||
|
13 years ago
|
|
||
|
|
Texture2D color2;
|
||
|
8 years ago
|
color2.setStorage(1,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
TextureFormat::RGBA8,
|
||
|
|
#elif !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
rgbaFormatES2,
|
||
|
|
#else
|
||
|
|
TextureFormat::RGBA,
|
||
|
|
#endif
|
||
|
|
Vector2i(128));
|
||
|
13 years ago
|
|
||
|
|
Renderbuffer depth;
|
||
|
|
depth.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128));
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
12 years ago
|
framebuffer.attachTexture(Framebuffer::ColorAttachment(0), color1, 0)
|
||
|
|
.attachTexture(Framebuffer::ColorAttachment(1), color2, 0)
|
||
|
13 years ago
|
.attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depth)
|
||
|
|
.mapForDraw({{0, Framebuffer::ColorAttachment(1)},
|
||
|
10 years ago
|
{1, Framebuffer::ColorAttachment(0)},
|
||
|
|
{2, Framebuffer::DrawAttachment::None}});
|
||
|
13 years ago
|
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
13 years ago
|
#ifdef MAGNUM_TARGET_GLES2
|
||
|
10 years ago
|
if(Context::current().isExtensionSupported<Extensions::GL::NV::read_buffer>())
|
||
|
13 years ago
|
#endif
|
||
|
|
{
|
||
|
|
#ifdef MAGNUM_TARGET_GLES2
|
||
|
|
Debug() << "Using" << Extensions::GL::NV::read_buffer::string();
|
||
|
|
#endif
|
||
|
|
framebuffer.mapForRead(Framebuffer::ColorAttachment(1));
|
||
|
|
}
|
||
|
8 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
|
void FramebufferGLTest::clear() {
|
||
|
11 years ago
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
13 years ago
|
Renderbuffer color;
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA8, Vector2i(128));
|
||
|
|
#else
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA4, Vector2i(128));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
/* Separate depth and stencil renderbuffers are not supported (or at least
|
||
|
|
on my NVidia, thus we need to do this juggling with one renderbuffer */
|
||
|
|
Renderbuffer depthStencil;
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
|
||
|
13 years ago
|
#endif
|
||
|
|
{
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
13 years ago
|
Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string();
|
||
|
|
#endif
|
||
|
8 years ago
|
depthStencil.setStorage(
|
||
|
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
RenderbufferFormat::Depth24Stencil8,
|
||
|
|
#else
|
||
|
|
RenderbufferFormat::DepthStencil,
|
||
|
|
#endif
|
||
|
|
Vector2i(128));
|
||
|
13 years ago
|
}
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
13 years ago
|
else depthStencil.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), color)
|
||
|
|
.attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depthStencil);
|
||
|
|
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
|
||
|
13 years ago
|
#endif
|
||
|
|
{
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::BufferAttachment::Stencil, depthStencil);
|
||
|
|
}
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
|
|
||
|
|
framebuffer.clear(FramebufferClear::Color|FramebufferClear::Depth|FramebufferClear::Stencil);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
9 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void FramebufferGLTest::clearColorI() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isVersionSupported(Version::GL300))
|
||
|
|
CORRADE_SKIP("GL 3.0 is not available.");
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer color;
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA8I, Vector2i{16});
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i{16}});
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
|
|
||
|
|
framebuffer.clearColor(0, Vector4i{-124, 67, 37, 17});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
Image2D colorImage = framebuffer.read({{}, Vector2i{1}},
|
||
|
|
{PixelFormat::RGBAInteger, PixelType::Int});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(colorImage.data<Vector4i>()[0], (Vector4i{-124, 67, 37, 17}));
|
||
|
|
}
|
||
|
|
|
||
|
|
void FramebufferGLTest::clearColorUI() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isVersionSupported(Version::GL300))
|
||
|
|
CORRADE_SKIP("GL 3.0 is not available.");
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer color;
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA8UI, Vector2i{16});
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i{16}});
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
|
|
||
|
|
framebuffer.clearColor(0, Vector4ui{240, 67, 37, 17});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
Image2D colorImage = framebuffer.read({{}, Vector2i{1}},
|
||
|
|
{PixelFormat::RGBAInteger, PixelType::UnsignedInt});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(colorImage.data<Vector4ui>()[0], (Vector4ui{240, 67, 37, 17}));
|
||
|
|
}
|
||
|
|
|
||
|
|
void FramebufferGLTest::clearColorF() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isVersionSupported(Version::GL300))
|
||
|
|
CORRADE_SKIP("GL 3.0 is not available.");
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer color;
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA8, Vector2i{16});
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i{16}});
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
|
|
||
|
|
framebuffer.clearColor(0, Math::unpack<Color4>(Color4ub{128, 64, 32, 17}));
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
Image2D colorImage = framebuffer.read({{}, Vector2i{1}},
|
||
|
|
{PixelFormat::RGBA, PixelType::UnsignedByte});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(colorImage.data<Color4ub>()[0], (Color4ub{128, 64, 32, 17}));
|
||
|
|
}
|
||
|
|
|
||
|
|
void FramebufferGLTest::clearDepth() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isVersionSupported(Version::GL300))
|
||
|
|
CORRADE_SKIP("GL 3.0 is not available.");
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer color;
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA8, Vector2i{16});
|
||
|
|
|
||
|
|
/* Separate depth and stencil renderbuffers are not supported (or at least
|
||
|
|
on my NVidia, thus we need to do this juggling with one renderbuffer */
|
||
|
|
Renderbuffer depthStencil;
|
||
|
|
depthStencil.setStorage(RenderbufferFormat::Depth24Stencil8, Vector2i{16});
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i{16}});
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color)
|
||
|
|
.attachRenderbuffer(Framebuffer::BufferAttachment::DepthStencil, depthStencil);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
|
|
||
|
|
framebuffer.clearDepth(Math::unpack<Float, UnsignedShort>(48352));
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
|
if(Context::current().isExtensionSupported<Extensions::GL::NV::read_depth>())
|
||
|
|
#endif
|
||
|
|
{
|
||
|
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
|
Debug() << "Using" << Extensions::GL::NV::read_depth::string();
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Image2D depthImage = framebuffer.read({{}, Vector2i{1}}, {PixelFormat::DepthComponent, PixelType::UnsignedShort});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(depthImage.data<UnsignedShort>()[0], 48352);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void FramebufferGLTest::clearStencil() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isVersionSupported(Version::GL300))
|
||
|
|
CORRADE_SKIP("GL 3.0 is not available.");
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer color;
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA8, Vector2i{16});
|
||
|
|
|
||
|
|
Renderbuffer depthStencil;
|
||
|
|
depthStencil.setStorage(RenderbufferFormat::Depth24Stencil8, Vector2i{16});
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i{16}});
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color)
|
||
|
|
.attachRenderbuffer(Framebuffer::BufferAttachment::DepthStencil, depthStencil);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
|
|
||
|
|
framebuffer.clearStencil(67);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
|
if(Context::current().isExtensionSupported<Extensions::GL::NV::read_stencil>())
|
||
|
|
#endif
|
||
|
|
{
|
||
|
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
|
Debug() << "Using" << Extensions::GL::NV::read_stencil::string();
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Image2D stencilImage = framebuffer.read({{}, Vector2i{1}}, {PixelFormat::StencilIndex, PixelType::UnsignedByte});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(stencilImage.data<UnsignedByte>()[0], 67);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void FramebufferGLTest::clearDepthStencil() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isVersionSupported(Version::GL300))
|
||
|
|
CORRADE_SKIP("GL 3.0 is not available.");
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer color;
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA8, Vector2i{16});
|
||
|
|
|
||
|
|
/* Separate depth and stencil renderbuffers are not supported (or at least
|
||
|
|
on my NVidia, thus we need to do this juggling with one renderbuffer */
|
||
|
|
Renderbuffer depthStencil;
|
||
|
|
depthStencil.setStorage(RenderbufferFormat::Depth24Stencil8, Vector2i{16});
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i{16}});
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment{0}, color)
|
||
|
|
.attachRenderbuffer(Framebuffer::BufferAttachment::DepthStencil, depthStencil);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
|
|
||
|
|
framebuffer.clearDepthStencil(Math::unpack<Float, UnsignedShort>(48352), 67);
|
||
|
|
|
||
|
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
|
if(Context::current().isExtensionSupported<Extensions::GL::NV::read_depth_stencil>())
|
||
|
|
#endif
|
||
|
|
{
|
||
|
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
|
Debug() << "Using" << Extensions::GL::NV::read_depth_stencil::string();
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Image2D depthStencilImage = framebuffer.read({{}, Vector2i{1}}, {PixelFormat::DepthStencil, PixelType::UnsignedInt248});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
/** @todo This will probably fail on different systems */
|
||
|
|
CORRADE_COMPARE(depthStencilImage.data<UnsignedInt>()[0] >> 8, 12378300);
|
||
|
|
CORRADE_COMPARE(depthStencilImage.data<UnsignedByte>()[0], 67);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
13 years ago
|
void FramebufferGLTest::invalidate() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer color;
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA8, Vector2i(128));
|
||
|
|
#else
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA4, Vector2i(128));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer stencil;
|
||
|
|
stencil.setStorage(RenderbufferFormat::StencilIndex8, Vector2i(128));
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), color)
|
||
|
|
.attachRenderbuffer(Framebuffer::BufferAttachment::Stencil, stencil);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
framebuffer.invalidate({Framebuffer::InvalidationAttachment::Depth, Framebuffer::ColorAttachment(0)});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
8 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
12 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
13 years ago
|
void FramebufferGLTest::invalidateSub() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer color;
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA8, Vector2i(128));
|
||
|
|
|
||
|
|
Renderbuffer depth;
|
||
|
|
depth.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128));
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), color)
|
||
|
|
.attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depth);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
|
||
|
|
framebuffer.invalidate({Framebuffer::InvalidationAttachment::Depth, Framebuffer::ColorAttachment(0)},
|
||
|
|
{{32, 16}, {79, 64}});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
12 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
11 years ago
|
namespace {
|
||
|
|
const auto DataStorage = PixelStorage{}.setSkip({0, 16, 0});
|
||
|
|
const std::size_t DataOffset = 16*8;
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
void FramebufferGLTest::read() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer color;
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA8, Vector2i(128));
|
||
|
|
#else
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA4, Vector2i(128));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
/* Separate depth and stencil renderbuffers are not supported (or at least
|
||
|
|
on my NVidia, thus we need to do this juggling with one renderbuffer */
|
||
|
|
Renderbuffer depthStencil;
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
|
||
|
13 years ago
|
#endif
|
||
|
|
{
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
13 years ago
|
Debug() << "Using" << Extensions::GL::OES::packed_depth_stencil::string();
|
||
|
|
#endif
|
||
|
8 years ago
|
depthStencil.setStorage(
|
||
|
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
RenderbufferFormat::Depth24Stencil8,
|
||
|
|
#else
|
||
|
|
RenderbufferFormat::DepthStencil,
|
||
|
|
#endif
|
||
|
|
Vector2i(128));
|
||
|
13 years ago
|
}
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
13 years ago
|
else depthStencil.setStorage(RenderbufferFormat::DepthComponent16, Vector2i(128));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), color)
|
||
|
|
.attachRenderbuffer(Framebuffer::BufferAttachment::Depth, depthStencil);
|
||
|
|
|
||
|
8 years ago
|
#if defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
if(Context::current().isExtensionSupported<Extensions::GL::OES::packed_depth_stencil>())
|
||
|
13 years ago
|
#endif
|
||
|
|
{
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::BufferAttachment::Stencil, depthStencil);
|
||
|
|
}
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
|
||
|
9 years ago
|
Renderer::setClearColor(Math::unpack<Color4>(Color4ub(128, 64, 32, 17)));
|
||
|
|
Renderer::setClearDepth(Math::unpack<Float, UnsignedShort>(48352));
|
||
|
13 years ago
|
Renderer::setClearStencil(67);
|
||
|
|
framebuffer.clear(FramebufferClear::Color|FramebufferClear::Depth|FramebufferClear::Stencil);
|
||
|
|
|
||
|
11 years ago
|
Image2D colorImage = framebuffer.read(Range2Di::fromSize({16, 8}, {8, 16}),
|
||
|
|
{DataStorage, PixelFormat::RGBA, PixelType::UnsignedByte});
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(colorImage.size(), Vector2i(8, 16));
|
||
|
11 years ago
|
CORRADE_COMPARE(colorImage.data().size(), (DataOffset + 8*16)*sizeof(Color4ub));
|
||
|
|
CORRADE_COMPARE(colorImage.data<Color4ub>()[DataOffset], Color4ub(128, 64, 32, 17));
|
||
|
13 years ago
|
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_WEBGL
|
||
|
13 years ago
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(Context::current().isExtensionSupported<Extensions::GL::NV::read_depth>())
|
||
|
13 years ago
|
#endif
|
||
|
|
{
|
||
|
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
|
Debug() << "Using" << Extensions::GL::NV::read_depth::string();
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
Image2D depthImage = framebuffer.read({{}, Vector2i{1}}, {PixelFormat::DepthComponent, PixelType::UnsignedShort});
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(depthImage.data<UnsignedShort>()[0], 48352);
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(Context::current().isExtensionSupported<Extensions::GL::NV::read_stencil>())
|
||
|
13 years ago
|
#endif
|
||
|
|
{
|
||
|
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
|
Debug() << "Using" << Extensions::GL::NV::read_stencil::string();
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
Image2D stencilImage = framebuffer.read({{}, Vector2i{1}}, {PixelFormat::StencilIndex, PixelType::UnsignedByte});
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_COMPARE(stencilImage.data<UnsignedByte>()[0], 67);
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(Context::current().isExtensionSupported<Extensions::GL::NV::read_depth_stencil>())
|
||
|
13 years ago
|
#endif
|
||
|
|
{
|
||
|
|
#ifdef MAGNUM_TARGET_GLES
|
||
|
|
Debug() << "Using" << Extensions::GL::NV::read_depth_stencil::string();
|
||
|
|
#endif
|
||
|
|
|
||
|
11 years ago
|
Image2D depthStencilImage = framebuffer.read({{}, Vector2i{1}}, {PixelFormat::DepthStencil, PixelType::UnsignedInt248});
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
/** @todo This will probably fail on different systems */
|
||
|
|
CORRADE_COMPARE(depthStencilImage.data<UnsignedInt>()[0] >> 8, 12378300);
|
||
|
|
CORRADE_COMPARE(depthStencilImage.data<UnsignedByte>()[0], 67);
|
||
|
|
}
|
||
|
8 years ago
|
#endif
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void FramebufferGLTest::readBuffer() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer color;
|
||
|
|
color.setStorage(RenderbufferFormat::RGBA8, Vector2i(128));
|
||
|
|
|
||
|
|
Renderbuffer depthStencil;
|
||
|
|
depthStencil.setStorage(RenderbufferFormat::Depth24Stencil8, Vector2i(128));
|
||
|
|
|
||
|
|
Framebuffer framebuffer({{}, Vector2i(128)});
|
||
|
|
framebuffer.attachRenderbuffer(Framebuffer::ColorAttachment(0), color)
|
||
|
|
.attachRenderbuffer(Framebuffer::BufferAttachment::DepthStencil, depthStencil);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(framebuffer.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
|
||
|
9 years ago
|
Renderer::setClearColor(Math::unpack<Color4>(Color4ub(128, 64, 32, 17)));
|
||
|
|
Renderer::setClearDepth(Math::unpack<Float, UnsignedShort>(48352));
|
||
|
13 years ago
|
Renderer::setClearStencil(67);
|
||
|
|
framebuffer.clear(FramebufferClear::Color|FramebufferClear::Depth|FramebufferClear::Stencil);
|
||
|
|
|
||
|
11 years ago
|
BufferImage2D colorImage = framebuffer.read(Range2Di::fromSize({16, 8}, {8, 16}),
|
||
|
|
{DataStorage, PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
|
||
|
13 years ago
|
CORRADE_COMPARE(colorImage.size(), Vector2i(8, 16));
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
/** @todo How to test this on ES? */
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
9 years ago
|
auto colorData = colorImage.buffer().data();
|
||
|
|
CORRADE_COMPARE(colorData.size(), (DataOffset + 8*16)*sizeof(Color4ub));
|
||
|
|
CORRADE_COMPARE(Containers::arrayCast<Color4ub>(colorData)[DataOffset], Color4ub(128, 64, 32, 17));
|
||
|
13 years ago
|
#endif
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
10 years ago
|
namespace {
|
||
|
|
constexpr char StorageData[]{
|
||
|
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
||
|
|
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
|
||
|
|
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
||
|
|
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f
|
||
|
|
};
|
||
|
|
|
||
|
|
constexpr char ZeroStorage[4*4*4*6]{};
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void FramebufferGLTest::copyImageTexture1D() {
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
|
||
|
|
Texture2D storage;
|
||
|
|
storage.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
|
||
|
|
|
||
|
|
Framebuffer fb{{{}, Vector2i{4}}};
|
||
|
|
fb.attachTexture(Framebuffer::ColorAttachment{0}, storage, 0);
|
||
|
|
|
||
|
|
Texture1D texture;
|
||
|
|
fb.copyImage(Range2Di::fromSize(Vector2i{1}, {2, 1}), texture, 0, TextureFormat::RGBA8);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(texture.imageSize(0)[0], 2);
|
||
|
|
CORRADE_COMPARE_AS(texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}).release(),
|
||
|
9 years ago
|
(Containers::Array<char>{Containers::InPlaceInit, {0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b}}),
|
||
|
10 years ago
|
TestSuite::Compare::Container);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void FramebufferGLTest::copyImageTexture2D() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Texture2D storage;
|
||
|
|
storage.setStorage(1,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
TextureFormat::RGBA8,
|
||
|
8 years ago
|
#elif !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
rgbaFormatES2,
|
||
|
8 years ago
|
#else
|
||
|
|
TextureFormat::RGBA,
|
||
|
10 years ago
|
#endif
|
||
|
|
Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
|
||
|
|
|
||
|
|
Framebuffer fb{{{}, Vector2i{4}}};
|
||
|
|
fb.attachTexture(Framebuffer::ColorAttachment{0}, storage, 0);
|
||
|
|
|
||
|
|
Texture2D texture;
|
||
|
|
fb.copyImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, 0,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
TextureFormat::RGBA8
|
||
|
8 years ago
|
#elif !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
rgbaFormatES2
|
||
|
8 years ago
|
#else
|
||
|
|
TextureFormat::RGBA
|
||
|
10 years ago
|
#endif
|
||
|
|
);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CORRADE_COMPARE(texture.imageSize(0), Vector2i{2});
|
||
|
|
CORRADE_COMPARE_AS(texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}).release(),
|
||
|
9 years ago
|
(Containers::Array<char>{Containers::InPlaceInit, {
|
||
|
|
0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
|
||
|
|
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b}}),
|
||
|
10 years ago
|
TestSuite::Compare::Container);
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void FramebufferGLTest::copyImageTexture1DArray() {
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_array>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not available."));
|
||
|
|
|
||
|
|
Texture2D storage;
|
||
|
|
storage.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
|
||
|
|
|
||
|
|
Framebuffer fb{{{}, Vector2i{4}}};
|
||
|
|
fb.attachTexture(Framebuffer::ColorAttachment{0}, storage, 0);
|
||
|
|
|
||
|
|
Texture1DArray texture;
|
||
|
|
fb.copyImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, 0, TextureFormat::RGBA8);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(texture.imageSize(0), Vector2i{2});
|
||
|
|
CORRADE_COMPARE_AS(texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}).release(),
|
||
|
9 years ago
|
(Containers::Array<char>{Containers::InPlaceInit, {
|
||
|
|
0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
|
||
|
|
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b}}),
|
||
|
10 years ago
|
TestSuite::Compare::Container);
|
||
|
|
}
|
||
|
|
|
||
|
|
void FramebufferGLTest::copyImageRectangleTexture() {
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not available."));
|
||
|
|
|
||
|
|
Texture2D storage;
|
||
|
|
storage.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
|
||
|
|
|
||
|
|
Framebuffer fb{{{}, Vector2i{4}}};
|
||
|
|
fb.attachTexture(Framebuffer::ColorAttachment{0}, storage, 0);
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
fb.copyImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, TextureFormat::RGBA8);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(texture.imageSize(), Vector2i{2});
|
||
|
|
CORRADE_COMPARE_AS(texture.image({PixelFormat::RGBA, PixelType::UnsignedByte}).release(),
|
||
|
9 years ago
|
(Containers::Array<char>{Containers::InPlaceInit, {
|
||
|
|
0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
|
||
|
|
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b}}),
|
||
|
10 years ago
|
TestSuite::Compare::Container);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void FramebufferGLTest::copyImageCubeMapTexture() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
8 years ago
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
constexpr TextureFormat format = TextureFormat::RGBA8;
|
||
|
|
#elif !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
const TextureFormat format = rgbaFormatES2;
|
||
|
|
#else
|
||
|
|
constexpr TextureFormat format = TextureFormat::RGBA;
|
||
|
|
#endif
|
||
|
|
|
||
|
10 years ago
|
Texture2D storage;
|
||
|
8 years ago
|
storage.setStorage(1, format, Vector2i{4})
|
||
|
10 years ago
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
|
||
|
|
|
||
|
|
Framebuffer fb{{{}, Vector2i{4}}};
|
||
|
|
fb.attachTexture(Framebuffer::ColorAttachment{0}, storage, 0);
|
||
|
|
|
||
|
8 years ago
|
constexpr UnsignedByte Zero[2*2*4]{};
|
||
|
|
|
||
|
10 years ago
|
CubeMapTexture texture;
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::PositiveX, 0, format,
|
||
|
8 years ago
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::NegativeX, 0, format,
|
||
|
8 years ago
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::PositiveY, 0, format,
|
||
|
8 years ago
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::NegativeY, 0, format,
|
||
|
8 years ago
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::PositiveZ, 0, format,
|
||
|
8 years ago
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
8 years ago
|
texture.setImage(CubeMapCoordinate::NegativeZ, 0, format,
|
||
|
8 years ago
|
ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2), Zero});
|
||
|
|
|
||
|
8 years ago
|
fb.copyImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, CubeMapCoordinate::PositiveX, 0, format);
|
||
|
10 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CORRADE_COMPARE(texture.imageSize(0), Vector2i{2});
|
||
|
|
CORRADE_COMPARE_AS(texture.image(CubeMapCoordinate::PositiveX, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}).release(),
|
||
|
9 years ago
|
(Containers::Array<char>{Containers::InPlaceInit, {
|
||
|
|
0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
|
||
|
|
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b}}),
|
||
|
10 years ago
|
TestSuite::Compare::Container);
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void FramebufferGLTest::copySubImageTexture1D() {
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
|
||
|
|
Texture2D storage;
|
||
|
|
storage.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
|
||
|
|
|
||
|
|
Framebuffer fb{{{}, Vector2i{4}}};
|
||
|
|
fb.attachTexture(Framebuffer::ColorAttachment{0}, storage, 0);
|
||
|
|
|
||
|
|
Texture1D texture;
|
||
|
|
texture.setStorage(1, TextureFormat::RGBA8, 4)
|
||
|
|
.setSubImage(0, {}, ImageView1D{PixelFormat::RGBA, PixelType::UnsignedByte, 4, ZeroStorage});
|
||
|
|
fb.copySubImage(Range2Di::fromSize(Vector2i{1}, {2, 1}), texture, 0, 1);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE_AS(texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}).release(),
|
||
|
9 years ago
|
(Containers::Array<char>{Containers::InPlaceInit, {
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x00, 0x00, 0x00, 0x00}}),
|
||
|
10 years ago
|
TestSuite::Compare::Container);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void FramebufferGLTest::copySubImageTexture2D() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Texture2D storage;
|
||
|
|
storage.setStorage(1,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
TextureFormat::RGBA8,
|
||
|
8 years ago
|
#elif !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
rgbaFormatES2,
|
||
|
8 years ago
|
#else
|
||
|
|
TextureFormat::RGBA,
|
||
|
10 years ago
|
#endif
|
||
|
|
Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
|
||
|
|
|
||
|
|
Framebuffer fb{{{}, Vector2i{4}}};
|
||
|
|
fb.attachTexture(Framebuffer::ColorAttachment{0}, storage, 0);
|
||
|
|
|
||
|
|
Texture2D texture;
|
||
|
|
texture.setStorage(1,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
TextureFormat::RGBA8,
|
||
|
8 years ago
|
#elif !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
rgbaFormatES2,
|
||
|
8 years ago
|
#else
|
||
|
|
TextureFormat::RGBA,
|
||
|
10 years ago
|
#endif
|
||
|
|
Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, ZeroStorage});
|
||
|
|
fb.copySubImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, 0, Vector2i{1});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CORRADE_COMPARE_AS(texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}).release(),
|
||
|
9 years ago
|
(Containers::Array<char>{Containers::InPlaceInit, {
|
||
|
10 years ago
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x00, 0x00, 0x00, 0x00,
|
||
|
9 years ago
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}),
|
||
|
10 years ago
|
TestSuite::Compare::Container);
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
|
void FramebufferGLTest::copySubImageTexture3D() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#elif defined(MAGNUM_TARGET_GLES2)
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::OES::texture_3D>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::OES::texture_3D::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Texture2D storage;
|
||
|
|
storage.setStorage(1,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
TextureFormat::RGBA8,
|
||
|
|
#else
|
||
|
|
rgbaFormatES2,
|
||
|
|
#endif
|
||
|
|
Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
|
||
|
|
|
||
|
|
Framebuffer fb{{{}, Vector2i{4}}};
|
||
|
|
fb.attachTexture(Framebuffer::ColorAttachment{0}, storage, 0);
|
||
|
|
|
||
|
|
Texture3D texture;
|
||
|
|
texture.setStorage(1,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
TextureFormat::RGBA8,
|
||
|
|
#else
|
||
|
|
rgbaFormatES2,
|
||
|
|
#endif
|
||
|
|
{4, 4, 2})
|
||
|
|
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, {4, 4, 2}, ZeroStorage});
|
||
|
|
fb.copySubImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, 0, Vector3i{1});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CORRADE_COMPARE_AS(texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}).release(),
|
||
|
9 years ago
|
(Containers::Array<char>{Containers::InPlaceInit, {
|
||
|
10 years ago
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x00, 0x00, 0x00, 0x00,
|
||
|
9 years ago
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}),
|
||
|
10 years ago
|
TestSuite::Compare::Container);
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void FramebufferGLTest::copySubImageTexture1DArray() {
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_array>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not available."));
|
||
|
|
|
||
|
|
Texture2D storage;
|
||
|
|
storage.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
|
||
|
|
|
||
|
|
Framebuffer fb{{{}, Vector2i{4}}};
|
||
|
|
fb.attachTexture(Framebuffer::ColorAttachment{0}, storage, 0);
|
||
|
|
|
||
|
|
Texture1DArray texture;
|
||
|
|
texture.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, ZeroStorage});
|
||
|
|
fb.copySubImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, 0, Vector2i{1});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE_AS(texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}).release(),
|
||
|
9 years ago
|
(Containers::Array<char>{Containers::InPlaceInit, {
|
||
|
10 years ago
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x00, 0x00, 0x00, 0x00,
|
||
|
9 years ago
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}),
|
||
|
10 years ago
|
TestSuite::Compare::Container);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
void FramebufferGLTest::copySubImageTexture2DArray() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_array>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::EXT::texture_array::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Texture2D storage;
|
||
|
|
storage.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
|
||
|
|
|
||
|
|
Framebuffer fb{{{}, Vector2i{4}}};
|
||
|
|
fb.attachTexture(Framebuffer::ColorAttachment{0}, storage, 0);
|
||
|
|
|
||
|
|
Texture2DArray texture;
|
||
|
|
texture.setStorage(1, TextureFormat::RGBA8, {4, 4, 2})
|
||
|
|
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, {4, 4, 2}, ZeroStorage});
|
||
|
|
fb.copySubImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, 0, Vector3i{1});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CORRADE_COMPARE_AS(texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}).release(),
|
||
|
9 years ago
|
(Containers::Array<char>{Containers::InPlaceInit, {
|
||
|
10 years ago
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x00, 0x00, 0x00, 0x00,
|
||
|
9 years ago
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}),
|
||
|
10 years ago
|
TestSuite::Compare::Container);
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
void FramebufferGLTest::copySubImageRectangleTexture() {
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not available."));
|
||
|
|
|
||
|
|
Texture2D storage;
|
||
|
|
storage.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
|
||
|
|
|
||
|
|
Framebuffer fb{{{}, Vector2i{4}}};
|
||
|
|
fb.attachTexture(Framebuffer::ColorAttachment{0}, storage, 0);
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
texture.setStorage(TextureFormat::RGBA8, Vector2i{4})
|
||
|
|
.setSubImage({}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, ZeroStorage});
|
||
|
|
fb.copySubImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, Vector2i{1});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE_AS(texture.image({PixelFormat::RGBA, PixelType::UnsignedByte}).release(),
|
||
|
9 years ago
|
(Containers::Array<char>{Containers::InPlaceInit, {
|
||
|
10 years ago
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x00, 0x00, 0x00, 0x00,
|
||
|
9 years ago
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}),
|
||
|
10 years ago
|
TestSuite::Compare::Container);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
void FramebufferGLTest::copySubImageCubeMapTexture() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Texture2D storage;
|
||
|
|
storage.setStorage(1,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
TextureFormat::RGBA8,
|
||
|
8 years ago
|
#elif !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
rgbaFormatES2,
|
||
|
8 years ago
|
#else
|
||
|
|
TextureFormat::RGBA,
|
||
|
10 years ago
|
#endif
|
||
|
|
Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
|
||
|
|
|
||
|
|
Framebuffer fb{{{}, Vector2i{4}}};
|
||
|
|
fb.attachTexture(Framebuffer::ColorAttachment{0}, storage, 0);
|
||
|
|
|
||
|
|
CubeMapTexture texture;
|
||
|
|
texture.setStorage(1,
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
TextureFormat::RGBA8,
|
||
|
8 years ago
|
#elif !defined(MAGNUM_TARGET_WEBGL)
|
||
|
10 years ago
|
rgbaFormatES2,
|
||
|
8 years ago
|
#else
|
||
|
|
TextureFormat::RGBA,
|
||
|
10 years ago
|
#endif
|
||
|
|
Vector2i{4})
|
||
|
|
.setSubImage(CubeMapCoordinate::NegativeY, 0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, ZeroStorage});
|
||
|
|
fb.copySubImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, 0, {1, 1, 3});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CORRADE_COMPARE_AS(texture.image(CubeMapCoordinate::NegativeY, 0, {PixelFormat::RGBA, PixelType::UnsignedByte}).release(),
|
||
|
9 years ago
|
(Containers::Array<char>{Containers::InPlaceInit, {
|
||
|
10 years ago
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x00, 0x00, 0x00, 0x00,
|
||
|
9 years ago
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}),
|
||
|
10 years ago
|
TestSuite::Compare::Container);
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
|
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
void FramebufferGLTest::copySubImageCubeMapTextureArray() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_cube_map_array>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::texture_cube_map_array::string() + std::string(" is not available."));
|
||
|
|
#else
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_cube_map_array>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::EXT::texture_cube_map_array::string() + std::string(" is not available."));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Texture2D storage;
|
||
|
|
storage.setStorage(1, TextureFormat::RGBA8, Vector2i{4})
|
||
|
|
.setSubImage(0, {}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, StorageData});
|
||
|
|
|
||
|
|
Framebuffer fb{{{}, Vector2i{4}}};
|
||
|
|
fb.attachTexture(Framebuffer::ColorAttachment{0}, storage, 0);
|
||
|
|
|
||
|
|
CubeMapTextureArray texture;
|
||
|
|
texture.setStorage(1, TextureFormat::RGBA8, {4, 4, 6})
|
||
|
|
.setSubImage(0, {}, ImageView3D{PixelFormat::RGBA, PixelType::UnsignedByte, {4, 4, 6}, ZeroStorage});
|
||
|
|
fb.copySubImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}), texture, 0, {1, 1, 3});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
|
CORRADE_COMPARE_AS(texture.image(0, {PixelFormat::RGBA, PixelType::UnsignedByte}).release(),
|
||
|
9 years ago
|
(Containers::Array<char>{Containers::InPlaceInit, {
|
||
|
10 years ago
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||
|
9 years ago
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}),
|
||
|
10 years ago
|
TestSuite::Compare::Container);
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
8 years ago
|
#if !(defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL))
|
||
|
13 years ago
|
void FramebufferGLTest::blit() {
|
||
|
|
#ifndef MAGNUM_TARGET_GLES
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::framebuffer_object>())
|
||
|
13 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::framebuffer_object::string() + std::string(" is not available."));
|
||
|
|
#elif defined(MAGNUM_TARGET_GLES2)
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::NV::framebuffer_blit>() &&
|
||
|
|
!Context::current().isExtensionSupported<Extensions::GL::ANGLE::framebuffer_blit>())
|
||
|
13 years ago
|
CORRADE_SKIP("Required extension is not available.");
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer colorA, colorB;
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
colorA.setStorage(RenderbufferFormat::RGBA8, Vector2i(128));
|
||
|
|
colorB.setStorage(RenderbufferFormat::RGBA8, Vector2i(128));
|
||
|
|
#else
|
||
|
|
colorA.setStorage(RenderbufferFormat::RGBA4, Vector2i(128));
|
||
|
|
colorB.setStorage(RenderbufferFormat::RGBA4, Vector2i(128));
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Framebuffer a({{}, Vector2i(128)}), b({{}, Vector2i(128)});;
|
||
|
|
a.attachRenderbuffer(Framebuffer::ColorAttachment(0), colorA);
|
||
|
|
b.attachRenderbuffer(Framebuffer::ColorAttachment(0), colorB);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(a.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(a.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(b.checkStatus(FramebufferTarget::Read), Framebuffer::Status::Complete);
|
||
|
|
CORRADE_COMPARE(b.checkStatus(FramebufferTarget::Draw), Framebuffer::Status::Complete);
|
||
|
13 years ago
|
|
||
|
|
/* Clear first with some color and second with another */
|
||
|
9 years ago
|
Renderer::setClearColor(Math::unpack<Color4>(Color4ub(128, 64, 32, 17)));
|
||
|
13 years ago
|
a.clear(FramebufferClear::Color);
|
||
|
|
Renderer::setClearColor({});
|
||
|
|
b.clear(FramebufferClear::Color);
|
||
|
|
|
||
|
|
/* The framebuffer should be black before */
|
||
|
11 years ago
|
Image2D imageBefore = b.read({{}, Vector2i{1}}, {PixelFormat::RGBA, PixelType::UnsignedByte});
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(imageBefore.data<Color4ub>()[0], Color4ub());
|
||
|
13 years ago
|
|
||
|
|
/* And have given color after */
|
||
|
12 years ago
|
Framebuffer::blit(a, b, a.viewport(), FramebufferBlit::Color);
|
||
|
11 years ago
|
Image2D imageAfter = b.read({{}, Vector2i{1}}, {PixelFormat::RGBA, PixelType::UnsignedByte});
|
||
|
13 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
11 years ago
|
CORRADE_COMPARE(imageAfter.data<Color4ub>()[0], Color4ub(128, 64, 32, 17));
|
||
|
13 years ago
|
}
|
||
|
8 years ago
|
#endif
|
||
|
13 years ago
|
|
||
|
13 years ago
|
}}
|
||
|
|
|
||
|
9 years ago
|
CORRADE_TEST_MAIN(Magnum::Test::FramebufferGLTest)
|