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"
|
2013-06-08 08:21:11 +08:00
|
|
|
#include "../BaseTest.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
DEFINE_TEST_SUITE(RenderTextureTests);
|
2011-02-25 11:31:49 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class RenderTextureTest : public TestCase
|
|
|
|
{
|
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;
|
2015-04-09 08:37:30 +08:00
|
|
|
void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
|
|
|
void clearImage(cocos2d::Ref* pSender);
|
|
|
|
void saveImage(cocos2d::Ref* pSender);
|
2011-08-08 14:06:03 +08:00
|
|
|
|
|
|
|
private:
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::RenderTexture* _target;
|
|
|
|
cocos2d::Vector<cocos2d::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
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
|
|
|
void onTouchesBegan(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
|
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::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;
|
2015-04-09 08:37:30 +08:00
|
|
|
virtual void draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags) override;
|
2013-12-31 11:49:46 +08:00
|
|
|
private:
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::CustomCommand _renderCmds[4];
|
2013-12-31 11:49:46 +08:00
|
|
|
void onBeforeClear();
|
|
|
|
void onBeforeStencil();
|
|
|
|
void onBeforDraw();
|
|
|
|
void onAfterDraw();
|
2013-12-31 14:48:07 +08:00
|
|
|
|
|
|
|
private:
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::RenderTexture* _rend;
|
|
|
|
cocos2d::Sprite* _spriteDS;
|
|
|
|
cocos2d::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
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void touched(cocos2d::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:
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::RenderTexture* _rend;
|
|
|
|
cocos2d::Sprite* _spriteDraw;
|
2014-03-04 15:07:54 +08:00
|
|
|
};
|
|
|
|
|
2013-02-28 16:35:42 +08:00
|
|
|
class SpriteRenderTextureBug : public RenderTextureTest
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
class SimpleSprite : public cocos2d::Sprite
|
2013-11-14 09:36:33 +08:00
|
|
|
{
|
2013-02-28 16:35:42 +08:00
|
|
|
public:
|
2015-04-09 08:37:30 +08:00
|
|
|
static SimpleSprite* create(const char* filename, const cocos2d::Rect &rect);
|
2013-02-28 16:35:42 +08:00
|
|
|
SimpleSprite();
|
2014-04-11 16:05:22 +08:00
|
|
|
~SimpleSprite();
|
2015-04-09 08:37:30 +08:00
|
|
|
virtual void draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags);
|
2013-02-28 16:35:42 +08:00
|
|
|
public:
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::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();
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::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
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
SimpleSprite* addNewSpriteWithCoords(const cocos2d::Vec2& p);
|
2012-11-20 16:45:59 +08:00
|
|
|
};
|
|
|
|
|
2010-09-10 10:29:39 +08:00
|
|
|
#endif
|