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.
517 lines
20 KiB
517 lines
20 KiB
|
12 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>
|
||
|
|
|
||
|
|
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.
|
||
|
|
*/
|
||
|
|
|
||
|
11 years ago
|
#include <Corrade/Containers/Array.h>
|
||
|
12 years ago
|
#include <Corrade/TestSuite/Compare/Container.h>
|
||
|
|
|
||
|
9 years ago
|
#include "Magnum/Context.h"
|
||
|
|
#include "Magnum/Extensions.h"
|
||
|
12 years ago
|
#include "Magnum/BufferImage.h"
|
||
|
|
#include "Magnum/Image.h"
|
||
|
10 years ago
|
#include "Magnum/ImageFormat.h"
|
||
|
9 years ago
|
#include "Magnum/OpenGLTester.h"
|
||
|
11 years ago
|
#include "Magnum/PixelFormat.h"
|
||
|
12 years ago
|
#include "Magnum/RectangleTexture.h"
|
||
|
|
#include "Magnum/TextureFormat.h"
|
||
|
11 years ago
|
#include "Magnum/Math/Color.h"
|
||
|
11 years ago
|
#include "Magnum/Math/Range.h"
|
||
|
9 years ago
|
#include "Magnum/OpenGLTester.h"
|
||
|
12 years ago
|
|
||
|
|
namespace Magnum { namespace Test {
|
||
|
|
|
||
|
9 years ago
|
struct RectangleTextureGLTest: OpenGLTester {
|
||
|
11 years ago
|
explicit RectangleTextureGLTest();
|
||
|
12 years ago
|
|
||
|
11 years ago
|
void construct();
|
||
|
11 years ago
|
void wrap();
|
||
|
|
|
||
|
11 years ago
|
void bind();
|
||
|
10 years ago
|
void bindImage();
|
||
|
12 years ago
|
|
||
|
11 years ago
|
void sampling();
|
||
|
|
void samplingSRGBDecode();
|
||
|
|
void samplingBorderInteger();
|
||
|
|
void samplingSwizzle();
|
||
|
|
void samplingDepthStencilMode();
|
||
|
12 years ago
|
|
||
|
11 years ago
|
void storage();
|
||
|
12 years ago
|
|
||
|
11 years ago
|
void image();
|
||
|
11 years ago
|
void compressedImage();
|
||
|
11 years ago
|
void imageBuffer();
|
||
|
11 years ago
|
void compressedImageBuffer();
|
||
|
11 years ago
|
void subImage();
|
||
|
11 years ago
|
void compressedSubImage();
|
||
|
11 years ago
|
void subImageBuffer();
|
||
|
11 years ago
|
void compressedSubImageBuffer();
|
||
|
11 years ago
|
void subImageQuery();
|
||
|
11 years ago
|
void compressedSubImageQuery();
|
||
|
11 years ago
|
void subImageQueryBuffer();
|
||
|
11 years ago
|
void compressedSubImageQueryBuffer();
|
||
|
12 years ago
|
|
||
|
11 years ago
|
void invalidateImage();
|
||
|
|
void invalidateSubImage();
|
||
|
12 years ago
|
};
|
||
|
|
|
||
|
9 years ago
|
namespace {
|
||
|
|
constexpr UnsignedByte Data[]{
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
||
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
|
||
|
|
|
||
|
|
enum: std::size_t { PixelStorageDataCount = 2 };
|
||
|
|
|
||
|
|
const struct {
|
||
|
|
const char* name;
|
||
|
|
Containers::ArrayView<const UnsignedByte> data;
|
||
|
|
PixelStorage storage;
|
||
|
|
Containers::ArrayView<const UnsignedByte> dataSparse;
|
||
|
|
std::size_t offset;
|
||
|
|
} PixelStorageData[PixelStorageDataCount]{
|
||
|
|
{"default pixel storage",
|
||
|
|
Containers::arrayView(Data).suffix(8), {},
|
||
|
|
Containers::arrayView(Data).suffix(8), 0},
|
||
|
|
#if !defined(MAGNUM_TARGET_GLES2) || !defined(MAGNUM_TARGET_WEBGL)
|
||
|
|
{"skip Y",
|
||
|
|
Containers::arrayView(Data).suffix(8), PixelStorage{}.setSkip({0, 1, 0}),
|
||
|
9 years ago
|
Containers::arrayView(Data), 8}
|
||
|
9 years ago
|
#endif
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
RectangleTextureGLTest::RectangleTextureGLTest() {
|
||
|
|
addTests({&RectangleTextureGLTest::construct,
|
||
|
11 years ago
|
&RectangleTextureGLTest::wrap,
|
||
|
|
|
||
|
12 years ago
|
&RectangleTextureGLTest::bind,
|
||
|
10 years ago
|
&RectangleTextureGLTest::bindImage,
|
||
|
12 years ago
|
|
||
|
12 years ago
|
&RectangleTextureGLTest::sampling,
|
||
|
12 years ago
|
&RectangleTextureGLTest::samplingSRGBDecode,
|
||
|
12 years ago
|
&RectangleTextureGLTest::samplingBorderInteger,
|
||
|
12 years ago
|
&RectangleTextureGLTest::samplingSwizzle,
|
||
|
12 years ago
|
&RectangleTextureGLTest::samplingDepthStencilMode,
|
||
|
12 years ago
|
|
||
|
9 years ago
|
&RectangleTextureGLTest::storage});
|
||
|
12 years ago
|
|
||
|
9 years ago
|
addInstancedTests({
|
||
|
|
&RectangleTextureGLTest::image,
|
||
|
|
&RectangleTextureGLTest::imageBuffer,
|
||
|
|
&RectangleTextureGLTest::subImage,
|
||
|
|
&RectangleTextureGLTest::subImageBuffer,
|
||
|
|
&RectangleTextureGLTest::subImageQuery,
|
||
|
|
&RectangleTextureGLTest::subImageQueryBuffer},
|
||
|
|
PixelStorageDataCount);
|
||
|
12 years ago
|
|
||
|
9 years ago
|
addTests({&RectangleTextureGLTest::compressedImage,
|
||
|
|
&RectangleTextureGLTest::compressedImageBuffer,
|
||
|
11 years ago
|
&RectangleTextureGLTest::compressedSubImage,
|
||
|
|
&RectangleTextureGLTest::compressedSubImageBuffer,
|
||
|
11 years ago
|
&RectangleTextureGLTest::compressedSubImageQuery,
|
||
|
|
&RectangleTextureGLTest::compressedSubImageQueryBuffer,
|
||
|
12 years ago
|
|
||
|
12 years ago
|
&RectangleTextureGLTest::invalidateImage,
|
||
|
|
&RectangleTextureGLTest::invalidateSubImage});
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void RectangleTextureGLTest::construct() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
{
|
||
|
|
RectangleTexture texture;
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
CORRADE_VERIFY(texture.id() > 0);
|
||
|
|
}
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
11 years ago
|
void RectangleTextureGLTest::wrap() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
GLuint id;
|
||
|
|
glGenTextures(1, &id);
|
||
|
|
|
||
|
|
/* Releasing won't delete anything */
|
||
|
|
{
|
||
|
|
auto texture = RectangleTexture::wrap(id, ObjectFlag::DeleteOnDestruction);
|
||
|
|
CORRADE_COMPARE(texture.release(), id);
|
||
|
|
}
|
||
|
|
|
||
|
|
/* ...so we can wrap it again */
|
||
|
|
RectangleTexture::wrap(id);
|
||
|
|
glDeleteTextures(1, &id);
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void RectangleTextureGLTest::bind() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
texture.bind(15);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
12 years ago
|
|
||
|
|
AbstractTexture::unbind(15);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
12 years ago
|
|
||
|
|
AbstractTexture::bind(7, {&texture, nullptr, &texture});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
12 years ago
|
|
||
|
|
AbstractTexture::unbind(7, 3);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
10 years ago
|
void RectangleTextureGLTest::bindImage() {
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::shader_image_load_store>())
|
||
|
|
CORRADE_SKIP(Extensions::GL::ARB::shader_image_load_store::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
texture.setStorage(TextureFormat::RGBA8, Vector2i{32})
|
||
|
|
.bindImage(2, ImageAccess::ReadWrite, ImageFormat::RGBA8);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
AbstractTexture::unbindImage(2);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
AbstractTexture::bindImages(1, {&texture, nullptr, &texture});
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
AbstractTexture::unbindImages(1, 3);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void RectangleTextureGLTest::sampling() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
texture.setMinificationFilter(Sampler::Filter::Linear)
|
||
|
|
.setMagnificationFilter(Sampler::Filter::Linear)
|
||
|
|
.setWrapping(Sampler::Wrapping::ClampToBorder)
|
||
|
|
.setBorderColor(Color3(0.5f))
|
||
|
12 years ago
|
.setMaxAnisotropy(Sampler::maxMaxAnisotropy())
|
||
|
|
.setCompareMode(Sampler::CompareMode::CompareRefToTexture)
|
||
|
|
.setCompareFunction(Sampler::CompareFunction::GreaterOrEqual);
|
||
|
12 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void RectangleTextureGLTest::samplingSRGBDecode() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_sRGB_decode>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::texture_sRGB_decode::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
texture.setSRGBDecode(false);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void RectangleTextureGLTest::samplingBorderInteger() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::EXT::texture_integer>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::EXT::texture_integer::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture a;
|
||
|
|
a.setWrapping(Sampler::Wrapping::ClampToBorder)
|
||
|
|
.setBorderColor(Vector4i(1, 56, 78, -2));
|
||
|
|
RectangleTexture b;
|
||
|
|
b.setWrapping(Sampler::Wrapping::ClampToBorder)
|
||
|
|
.setBorderColor(Vector4ui(35, 56, 78, 15));
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void RectangleTextureGLTest::samplingSwizzle() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_swizzle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_swizzle::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
texture.setSwizzle<'b', 'g', 'r', '0'>();
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void RectangleTextureGLTest::samplingDepthStencilMode() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::stencil_texturing>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::stencil_texturing::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
texture.setDepthStencilMode(Sampler::DepthStencilMode::StencilIndex);
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void RectangleTextureGLTest::storage() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
texture.setStorage(TextureFormat::RGBA8, Vector2i(32));
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(texture.imageSize(), Vector2i(32));
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void RectangleTextureGLTest::image() {
|
||
|
9 years ago
|
setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
11 years ago
|
texture.setImage(TextureFormat::RGBA8, ImageView2D{
|
||
|
9 years ago
|
PixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2),
|
||
|
|
PixelStorageData[testCaseInstanceId()].dataSparse});
|
||
|
12 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
Image2D image = texture.image({PixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte});
|
||
|
12 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(image.size(), Vector2i(2));
|
||
|
9 years ago
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).suffix(PixelStorageData[testCaseInstanceId()].offset),
|
||
|
|
PixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void RectangleTextureGLTest::imageBuffer() {
|
||
|
9 years ago
|
setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
11 years ago
|
texture.setImage(TextureFormat::RGBA8, BufferImage2D{
|
||
|
9 years ago
|
PixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2),
|
||
|
|
PixelStorageData[testCaseInstanceId()].dataSparse,
|
||
|
|
BufferUsage::StaticDraw});
|
||
|
12 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
9 years ago
|
BufferImage2D image = texture.image({PixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
|
||
|
9 years ago
|
const auto imageData = image.buffer().data();
|
||
|
12 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(image.size(), Vector2i(2));
|
||
|
9 years ago
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(imageData).suffix(PixelStorageData[testCaseInstanceId()].offset),
|
||
|
9 years ago
|
PixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
namespace {
|
||
|
9 years ago
|
constexpr UnsignedByte Zero[4*4*4]{};
|
||
|
|
constexpr UnsignedByte SubDataComplete[]{
|
||
|
11 years ago
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0, 0, 0, 0,
|
||
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||
|
|
};
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void RectangleTextureGLTest::subImage() {
|
||
|
9 years ago
|
setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
texture.setImage(TextureFormat::RGBA8,
|
||
|
11 years ago
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
|
||
|
11 years ago
|
texture.setSubImage(Vector2i(1), ImageView2D{
|
||
|
9 years ago
|
PixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2),
|
||
|
|
PixelStorageData[testCaseInstanceId()].dataSparse});
|
||
|
12 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
11 years ago
|
Image2D image = texture.image({PixelFormat::RGBA, PixelType::UnsignedByte});
|
||
|
12 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(image.size(), Vector2i(4));
|
||
|
9 years ago
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()),
|
||
|
|
Containers::arrayView(SubDataComplete), TestSuite::Compare::Container);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
12 years ago
|
void RectangleTextureGLTest::subImageBuffer() {
|
||
|
9 years ago
|
setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
texture.setImage(TextureFormat::RGBA8,
|
||
|
11 years ago
|
ImageView2D(PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(4), Zero));
|
||
|
11 years ago
|
texture.setSubImage(Vector2i(1), BufferImage2D{
|
||
|
9 years ago
|
PixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i(2),
|
||
|
|
PixelStorageData[testCaseInstanceId()].dataSparse,
|
||
|
|
BufferUsage::StaticDraw});
|
||
|
12 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
11 years ago
|
BufferImage2D image = texture.image({PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
|
||
|
9 years ago
|
const auto imageData = image.buffer().data();
|
||
|
12 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(image.size(), Vector2i(4));
|
||
|
9 years ago
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(imageData),
|
||
|
|
Containers::arrayView(SubDataComplete),
|
||
|
9 years ago
|
TestSuite::Compare::Container);
|
||
|
12 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void RectangleTextureGLTest::subImageQuery() {
|
||
|
9 years ago
|
setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::get_texture_sub_image>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
texture.setStorage(TextureFormat::RGBA8, Vector2i{4})
|
||
|
11 years ago
|
.setSubImage({}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, SubDataComplete});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
11 years ago
|
Image2D image = texture.subImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}),
|
||
|
9 years ago
|
{PixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(image.size(), Vector2i{2});
|
||
|
9 years ago
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(image.data()).suffix(PixelStorageData[testCaseInstanceId()].offset),
|
||
|
|
PixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void RectangleTextureGLTest::subImageQueryBuffer() {
|
||
|
9 years ago
|
setTestCaseDescription(PixelStorageData[testCaseInstanceId()].name);
|
||
|
|
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::get_texture_sub_image>())
|
||
|
11 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::get_texture_sub_image::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
texture.setStorage(TextureFormat::RGBA8, Vector2i{4})
|
||
|
11 years ago
|
.setSubImage({}, ImageView2D{PixelFormat::RGBA, PixelType::UnsignedByte, Vector2i{4}, SubDataComplete});
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
11 years ago
|
BufferImage2D image = texture.subImage(Range2Di::fromSize(Vector2i{1}, Vector2i{2}),
|
||
|
9 years ago
|
{PixelStorageData[testCaseInstanceId()].storage,
|
||
|
|
PixelFormat::RGBA, PixelType::UnsignedByte}, BufferUsage::StaticRead);
|
||
|
9 years ago
|
const auto imageData = image.buffer().data();
|
||
|
11 years ago
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
|
||
|
|
CORRADE_COMPARE(image.size(), Vector2i{2});
|
||
|
9 years ago
|
CORRADE_COMPARE_AS(Containers::arrayCast<UnsignedByte>(imageData).suffix(PixelStorageData[testCaseInstanceId()].offset),
|
||
|
9 years ago
|
PixelStorageData[testCaseInstanceId()].data,
|
||
|
|
TestSuite::Compare::Container);
|
||
|
|
}
|
||
|
|
|
||
|
|
void RectangleTextureGLTest::compressedImage() {
|
||
|
|
CORRADE_SKIP("No rectangle texture compression format exists.");
|
||
|
|
}
|
||
|
|
|
||
|
|
void RectangleTextureGLTest::compressedImageBuffer() {
|
||
|
|
CORRADE_SKIP("No rectangle texture compression format exists.");
|
||
|
|
}
|
||
|
|
|
||
|
|
void RectangleTextureGLTest::compressedSubImage() {
|
||
|
|
CORRADE_SKIP("No rectangle texture compression format exists.");
|
||
|
|
}
|
||
|
|
|
||
|
|
void RectangleTextureGLTest::compressedSubImageBuffer() {
|
||
|
|
CORRADE_SKIP("No rectangle texture compression format exists.");
|
||
|
|
}
|
||
|
|
|
||
|
|
void RectangleTextureGLTest::compressedSubImageQuery() {
|
||
|
|
CORRADE_SKIP("No rectangle texture compression format exists.");
|
||
|
11 years ago
|
}
|
||
|
|
|
||
|
11 years ago
|
void RectangleTextureGLTest::compressedSubImageQueryBuffer() {
|
||
|
|
CORRADE_SKIP("No rectangle texture compression format exists.");
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void RectangleTextureGLTest::invalidateImage() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
texture.setStorage(TextureFormat::RGBA8, Vector2i(32));
|
||
|
|
texture.invalidateImage();
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
12 years ago
|
void RectangleTextureGLTest::invalidateSubImage() {
|
||
|
10 years ago
|
if(!Context::current().isExtensionSupported<Extensions::GL::ARB::texture_rectangle>())
|
||
|
12 years ago
|
CORRADE_SKIP(Extensions::GL::ARB::texture_rectangle::string() + std::string(" is not supported."));
|
||
|
|
|
||
|
|
RectangleTexture texture;
|
||
|
|
texture.setStorage(TextureFormat::RGBA8, Vector2i(32));
|
||
|
|
texture.invalidateSubImage(Vector2i(4), Vector2i(16));
|
||
|
|
|
||
|
|
MAGNUM_VERIFY_NO_ERROR();
|
||
|
|
}
|
||
|
|
|
||
|
|
}}
|
||
|
|
|
||
|
9 years ago
|
CORRADE_TEST_MAIN(Magnum::Test::RectangleTextureGLTest)
|