Browse Source

GL: this Buffer::setStorage() overload wasn't implemented.

Also test it properly and add a check for extension availability. Sigh,
seems like nobody ran this test on an Apple device since this thing got
added in 75d238f50b ...
pull/518/head
Vladimír Vondruš 5 years ago
parent
commit
c0d64b913e
  1. 4
      src/Magnum/GL/Buffer.cpp
  2. 22
      src/Magnum/GL/Test/BufferGLTest.cpp

4
src/Magnum/GL/Buffer.cpp

@ -310,6 +310,10 @@ Buffer& Buffer::setStorage(const Containers::ArrayView<const void> data, const S
(this->*Context::current().state().buffer.storageImplementation)(data, flags);
return *this;
}
Buffer& Buffer::setStorage(const std::size_t size, const StorageFlags flags) {
return setStorage({nullptr, size}, flags);
}
#endif
Int Buffer::size() {

22
src/Magnum/GL/Test/BufferGLTest.cpp

@ -56,6 +56,7 @@ struct BufferGLTest: OpenGLTester {
#ifndef MAGNUM_TARGET_GLES
void storage();
void storagePreinitialized();
#endif
void data();
@ -87,6 +88,7 @@ BufferGLTest::BufferGLTest() {
#ifndef MAGNUM_TARGET_GLES
&BufferGLTest::storage,
&BufferGLTest::storagePreinitialized,
#endif
&BufferGLTest::data,
@ -254,6 +256,26 @@ void BufferGLTest::bindRange() {
#ifndef MAGNUM_TARGET_GLES
void BufferGLTest::storage() {
if(!Context::current().isExtensionSupported<Extensions::ARB::buffer_storage>())
CORRADE_SKIP(Extensions::ARB::buffer_storage::string() << "is not supported.");
Buffer buffer;
constexpr Int data[] = {2, 7, 5, 13, 25};
buffer.setStorage(sizeof(data), Buffer::StorageFlag::DynamicStorage)
.setSubData(0, data);
MAGNUM_VERIFY_NO_GL_ERROR();
CORRADE_COMPARE_AS(Containers::arrayCast<Int>(buffer.data()),
Containers::arrayView(data),
TestSuite::Compare::Container);
}
void BufferGLTest::storagePreinitialized() {
if(!Context::current().isExtensionSupported<Extensions::ARB::buffer_storage>())
CORRADE_SKIP(Extensions::ARB::buffer_storage::string() << "is not supported.");
Buffer buffer;
constexpr Int data[] = {2, 7, 5, 13, 25};

Loading…
Cancel
Save