Browse Source

GL: create the buffer passed to setBuffer() if it's not already.

pull/370/head
Vladimír Vondruš 7 years ago
parent
commit
7b43ab5fc2
  1. 5
      doc/changelog.dox
  2. 2
      src/Magnum/GL/Buffer.cpp
  3. 7
      src/Magnum/GL/Buffer.h
  4. 2
      src/Magnum/GL/BufferTexture.cpp

5
doc/changelog.dox

@ -579,6 +579,11 @@ See also:
@fn_gl{GetString} returning a @cpp nullptr @ce
- @ref GL::Texture::imageSize() was present on WebGL 2 by mistake (see
[mosra/magnum#365](https://github.com/mosra/magnum/pull/365))
- @ref GL::BufferTexture::setBuffer() now creates the passed buffer if not
already (and if it was not created by @fn_gl{CreateBuffers}). Before that,
passing a freshly created @ref GL::Buffer to it was causing
@ref GL::Renderer::Error::InvalidOperation on systems without
@gl_extension{ARB,direct_state_access}.
@subsection changelog-latest-docs Documentation

2
src/Magnum/GL/Buffer.cpp

@ -210,7 +210,7 @@ void Buffer::setTargetHintImplementationSwiftShader(const TargetHint hint) {
}
#endif
inline void Buffer::createIfNotAlready() {
void Buffer::createIfNotAlready() {
if(_flags & ObjectFlag::Created) return;
/* glGen*() does not create the object, just reserves the name. Some

7
src/Magnum/GL/Buffer.h

@ -221,8 +221,6 @@ by OpenGL in order to preserve the data. If running on OpenGL ES or extension
functions do nothing.
*/
class MAGNUM_GL_EXPORT Buffer: public AbstractObject {
friend Implementation::BufferState;
public:
/**
* @brief Buffer target
@ -1155,6 +1153,11 @@ class MAGNUM_GL_EXPORT Buffer: public AbstractObject {
void bindInternal(TargetHint target) { bindInternal(target, this); }
private:
friend Implementation::BufferState;
#if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL)
friend BufferTexture; /* calls createIfNotAlready() */
#endif
static void bindInternal(TargetHint hint, Buffer* buffer);
TargetHint MAGNUM_GL_LOCAL bindSomewhereInternal(TargetHint hint);

2
src/Magnum/GL/BufferTexture.cpp

@ -79,11 +79,13 @@ Int BufferTexture::size() {
}
BufferTexture& BufferTexture::setBuffer(const BufferTextureFormat internalFormat, Buffer& buffer) {
buffer.createIfNotAlready();
(this->*Context::current().state().texture->setBufferImplementation)(internalFormat, buffer);
return *this;
}
BufferTexture& BufferTexture::setBuffer(const BufferTextureFormat internalFormat, Buffer& buffer, const GLintptr offset, const GLsizeiptr size) {
buffer.createIfNotAlready();
(this->*Context::current().state().texture->setBufferRangeImplementation)(internalFormat, buffer, offset, size);
return *this;
}

Loading…
Cancel
Save