Added ClippingMask class, for clipping with scissor test, clip planes and stencil test.

Fixed some minor problems.

--HG--
branch : dev
This commit is contained in:
Martí­n Lucas Golini
2017-03-30 01:17:11 -03:00
parent 12c74347ac
commit e09b07ecc0
24 changed files with 835 additions and 643 deletions

View File

@@ -6,7 +6,7 @@
namespace EE { namespace Graphics {
class ArcDrawable : public PrimitiveDrawable {
class EE_API ArcDrawable : public PrimitiveDrawable {
public:
ArcDrawable();

View File

@@ -5,7 +5,7 @@
namespace EE { namespace Graphics {
class CircleDrawable : public ArcDrawable {
class EE_API CircleDrawable : public ArcDrawable {
public:
CircleDrawable();

View File

@@ -7,7 +7,7 @@ namespace EE { namespace Graphics {
class VertexBuffer;
class PrimitiveDrawable : public Drawable {
class EE_API PrimitiveDrawable : public Drawable {
public:
PrimitiveDrawable( EE_DRAWABLE_TYPE drawableType );
@@ -36,7 +36,6 @@ class PrimitiveDrawable : public Drawable {
EE_FILL_MODE mFillMode;
EE_BLEND_MODE mBlendMode;
Float mLineWidth;
Vector2f mPosition;
bool mNeedsUpdate;
bool mRecreateVertexBuffer;
VertexBuffer * mVertexBuffer;

View File

@@ -6,7 +6,7 @@
namespace EE { namespace Graphics {
class RectangleDrawable : public PrimitiveDrawable {
class EE_API RectangleDrawable : public PrimitiveDrawable {
public:
RectangleDrawable();

View File

@@ -0,0 +1,65 @@
#ifndef EE_GRAPHICS_CLIPPINGMASK_HPP
#define EE_GRAPHICS_CLIPPINGMASK_HPP
#include <eepp/core.hpp>
#include <eepp/graphics/drawable.hpp>
#include <eepp/math/rect.hpp>
#include <list>
namespace EE { namespace Graphics {
class EE_API ClippingMask {
public:
enum Mode {
Inclusive,
Exclusive
};
/** Set the current Clipping area ( default the entire window, SCISSOR TEST ). */
void clipEnable( const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height );
/** Disable the Clipping area */
void clipDisable();
/** Clip the area with a plane. */
void clipPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height );
/** Disable the clip plane area. */
void clipPlaneDisable();
std::size_t getMaskCount() const;
const Drawable*& operator [](std::size_t index);
const Drawable* const& operator [](std::size_t index) const;
void clearMasks();
void appendMask(const Drawable& drawable);
void removeMask(const Drawable& drawable);
Mode getMaskMode() const;
void setMaskMode(Mode theMode);
void stencilMaskEnable();
void stencilMaskDisable( bool clearMasks = false );
protected:
std::list<Rectf> mScissorsClipped;
bool mPushScissorClip;
std::vector<const Drawable*> mDrawables;
Mode mMode;
void drawMask();
private:
friend class Renderer;
ClippingMask();
};
}}
#endif

View File

@@ -4,6 +4,7 @@
#include <eepp/graphics/renderer/base.hpp>
#include <eepp/graphics/shaderprogram.hpp>
#include <eepp/graphics/renderer/rendererhelper.hpp>
#include <eepp/graphics/renderer/clippingmask.hpp>
namespace EE { namespace Graphics {
@@ -210,6 +211,8 @@ class EE_API Renderer {
const bool& quadsSupported() const;
const int& quadVertexs() const;
ClippingMask * getClippingMask() const;
protected:
static Renderer * sSingleton;
@@ -228,6 +231,7 @@ class EE_API Renderer {
unsigned int mCurVAO;
std::list<Rectf> mPlanesClipped;
ClippingMask * mClippingMask;
private:
void writeExtension( Uint8 Pos, Uint32 BitWrite );
};

View File

@@ -301,7 +301,7 @@ class EE_API UIControl {
virtual Uint32 onValueChange();
virtual void onVisibleChange();
virtual void onVisibilityChange();
virtual void onEnabledChange();

View File

@@ -100,6 +100,8 @@ class EE_API UIWidget : public UIControlAnim {
virtual void onPositionChange();
virtual void onVisibilityChange();
virtual void onAutoSize();
void notifyLayoutAttrChange();

View File

@@ -318,18 +318,6 @@ class EE_API Window {
/** Get a frame per second limit. */
Uint32 getFrameRateLimit();
/** Set the current Clipping area ( default the entire window, SCISSOR TEST ). */
void clipEnable( const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height );
/** Disable the Clipping area */
void clipDisable();
/** Clip the area with a plane. */
void clipPlaneEnable( const Int32& x, const Int32& y, const Int32& Width, const Int32& Height );
/** Disable the clip plane area. */
void clipPlaneDisable();
/** @return The clipboard manager */
Clipboard * getClipboard() const;
@@ -492,8 +480,6 @@ class EE_API Window {
};
FrameData mFrameData;
std::list<Rectf> mScissorsClipped;
bool mPushScissorClip;
/** Set the flag state to be the current window */
virtual void setCurrent();