Browse Source

DebugTools: make bufferData()/bufferSubData() default to Buffer::subData()

This avoids requiring any Desktop GL extensions and allows forwarding to
Buffer::subData() also on WebGL 2.0 (in a follow-up commit)
gltestlib-symbol-duplication
Pablo Escobar 4 years ago committed by Vladimír Vondruš
parent
commit
588f62d2a0
  1. 9
      src/Magnum/DebugTools/BufferData.cpp
  2. 8
      src/Magnum/DebugTools/BufferData.h
  3. 10
      src/Magnum/DebugTools/Test/BufferDataGLTest.cpp

9
src/Magnum/DebugTools/BufferData.cpp

@ -26,10 +26,13 @@
#include "BufferData.h"
#include <Corrade/Containers/Array.h>
#include <Corrade/Utility/Algorithms.h>
#include "Magnum/GL/Buffer.h"
#if defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_BUILD_DEPRECATED)
#include <Corrade/Utility/Algorithms.h>
#endif
namespace Magnum { namespace DebugTools {
#ifdef MAGNUM_BUILD_DEPRECATED
@ -46,12 +49,16 @@ void bufferSubData(GL::Buffer& buffer, GLintptr offset, GLsizeiptr size, void* o
#endif
Containers::Array<char> bufferSubData(GL::Buffer& buffer, GLintptr offset, GLsizeiptr size) {
#ifndef MAGNUM_TARGET_GLES
return buffer.subData(offset, size);
#else
Containers::Array<char> data{NoInit, std::size_t(size)};
if(size) {
Utility::copy(buffer.mapRead(offset, size), data);
buffer.unmap();
}
return data;
#endif
}
Containers::Array<char> bufferData(GL::Buffer& buffer) {

8
src/Magnum/DebugTools/BufferData.h

@ -60,13 +60,13 @@ namespace Implementation {
@brief Buffer subdata
Emulates @ref GL::Buffer::subData() call on platforms that don't support it
(such as OpenGL ES) by using @ref GL::Buffer::map().
(such as OpenGL ES) by using @ref GL::Buffer::mapRead(). On desktop GL it's
just an alias to @ref GL::Buffer::subData().
@note This function is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default). See
@ref building-features for more information.
@requires_gl30 Extension @gl_extension{ARB,map_buffer_range}
@requires_gles30 Extension @gl_extension{EXT,map_buffer_range} in OpenGL ES
2.0.
@requires_gles Buffer mapping is not available in WebGL.
@ -97,13 +97,13 @@ template<class T> CORRADE_DEPRECATED("use non-templated bufferSubData() and Cont
@brief Buffer data
Emulates @ref GL::Buffer::data() call on platforms that don't support it (such
as OpenGL ES) by using @ref GL::Buffer::map().
as OpenGL ES) by using @ref GL::Buffer::mapRead(). On desktop GL it's just an
alias to @ref GL::Buffer::data().
@note This function is available only if Magnum is compiled with
@ref MAGNUM_TARGET_GL "TARGET_GL" enabled (done by default). See
@ref building-features for more information.
@requires_gl30 Extension @gl_extension{ARB,map_buffer_range}
@requires_gles30 Extension @gl_extension{EXT,map_buffer_range} in OpenGL ES
2.0.
@requires_gles Buffer mapping is not available in WebGL.

10
src/Magnum/DebugTools/Test/BufferDataGLTest.cpp

@ -49,10 +49,7 @@ BufferDataGLTest::BufferDataGLTest() {
constexpr Int Data[] = {2, 7, 5, 13, 25};
void BufferDataGLTest::data() {
#ifndef MAGNUM_TARGET_GLES
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::map_buffer_range>())
CORRADE_SKIP(GL::Extensions::ARB::map_buffer_range::string() << "is not supported.");
#elif defined(MAGNUM_TARGET_GLES2)
#ifdef MAGNUM_TARGET_GLES2
if(!GL::Context::current().isExtensionSupported<GL::Extensions::EXT::map_buffer_range>())
CORRADE_SKIP(GL::Extensions::EXT::map_buffer_range::string() << "is not supported.");
#endif
@ -68,10 +65,7 @@ void BufferDataGLTest::data() {
}
void BufferDataGLTest::subData() {
#ifndef MAGNUM_TARGET_GLES
if(!GL::Context::current().isExtensionSupported<GL::Extensions::ARB::map_buffer_range>())
CORRADE_SKIP(GL::Extensions::ARB::map_buffer_range::string() << "is not supported.");
#elif defined(MAGNUM_TARGET_GLES2)
#ifdef MAGNUM_TARGET_GLES2
if(!GL::Context::current().isExtensionSupported<GL::Extensions::EXT::map_buffer_range>())
CORRADE_SKIP(GL::Extensions::EXT::map_buffer_range::string() << "is not supported.");
#endif

Loading…
Cancel
Save