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

202 lines
6.1 KiB
C
Raw Normal View History

/****************************************************************************
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
2010-09-10 10:29:39 +08:00
#ifndef _RENDERTEXTURE_TEST_H_
#define _RENDERTEXTURE_TEST_H_
#include "cocos2d.h"
#include "../BaseTest.h"
DEFINE_TEST_SUITE(RenderTextureTests);
class RenderTextureTest : public TestCase
{
};
class RenderTextureSave : public RenderTextureTest
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(RenderTextureSave);
RenderTextureSave();
~RenderTextureSave();
virtual std::string title() const override;
virtual std::string subtitle() const override;
void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
void clearImage(cocos2d::Ref* pSender);
void saveImage(cocos2d::Ref* pSender);
private:
cocos2d::RenderTexture* _target;
cocos2d::Vector<cocos2d::Sprite*> _brushs;
};
class RenderTextureIssue937 : public RenderTextureTest
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(RenderTextureIssue937);
RenderTextureIssue937();
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class RenderTextureZbuffer : public RenderTextureTest
2011-07-08 16:27:13 +08:00
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(RenderTextureZbuffer);
RenderTextureZbuffer();
2011-07-08 16:27:13 +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);
virtual std::string title() const override;
virtual std::string subtitle() const override;
2011-07-08 16:27:13 +08:00
void renderScreenShot();
2011-07-08 16:27:13 +08:00
private:
2016-09-12 09:45:34 +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
};
class RenderTextureTestDepthStencil : public RenderTextureTest
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(RenderTextureTestDepthStencil);
RenderTextureTestDepthStencil();
virtual ~RenderTextureTestDepthStencil();
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags) override;
private:
cocos2d::CustomCommand _renderCmds[4];
void onBeforeClear();
void onBeforeStencil();
2017-03-23 09:30:42 +08:00
void onBeforeDraw();
void onAfterDraw();
private:
cocos2d::RenderTexture* _rend;
cocos2d::Sprite* _spriteDS;
cocos2d::Sprite* _spriteDraw;
};
2012-11-20 16:45:59 +08:00
class RenderTextureTargetNode : public RenderTextureTest
{
private:
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();
2015-07-15 12:04:48 +08:00
virtual void update(float t)override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-11-20 16:45:59 +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:
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:
class SimpleSprite : public cocos2d::Sprite
2013-11-14 09:36:33 +08:00
{
2013-02-28 16:35:42 +08:00
public:
static SimpleSprite* create(const char* filename, const cocos2d::Rect &rect);
2013-02-28 16:35:42 +08:00
SimpleSprite();
~SimpleSprite();
virtual void draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags);
2013-02-28 16:35:42 +08:00
public:
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();
void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
virtual std::string title() const override;
virtual std::string subtitle() const override;
2013-02-28 16:35:42 +08:00
SimpleSprite* addNewSpriteWithCoords(const cocos2d::Vec2& p);
2012-11-20 16:45:59 +08:00
};
2016-07-21 10:34:04 +08:00
class Issue16113Test : public RenderTextureTest
{
public:
CREATE_FUNC(Issue16113Test);
Issue16113Test();
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
cocos2d::RenderTexture* _rend;
cocos2d::Sprite* _spriteDraw;
};
class RenderTextureWithSprite3DIssue16894 : public RenderTextureTest
{
public:
CREATE_FUNC(RenderTextureWithSprite3DIssue16894);
RenderTextureWithSprite3DIssue16894();
virtual ~RenderTextureWithSprite3DIssue16894();
virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4& parentTransform, uint32_t parentFlags) override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
cocos2d::Sprite3D* _ship[3];
cocos2d::RenderTexture* _renderTexDefault;
cocos2d::RenderTexture* _renderTexWithBuffer;
};
2010-09-10 10:29:39 +08:00
#endif