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"
|
2013-12-27 14:42:45 +08:00
|
|
|
#include "renderer/CCCustomCommand.h"
|
|
|
|
#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;
|
2012-11-21 15:22:54 +08:00
|
|
|
virtual void setup();
|
|
|
|
|
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-04-15 18:23:40 +08:00
|
|
|
void pokeHoleAtPoint(Vector2 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-04-15 18:23:40 +08:00
|
|
|
Vector2 _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-04-08 22:07:35 +08:00
|
|
|
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) 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-04-15 18:23:40 +08:00
|
|
|
void onBeforeDrawClip(int planeIndex, const Vector2& pt);
|
|
|
|
void onBeforeDrawSprite(int planeIndex, const Vector2& pt);
|
2013-12-30 15:26:01 +08:00
|
|
|
protected:
|
|
|
|
Vector<Sprite*> _sprites;
|
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);
|
|
|
|
};
|
|
|
|
|
|
|
|
class RawStencilBufferTest4 : public RawStencilBufferTest
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
|
|
|
class RawStencilBufferTest5 : public RawStencilBufferTest
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
};
|
|
|
|
|
|
|
|
class RawStencilBufferTest6 : public RawStencilBufferTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 07:55:36 +08:00
|
|
|
CREATE_FUNC(RawStencilBufferTest6);
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2012-11-21 15:22:54 +08:00
|
|
|
virtual void setup();
|
|
|
|
virtual void setupStencilForClippingOnPlane(GLint plane);
|
|
|
|
virtual void setupStencilForDrawingOnPlane(GLint plane);
|
|
|
|
};
|
|
|
|
|
|
|
|
//#endif //COCOS2D_DEBUG > 1
|
|
|
|
|
|
|
|
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__
|