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

160 lines
4.1 KiB
C++

#ifndef _RENDERTEXTURE_TEST_H_
#define _RENDERTEXTURE_TEST_H_
#include "cocos2d.h"
#include "../testBasic.h"
#include "../BaseTest.h"
#include "2d/renderer/CCCustomCommand.h"
class RenderTextureTest : public BaseTest
{
public:
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
void restartCallback(Ref* sender);
void nextCallback(Ref* sender);
void backCallback(Ref* sender);
};
class RenderTextureSave : public RenderTextureTest
{
public:
CREATE_FUNC(RenderTextureSave);
RenderTextureSave();
~RenderTextureSave();
virtual std::string title() const override;
virtual std::string subtitle() const override;
void onTouchesMoved(const std::vector<Touch*>& touches, Event* event);
void clearImage(Ref *pSender);
void saveImage(Ref *pSender);
private:
RenderTexture *_target;
Vector<Sprite*> _brushs;
};
class RenderTextureIssue937 : public RenderTextureTest
{
public:
CREATE_FUNC(RenderTextureIssue937);
RenderTextureIssue937();
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class RenderTextureScene : public TestScene
{
public:
virtual void runThisTest();
};
class RenderTextureZbuffer : public RenderTextureTest
{
public:
CREATE_FUNC(RenderTextureZbuffer);
RenderTextureZbuffer();
void onTouchesMoved(const std::vector<Touch*>& touches, Event* event);
void onTouchesBegan(const std::vector<Touch*>& touches, Event* event);
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
virtual std::string title() const override;
virtual std::string subtitle() const override;
void renderScreenShot();
private:
cocos2d::SpriteBatchNode *mgr;;
cocos2d::Sprite *sp1;
cocos2d::Sprite *sp2;
cocos2d::Sprite *sp3;
cocos2d::Sprite *sp4;
cocos2d::Sprite *sp5;
cocos2d::Sprite *sp6;
cocos2d::Sprite *sp7;
cocos2d::Sprite *sp8;
cocos2d::Sprite *sp9;
};
class RenderTextureTestDepthStencil : public RenderTextureTest
{
public:
CREATE_FUNC(RenderTextureTestDepthStencil);
RenderTextureTestDepthStencil();
virtual ~RenderTextureTestDepthStencil();
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated) override;
private:
CustomCommand _renderCmds[4];
void onBeforeClear();
void onBeforeStencil();
void onBeforDraw();
void onAfterDraw();
private:
RenderTexture* _rend;
Sprite* _spriteDS;
Sprite* _spriteDraw;
};
class RenderTextureTargetNode : public RenderTextureTest
{
private:
cocos2d::Sprite *sprite1, *sprite2;
cocos2d::RenderTexture *renderTexture;
public:
CREATE_FUNC(RenderTextureTargetNode);
RenderTextureTargetNode();
virtual void update(float t);
virtual std::string title() const override;
virtual std::string subtitle() const override;
void touched(Ref* sender);
};
class RenderTexturePartTest : public RenderTextureTest
{
public:
CREATE_FUNC(RenderTexturePartTest);
RenderTexturePartTest();
virtual ~RenderTexturePartTest();
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
RenderTexture* _rend;
Sprite* _spriteDraw;
};
class SpriteRenderTextureBug : public RenderTextureTest
{
public:
class SimpleSprite : public Sprite
{
public:
static SimpleSprite* create(const char* filename, const Rect &rect);
SimpleSprite();
~SimpleSprite();
virtual void draw(Renderer *renderer, const Matrix &transform, bool transformUpdated);
public:
RenderTexture *_rt;
};
public:
CREATE_FUNC(SpriteRenderTextureBug);
SpriteRenderTextureBug();
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
virtual std::string title() const override;
virtual std::string subtitle() const override;
SimpleSprite* addNewSpriteWithCoords(const Vector2& p);
};
#endif