Browse Source

Allow method chaining on *Framebuffer::clear().

In the future, when I get to implement proper DSA clearing, this won't
change currently bound framebuffer and thus it might be useful to be
able to call bind() right after, e.g.:

    framebuffer.clear(FramebufferClear::Color)
        .bind(FramebufferTarget::ReadDraw);
pull/87/head
Vladimír Vondruš 11 years ago
parent
commit
371700097b
  1. 4
      src/Magnum/AbstractFramebuffer.cpp
  2. 3
      src/Magnum/AbstractFramebuffer.h
  3. 4
      src/Magnum/DefaultFramebuffer.h
  4. 4
      src/Magnum/Framebuffer.h

4
src/Magnum/AbstractFramebuffer.cpp

@ -221,13 +221,15 @@ void AbstractFramebuffer::setViewportInternal() {
glViewport(_viewport.left(), _viewport.bottom(), _viewport.sizeX(), _viewport.sizeY()); glViewport(_viewport.left(), _viewport.bottom(), _viewport.sizeX(), _viewport.sizeY());
} }
void AbstractFramebuffer::clear(FramebufferClearMask mask) { AbstractFramebuffer& AbstractFramebuffer::clear(FramebufferClearMask mask) {
#ifndef MAGNUM_TARGET_GLES2 #ifndef MAGNUM_TARGET_GLES2
bindInternal(FramebufferTarget::Draw); bindInternal(FramebufferTarget::Draw);
#else #else
bindInternal(Context::current()->state().framebuffer->drawTarget); bindInternal(Context::current()->state().framebuffer->drawTarget);
#endif #endif
glClear(GLbitfield(mask)); glClear(GLbitfield(mask));
return *this;
} }
void AbstractFramebuffer::read(const Range2Di& rectangle, Image2D& image) { void AbstractFramebuffer::read(const Range2Di& rectangle, Image2D& image) {

3
src/Magnum/AbstractFramebuffer.h

@ -284,6 +284,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
/** /**
* @brief Clear specified buffers in framebuffer * @brief Clear specified buffers in framebuffer
* @param mask Which buffers to clear * @param mask Which buffers to clear
* @return Reference to self (for method chaining)
* *
* To improve performance you can also use * To improve performance you can also use
* @ref DefaultFramebuffer::invalidate() / @ref Framebuffer::invalidate() * @ref DefaultFramebuffer::invalidate() / @ref Framebuffer::invalidate()
@ -293,7 +294,7 @@ class MAGNUM_EXPORT AbstractFramebuffer {
* @ref Renderer::setClearStencil(), @fn_gl{BindFramebuffer}, * @ref Renderer::setClearStencil(), @fn_gl{BindFramebuffer},
* @fn_gl{Clear} * @fn_gl{Clear}
*/ */
void clear(FramebufferClearMask mask); AbstractFramebuffer& clear(FramebufferClearMask mask);
/** /**
* @brief Read block of pixels from framebuffer to image * @brief Read block of pixels from framebuffer to image

4
src/Magnum/DefaultFramebuffer.h

@ -432,6 +432,10 @@ class MAGNUM_EXPORT DefaultFramebuffer: public AbstractFramebuffer {
AbstractFramebuffer::setViewport(rectangle); AbstractFramebuffer::setViewport(rectangle);
return *this; return *this;
} }
DefaultFramebuffer& clear(FramebufferClearMask mask) {
AbstractFramebuffer::clear(mask);
return *this;
}
#endif #endif
private: private:

4
src/Magnum/Framebuffer.h

@ -650,6 +650,10 @@ class MAGNUM_EXPORT Framebuffer: public AbstractFramebuffer, public AbstractObje
AbstractFramebuffer::setViewport(rectangle); AbstractFramebuffer::setViewport(rectangle);
return *this; return *this;
} }
Framebuffer& clear(FramebufferClearMask mask) {
AbstractFramebuffer::clear(mask);
return *this;
}
#endif #endif
private: private:

Loading…
Cancel
Save