2010-09-10 10:29:39 +08:00
|
|
|
#ifndef _RENDERTEXTURE_TEST_H_
|
|
|
|
#define _RENDERTEXTURE_TEST_H_
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "../testBasic.h"
|
2013-06-08 08:21:11 +08:00
|
|
|
#include "../BaseTest.h"
|
2013-12-31 11:49:46 +08:00
|
|
|
#include "renderer/CCCustomCommand.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-08 08:21:11 +08:00
|
|
|
class RenderTextureTest : public BaseTest
|
2010-09-10 10:29:39 +08:00
|
|
|
{
|
|
|
|
public:
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2011-02-25 11:31:49 +08:00
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void restartCallback(Ref* sender);
|
|
|
|
void nextCallback(Ref* sender);
|
|
|
|
void backCallback(Ref* sender);
|
2011-02-25 11:31:49 +08:00
|
|
|
};
|
|
|
|
|
2012-06-14 18:37:57 +08:00
|
|
|
class RenderTextureSave : public RenderTextureTest
|
2011-08-08 14:06:03 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(RenderTextureSave);
|
2012-04-19 14:35:52 +08:00
|
|
|
RenderTextureSave();
|
|
|
|
~RenderTextureSave();
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-10-23 16:14:03 +08:00
|
|
|
void onTouchesMoved(const std::vector<Touch*>& touches, Event* event);
|
2014-02-20 10:53:49 +08:00
|
|
|
void clearImage(Ref *pSender);
|
|
|
|
void saveImage(Ref *pSender);
|
2011-08-08 14:06:03 +08:00
|
|
|
|
|
|
|
private:
|
2013-12-23 17:13:41 +08:00
|
|
|
RenderTexture *_target;
|
2014-01-06 09:49:04 +08:00
|
|
|
Vector<Sprite*> _brushs;
|
2011-08-08 14:06:03 +08:00
|
|
|
};
|
|
|
|
|
2012-06-14 18:37:57 +08:00
|
|
|
class RenderTextureIssue937 : public RenderTextureTest
|
2011-02-25 11:31:49 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(RenderTextureIssue937);
|
2011-02-25 11:31:49 +08:00
|
|
|
RenderTextureIssue937();
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2011-02-25 11:31:49 +08:00
|
|
|
};
|
|
|
|
|
2010-09-10 10:29:39 +08:00
|
|
|
class RenderTextureScene : public TestScene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void runThisTest();
|
|
|
|
};
|
|
|
|
|
2012-06-14 18:37:57 +08:00
|
|
|
class RenderTextureZbuffer : public RenderTextureTest
|
2011-07-08 16:27:13 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(RenderTextureZbuffer);
|
2012-04-19 14:35:52 +08:00
|
|
|
RenderTextureZbuffer();
|
2011-07-08 16:27:13 +08:00
|
|
|
|
2013-10-23 16:14:03 +08:00
|
|
|
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);
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2011-07-08 16:27:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
void renderScreenShot();
|
2011-07-08 16:27:13 +08:00
|
|
|
|
|
|
|
private:
|
2013-06-20 14:17:10 +08:00
|
|
|
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;
|
2011-07-08 16:27:13 +08:00
|
|
|
};
|
|
|
|
|
2012-06-14 18:37:57 +08:00
|
|
|
class RenderTextureTestDepthStencil : public RenderTextureTest
|
|
|
|
{
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(RenderTextureTestDepthStencil);
|
2012-06-14 18:37:57 +08:00
|
|
|
RenderTextureTestDepthStencil();
|
2013-12-31 14:48:07 +08:00
|
|
|
virtual ~RenderTextureTestDepthStencil();
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2014-03-01 08:10:48 +08:00
|
|
|
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated) override;
|
2013-12-31 11:49:46 +08:00
|
|
|
private:
|
|
|
|
CustomCommand _renderCmds[4];
|
|
|
|
void onBeforeClear();
|
|
|
|
void onBeforeStencil();
|
|
|
|
void onBeforDraw();
|
|
|
|
void onAfterDraw();
|
2013-12-31 14:48:07 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
RenderTexture* _rend;
|
|
|
|
Sprite* _spriteDS;
|
|
|
|
Sprite* _spriteDraw;
|
2012-06-12 15:55:23 +08:00
|
|
|
};
|
|
|
|
|
2012-11-20 16:45:59 +08:00
|
|
|
class RenderTextureTargetNode : public RenderTextureTest
|
|
|
|
{
|
|
|
|
private:
|
2013-06-20 14:17:10 +08:00
|
|
|
cocos2d::Sprite *sprite1, *sprite2;
|
|
|
|
cocos2d::RenderTexture *renderTexture;
|
2012-11-20 16:45:59 +08:00
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(RenderTextureTargetNode);
|
2012-11-20 16:45:59 +08:00
|
|
|
RenderTextureTargetNode();
|
|
|
|
|
|
|
|
virtual void update(float t);
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-11-20 16:45:59 +08:00
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void touched(Ref* sender);
|
2013-02-28 16:35:42 +08:00
|
|
|
};
|
|
|
|
|
2014-03-04 15:07:54 +08:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2013-02-28 16:35:42 +08:00
|
|
|
class SpriteRenderTextureBug : public RenderTextureTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2013-11-14 09:36:33 +08:00
|
|
|
class SimpleSprite : public Sprite
|
|
|
|
{
|
2013-02-28 16:35:42 +08:00
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
static SimpleSprite* create(const char* filename, const Rect &rect);
|
2013-02-28 16:35:42 +08:00
|
|
|
SimpleSprite();
|
2014-04-11 16:05:22 +08:00
|
|
|
~SimpleSprite();
|
2014-03-01 08:10:48 +08:00
|
|
|
virtual void draw(Renderer *renderer, const kmMat4 &transform, bool transformUpdated);
|
2013-02-28 16:35:42 +08:00
|
|
|
public:
|
2013-11-15 08:33:43 +08:00
|
|
|
RenderTexture *_rt;
|
2013-11-14 09:36:33 +08:00
|
|
|
};
|
2013-02-28 16:35:42 +08:00
|
|
|
|
|
|
|
public:
|
2013-11-14 09:36:33 +08:00
|
|
|
CREATE_FUNC(SpriteRenderTextureBug);
|
2013-02-28 16:35:42 +08:00
|
|
|
SpriteRenderTextureBug();
|
|
|
|
|
2013-10-23 16:14:03 +08:00
|
|
|
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2013-02-28 16:35:42 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
SimpleSprite* addNewSpriteWithCoords(const Point& p);
|
2012-11-20 16:45:59 +08:00
|
|
|
};
|
|
|
|
|
2010-09-10 10:29:39 +08:00
|
|
|
#endif
|