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.
171 lines
5.7 KiB
171 lines
5.7 KiB
|
13 years ago
|
/*
|
||
|
|
This file is part of Magnum.
|
||
|
|
|
||
|
|
Copyright © 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz>
|
||
|
|
|
||
|
|
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.
|
||
|
|
*/
|
||
|
|
|
||
|
13 years ago
|
#include "Math/Vector2.h"
|
||
|
13 years ago
|
#include "Context.h"
|
||
|
|
#include "Extensions.h"
|
||
|
|
#include "Renderbuffer.h"
|
||
|
13 years ago
|
#include "RenderbufferFormat.h"
|
||
|
13 years ago
|
#include "Test/AbstractOpenGLTester.h"
|
||
|
|
|
||
|
|
namespace Magnum { namespace Test {
|
||
|
|
|
||
|
|
class RenderbufferGLTest: public AbstractOpenGLTester {
|
||
|
|
public:
|
||
|
|
explicit RenderbufferGLTest();
|
||
|
|
|
||
|
13 years ago
|
void construct();
|
||
|
|
void constructCopy();
|
||
|
|
void constructMove();
|
||
|
|
|
||
|
13 years ago
|
void label();
|
||
|
13 years ago
|
|
||
|
|
void setStorage();
|
||
|
|
void setStorageMultisample();
|
||
|
13 years ago
|
};
|
||
|
|
|
||
|
|
RenderbufferGLTest::RenderbufferGLTest() {
|
||
|
13 years ago
|
addTests({&RenderbufferGLTest::construct,
|
||
|
|
&RenderbufferGLTest::constructCopy,
|
||
|
|
&RenderbufferGLTest::constructMove,
|
||
|
|
|
||
|
13 years ago
|
&RenderbufferGLTest::label,
|
||
|
|
|
||
|
|
&RenderbufferGLTest::setStorage,
|
||
|
|
&RenderbufferGLTest::setStorageMultisample});
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
|
void RenderbufferGLTest::construct() {
|
||
|
13 years ago
|
#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
|
||
|
|
|
||
|
13 years ago
|
{
|
||
|
|
const Renderbuffer renderbuffer;
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_VERIFY(renderbuffer.id() > 0);
|
||
|
|
}
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
|
void RenderbufferGLTest::constructCopy() {
|
||
|
13 years ago
|
CORRADE_VERIFY(!(std::is_constructible<Renderbuffer, const Renderbuffer&>{}));
|
||
|
|
/* GCC 4.6 doesn't have std::is_assignable */
|
||
|
|
#ifndef CORRADE_GCC46_COMPATIBILITY
|
||
|
|
CORRADE_VERIFY(!(std::is_assignable<Renderbuffer, const Renderbuffer&>{}));
|
||
|
|
#endif
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
|
void RenderbufferGLTest::constructMove() {
|
||
|
13 years ago
|
#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
|
||
|
|
|
||
|
13 years ago
|
Renderbuffer a;
|
||
|
|
const Int id = a.id();
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_VERIFY(id > 0);
|
||
|
|
|
||
|
|
Renderbuffer b(std::move(a));
|
||
|
|
|
||
|
|
CORRADE_COMPARE(a.id(), 0);
|
||
|
|
CORRADE_COMPARE(b.id(), id);
|
||
|
|
|
||
|
|
Renderbuffer c;
|
||
|
|
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);
|
||
|
13 years ago
|
}
|
||
|
|
|
||
|
|
void RenderbufferGLTest::label() {
|
||
|
13 years ago
|
#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
|
||
|
|
|
||
|
13 years ago
|
/* No-Op version is tested in AbstractObjectGLTest */
|
||
|
|
if(!Context::current()->isExtensionSupported<Extensions::GL::KHR::debug>() &&
|
||
|
|
!Context::current()->isExtensionSupported<Extensions::GL::EXT::debug_label>())
|
||
|
|
CORRADE_SKIP("Required extension is not available");
|
||
|
|
|
||
|
|
Renderbuffer renderbuffer;
|
||
|
|
CORRADE_COMPARE(renderbuffer.label(), "");
|
||
|
|
|
||
|
|
renderbuffer.setLabel("MyRenderbuffer");
|
||
|
|
CORRADE_COMPARE(renderbuffer.label(), "MyRenderbuffer");
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
void RenderbufferGLTest::setStorage() {
|
||
|
|
#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
|
||
|
|
|
||
|
|
Renderbuffer renderbuffer;
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
renderbuffer.setStorage(RenderbufferFormat::RGBA8, {128, 128});
|
||
|
|
#else
|
||
|
|
renderbuffer.setStorage(RenderbufferFormat::RGBA4, {128, 128});
|
||
|
|
#endif
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
|
void RenderbufferGLTest::setStorageMultisample() {
|
||
|
|
#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::ANGLE::framebuffer_multisample>() &&
|
||
|
|
!Context::current()->isExtensionSupported<Extensions::GL::NV::framebuffer_multisample>())
|
||
|
|
CORRADE_SKIP("Required extension is not available.");
|
||
|
|
#endif
|
||
|
|
|
||
|
|
Renderbuffer renderbuffer;
|
||
|
|
|
||
|
|
#ifndef MAGNUM_TARGET_GLES2
|
||
|
|
renderbuffer.setStorageMultisample(Renderbuffer::maxSamples(), RenderbufferFormat::RGBA8, {128, 128});
|
||
|
|
#else
|
||
|
|
renderbuffer.setStorageMultisample(Renderbuffer::maxSamples(), RenderbufferFormat::RGBA4, {128, 128});
|
||
|
|
#endif
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
13 years ago
|
}}
|
||
|
|
|
||
|
|
CORRADE_TEST_MAIN(Magnum::Test::RenderbufferGLTest)
|