axmol/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.h

233 lines
5.6 KiB
C
Raw Normal View History

2012-11-21 15:22:54 +08:00
#ifndef __CLIPPINGNODETEST_H__
#define __CLIPPINGNODETEST_H__
#include "../testBasic.h"
#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
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();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-11-21 15:22:54 +08:00
virtual void setup();
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);
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-11-21 15:22:54 +08:00
virtual void setup();
virtual Action* actionRotate();
virtual Action* actionScale();
2012-11-21 15:22:54 +08:00
virtual DrawNode* shape();
virtual Sprite* grossini();
2012-11-21 15:22:54 +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);
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-11-21 15:22:54 +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);
virtual std::string title() const override;
virtual std::string subtitle() const override;
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);
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-11-21 15:22:54 +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);
virtual std::string title() const override;
virtual std::string subtitle() const override;
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);
virtual std::string title() const override;
virtual std::string subtitle() const override;
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);
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();
virtual std::string title() const override;
virtual std::string subtitle() const override;
void pokeHoleAtPoint(Point point);
void onTouchesBegan(const std::vector<Touch*>& touches, Event *event);
2012-11-21 15:22:54 +08:00
private:
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);
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-11-21 15:22:54 +08:00
virtual void setup();
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:
bool _scrolling;
Point _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();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-11-21 15:22:54 +08:00
virtual void setup();
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
2012-11-21 15:22:54 +08:00
virtual void setupStencilForClippingOnPlane(GLint plane);
virtual void setupStencilForDrawingOnPlane(GLint plane);
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();
void onBeforeDrawClip(int planeIndex, const Point& pt);
void onBeforeDrawSprite(int planeIndex, const Point& pt);
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);
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);
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);
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);
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);
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__