Browse Source

Removed parameter-less clear() from Framebuffer.

Automatic behavior could cause harm, as the stencil/depth test could be
temporarily disabled for some parts of the scene (but enabled for the
rest), causing clear() to leave stencil/depth buffer untouched.
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
685be07a8f
  1. 15
      src/Framebuffer.cpp
  2. 19
      src/Framebuffer.h

15
src/Framebuffer.cpp

@ -17,21 +17,6 @@
namespace Magnum {
Framebuffer::ClearMask Framebuffer::clearMask = Framebuffer::Clear::Color;
void Framebuffer::setFeature(Feature feature, bool enabled) {
/* Enable or disable the feature */
enabled ? glEnable(static_cast<GLenum>(feature)) : glDisable(static_cast<GLenum>(feature));
/* Update clear mask, if needed */
ClearMask clearMaskChange;
if(feature == Feature::DepthTest) clearMaskChange = Clear::Depth;
else if(feature == Feature::StencilTest) clearMaskChange = Clear::Stencil;
else return;
enabled ? clearMask |= clearMaskChange : clearMask &= ~clearMaskChange;
}
#ifndef MAGNUM_TARGET_GLES
void Framebuffer::mapDefaultForDraw(std::initializer_list<DefaultDrawAttachment> attachments) {
GLenum* _attachments = new GLenum[attachments.size()];

19
src/Framebuffer.h

@ -86,7 +86,9 @@ class MAGNUM_EXPORT Framebuffer {
};
/** @brief Set feature */
static void setFeature(Feature feature, bool enabled);
inline static void setFeature(Feature feature, bool enabled) {
enabled ? glEnable(static_cast<GLenum>(feature)) : glDisable(static_cast<GLenum>(feature));
}
/**
* @brief Set viewport size
@ -115,21 +117,10 @@ class MAGNUM_EXPORT Framebuffer {
typedef Corrade::Containers::EnumSet<Clear, GLbitfield> ClearMask; /**< @brief Mask for clearing */
/**
* @brief Clear framebuffer
*
* Clears color buffer, depth and stencil buffer in currently active
* framebuffer. If depth or stencil test is not enabled, it doesn't
* clear these buffers.
*
* @see setFeature(), clear(ClearMask)
*/
inline static void clear() { glClear(static_cast<GLbitfield>(clearMask)); }
/**
* @brief Clear specified buffers in framebuffer
*
* @see clear()
* @see clear(), setClearColor(), setClearDepth(), setClearStencil()
* @todo Clearing only given draw buffer
*/
inline static void clear(ClearMask mask) { glClear(static_cast<GLbitfield>(mask)); }
@ -1108,8 +1099,6 @@ class MAGNUM_EXPORT Framebuffer {
/*@}*/
private:
static ClearMask clearMask;
GLuint framebuffer;
};

Loading…
Cancel
Save