2012-11-21 15:22:54 +08:00
|
|
|
#ifndef __CLIPPINGNODETEST_H__
|
|
|
|
#define __CLIPPINGNODETEST_H__
|
|
|
|
|
|
|
|
#include "../testBasic.h"
|
2013-06-07 08:12:28 +08:00
|
|
|
#include "../BaseTest.h"
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "renderer/CCCustomCommand.h"
|
2013-12-27 14:42:45 +08:00
|
|
|
#include <list>
|
2012-11-21 15:22:54 +08:00
|
|
|
|
2013-06-07 08:12:28 +08:00
|
|
|
class BaseClippingNodeTest : public BaseTest
|
2012-11-21 15:22:54 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(BaseClippingNodeTest);
|
|
|
|
|
2012-11-21 15:22:54 +08:00
|
|
|
~BaseClippingNodeTest();
|
|
|
|
virtual bool init();
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-11-21 15:22:54 +08:00
|
|
|
virtual void setup();
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void backCallback(Ref* sender);
|
|
|
|
void nextCallback(Ref* sender);
|
|
|
|
void restartCallback(Ref* sender);
|
2012-11-21 15:22:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class BasicTest : public BaseClippingNodeTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(BasicTest);
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2014-08-28 01:54:15 +08:00
|
|
|
virtual void setup() override;
|
2012-11-21 15:22:54 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
virtual Action* actionRotate();
|
|
|
|
virtual Action* actionScale();
|
2012-11-21 15:22:54 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
virtual DrawNode* shape();
|
|
|
|
virtual Sprite* grossini();
|
2012-11-21 15:22:54 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
virtual Node* stencil();
|
|
|
|
virtual ClippingNode* clipper();
|
|
|
|
virtual Node* content();
|
2012-11-21 15:22:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ShapeTest : public BasicTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(ShapeTest);
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-11-21 15:22:54 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
virtual Node* stencil();
|
|
|
|
virtual Node* content();
|
2012-11-21 15:22:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ShapeInvertedTest : public ShapeTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(ShapeInvertedTest);
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-06-20 14:17:10 +08:00
|
|
|
virtual ClippingNode* clipper();
|
2012-11-21 15:22:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SpriteTest : public BasicTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(SpriteTest);
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-11-21 15:22:54 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
virtual Node* stencil();
|
|
|
|
virtual ClippingNode* clipper();
|
|
|
|
virtual Node* content();
|
2012-11-21 15:22:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SpriteNoAlphaTest : public SpriteTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(SpriteNoAlphaTest);
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-06-20 14:17:10 +08:00
|
|
|
virtual ClippingNode* clipper();
|
2012-11-21 15:22:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class SpriteInvertedTest : public SpriteTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(SpriteInvertedTest);
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-06-20 14:17:10 +08:00
|
|
|
virtual ClippingNode* clipper();
|
2012-11-21 15:22:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class NestedTest : public BaseClippingNodeTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(NestedTest);
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-11-21 15:22:54 +08:00
|
|
|
virtual void setup();
|
|
|
|
};
|
|
|
|
|
|
|
|
class HoleDemo : public BaseClippingNodeTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(HoleDemo);
|
|
|
|
|
2012-11-21 15:22:54 +08:00
|
|
|
~HoleDemo();
|
|
|
|
virtual void setup();
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2014-05-15 01:07:09 +08:00
|
|
|
void pokeHoleAtPoint(Vec2 point);
|
2013-10-23 16:14:03 +08:00
|
|
|
void onTouchesBegan(const std::vector<Touch*>& touches, Event *event);
|
2012-11-21 15:22:54 +08:00
|
|
|
private:
|
2013-06-20 14:17:10 +08:00
|
|
|
ClippingNode* _outerClipper;
|
|
|
|
Node* _holes;
|
|
|
|
Node* _holesStencil;
|
2012-11-21 15:22:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ScrollViewDemo : public BaseClippingNodeTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(ScrollViewDemo);
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-11-21 15:22:54 +08:00
|
|
|
virtual void setup();
|
2013-10-23 16:14:03 +08:00
|
|
|
void onTouchesBegan(const std::vector<Touch*>& touches, Event *event);
|
|
|
|
void onTouchesMoved(const std::vector<Touch*>& touches, Event *event);
|
|
|
|
void onTouchesEnded(const std::vector<Touch*>& touches, Event *event);
|
2012-11-21 15:22:54 +08:00
|
|
|
private:
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _scrolling;
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 _lastPoint;
|
2012-11-21 15:22:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
//#if COCOS2D_DEBUG > 1
|
|
|
|
|
|
|
|
class RawStencilBufferTest : public BaseClippingNodeTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(RawStencilBufferTest);
|
|
|
|
|
2012-11-21 15:22:54 +08:00
|
|
|
~RawStencilBufferTest();
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-11-21 15:22:54 +08:00
|
|
|
virtual void setup();
|
2014-05-31 07:42:05 +08:00
|
|
|
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
2012-11-21 15:22:54 +08:00
|
|
|
|
|
|
|
virtual void setupStencilForClippingOnPlane(GLint plane);
|
|
|
|
virtual void setupStencilForDrawingOnPlane(GLint plane);
|
|
|
|
|
2013-12-26 15:34:22 +08:00
|
|
|
protected:
|
2013-12-27 14:42:45 +08:00
|
|
|
std::list<CustomCommand> _renderCmds;
|
2013-12-26 15:30:13 +08:00
|
|
|
void onEnableStencil();
|
|
|
|
void onDisableStencil();
|
2014-05-15 01:07:09 +08:00
|
|
|
void onBeforeDrawClip(int planeIndex, const Vec2& pt);
|
|
|
|
void onBeforeDrawSprite(int planeIndex, const Vec2& pt);
|
2013-12-30 15:26:01 +08:00
|
|
|
protected:
|
|
|
|
Vector<Sprite*> _sprites;
|
2014-04-22 10:58:42 +08:00
|
|
|
Vector<Sprite*> _spritesStencil;
|
2012-11-21 15:22:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class RawStencilBufferTest2 : public RawStencilBufferTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(RawStencilBufferTest2);
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2012-11-21 15:22:54 +08:00
|
|
|
virtual void setupStencilForClippingOnPlane(GLint plane);
|
|
|
|
virtual void setupStencilForDrawingOnPlane(GLint plane);
|
|
|
|
};
|
|
|
|
|
|
|
|
class RawStencilBufferTest3 : public RawStencilBufferTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(RawStencilBufferTest3);
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2012-11-21 15:22:54 +08:00
|
|
|
virtual void setupStencilForClippingOnPlane(GLint plane);
|
|
|
|
virtual void setupStencilForDrawingOnPlane(GLint plane);
|
|
|
|
};
|
|
|
|
|
2014-04-22 10:58:42 +08:00
|
|
|
class RawStencilBufferTestAlphaTest : public RawStencilBufferTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void setup() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class RawStencilBufferTest4 : public RawStencilBufferTestAlphaTest
|
2012-11-21 15:22:54 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(RawStencilBufferTest4);
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2012-11-21 15:22:54 +08:00
|
|
|
virtual void setupStencilForClippingOnPlane(GLint plane);
|
|
|
|
virtual void setupStencilForDrawingOnPlane(GLint plane);
|
|
|
|
};
|
|
|
|
|
2014-04-22 10:58:42 +08:00
|
|
|
class RawStencilBufferTest5 : public RawStencilBufferTestAlphaTest
|
2012-11-21 15:22:54 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(RawStencilBufferTest5);
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2012-11-21 15:22:54 +08:00
|
|
|
virtual void setupStencilForClippingOnPlane(GLint plane);
|
|
|
|
virtual void setupStencilForDrawingOnPlane(GLint plane);
|
|
|
|
};
|
|
|
|
|
2014-04-22 10:58:42 +08:00
|
|
|
class RawStencilBufferTest6 : public RawStencilBufferTestAlphaTest
|
2012-11-21 15:22:54 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(RawStencilBufferTest6);
|
2014-08-28 01:54:15 +08:00
|
|
|
|
2012-11-21 15:22:54 +08:00
|
|
|
virtual void setupStencilForClippingOnPlane(GLint plane);
|
|
|
|
virtual void setupStencilForDrawingOnPlane(GLint plane);
|
2014-08-28 01:54:15 +08:00
|
|
|
|
|
|
|
// override
|
|
|
|
virtual void setup() override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-11-21 15:22:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
//#endif //COCOS2D_DEBUG > 1
|
|
|
|
|
2014-08-28 01:54:15 +08:00
|
|
|
class ClippingToRenderTextureTest : public BaseClippingNodeTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(ClippingToRenderTextureTest);
|
|
|
|
|
|
|
|
void expectedBehaviour();
|
|
|
|
void reproduceBug();
|
|
|
|
|
|
|
|
// override
|
|
|
|
virtual void setup() override;
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
};
|
|
|
|
|
2014-10-15 13:41:47 +08:00
|
|
|
class ClippingRectangleNodeTest : public BaseClippingNodeTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(ClippingRectangleNodeTest);
|
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
virtual void setup();
|
|
|
|
};
|
|
|
|
|
2014-08-28 01:54:15 +08:00
|
|
|
|
2012-11-21 15:22:54 +08:00
|
|
|
class ClippingNodeTestScene : public TestScene
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(ClippingNodeTestScene);
|
|
|
|
|
2012-11-21 15:22:54 +08:00
|
|
|
virtual void runThisTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //__CLIPPINGNODETEST_H__
|