PuzzleSDK
RenderTextureTest.h
浏览该文件的文档.
1/****************************************************************************
2 Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
3
4 http://www.cocos2d-x.org
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 THE SOFTWARE.
23 ****************************************************************************/
24
25#ifndef _RENDERTEXTURE_TEST_H_
26#define _RENDERTEXTURE_TEST_H_
27
28#include "cocos2d.h"
29#include "../BaseTest.h"
30
31DEFINE_TEST_SUITE(RenderTextureTests);
32
34{
35};
36
38{
39public:
43 virtual std::string title() const override;
44 virtual std::string subtitle() const override;
45 void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
46 void clearImage(cocos2d::Ref* pSender);
47 void clearImageTransparent(cocos2d::Ref* sender);
48 void saveImageWithPremultipliedAlpha(cocos2d::Ref* pSender);
49 void saveImageWithNonPremultipliedAlpha(cocos2d::Ref* pSender);
50 void addImage(cocos2d::Ref* sender);
51
52private:
53 cocos2d::RenderTexture* _target;
54 cocos2d::Vector<cocos2d::Sprite*> _brushs;
55};
56
58{
59public:
62 virtual std::string title() const override;
63 virtual std::string subtitle() const override;
64};
65
67{
68public:
71
72 void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
73 void onTouchesBegan(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
74 void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
75 virtual std::string title() const override;
76 virtual std::string subtitle() const override;
77
78 void renderScreenShot();
79
80private:
81 cocos2d::SpriteBatchNode *mgr;
82
83 cocos2d::Sprite *sp1;
84 cocos2d::Sprite *sp2;
85 cocos2d::Sprite *sp3;
86 cocos2d::Sprite *sp4;
87 cocos2d::Sprite *sp5;
88 cocos2d::Sprite *sp6;
89 cocos2d::Sprite *sp7;
90 cocos2d::Sprite *sp8;
91 cocos2d::Sprite *sp9;
92};
93
95{
96public:
100 virtual std::string title() const override;
101 virtual std::string subtitle() const override;
102 virtual void draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags) override;
103private:
104 cocos2d::CallbackCommand _renderCmds[4];
105 void onBeforeClear();
106 void onBeforeStencil();
107 void onBeforeDraw();
108 void onAfterDraw();
109
110private:
111 cocos2d::RenderTexture* _rend;
112 cocos2d::Sprite* _spriteDS;
113 cocos2d::Sprite* _spriteDraw;
114};
115
117{
118private:
119 cocos2d::Sprite *sprite1, *sprite2;
120 cocos2d::RenderTexture *renderTexture;
121public:
124
125 virtual void update(float t)override;
126 virtual std::string title() const override;
127 virtual std::string subtitle() const override;
128
129 void touched(cocos2d::Ref* sender);
130};
131
133{
134public:
137 virtual ~RenderTexturePartTest();
138 virtual std::string title() const override;
139 virtual std::string subtitle() const override;
140
141private:
142 cocos2d::RenderTexture* _rend;
143 cocos2d::Sprite* _spriteDraw;
144};
145
147{
148public:
149
150 class SimpleSprite : public cocos2d::Sprite
151 {
152 public:
153 static SimpleSprite* create(const char* filename, const cocos2d::Rect &rect);
154 SimpleSprite();
156 virtual void draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags);
157 public:
158 cocos2d::RenderTexture* _rt;
159 };
160
161public:
164
165 void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
166 virtual std::string title() const override;
167 virtual std::string subtitle() const override;
168
169 SimpleSprite* addNewSpriteWithCoords(const cocos2d::Vec2& p);
170};
171
173{
174public:
177 virtual std::string title() const override;
178 virtual std::string subtitle() const override;
179};
180
182{
183public:
187
188 virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4& parentTransform, uint32_t parentFlags) override;
189
190 virtual std::string title() const override;
191 virtual std::string subtitle() const override;
192
193private:
194 cocos2d::Sprite3D* _ship[3];
195
196 cocos2d::RenderTexture* _renderTexDefault;
197 cocos2d::RenderTexture* _renderTexWithBuffer;
198};
199
200#endif
DEFINE_TEST_SUITE(RenderTextureTests)
CREATE_FUNC(Issue16113Test)
virtual std::string title() const override
virtual std::string subtitle() const override
virtual std::string title() const override
CREATE_FUNC(RenderTextureIssue937)
virtual std::string subtitle() const override
virtual std::string subtitle() const override
virtual std::string title() const override
CREATE_FUNC(RenderTexturePartTest)
cocos2d::RenderTexture * _rend
cocos2d::Sprite * _spriteDraw
cocos2d::Vector< cocos2d::Sprite * > _brushs
virtual std::string subtitle() const override
CREATE_FUNC(RenderTextureSave)
void clearImage(cocos2d::Ref *pSender)
void onTouchesMoved(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
cocos2d::RenderTexture * _target
void saveImageWithNonPremultipliedAlpha(cocos2d::Ref *pSender)
void saveImageWithPremultipliedAlpha(cocos2d::Ref *pSender)
virtual std::string title() const override
void addImage(cocos2d::Ref *sender)
void clearImageTransparent(cocos2d::Ref *sender)
cocos2d::Sprite * sprite1
virtual void update(float t) override
void touched(cocos2d::Ref *sender)
virtual std::string subtitle() const override
cocos2d::Sprite * sprite2
virtual std::string title() const override
cocos2d::RenderTexture * renderTexture
CREATE_FUNC(RenderTextureTargetNode)
virtual std::string title() const override
cocos2d::CallbackCommand _renderCmds[4]
virtual std::string subtitle() const override
cocos2d::RenderTexture * _rend
CREATE_FUNC(RenderTextureTestDepthStencil)
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags) override
virtual std::string title() const override
CREATE_FUNC(RenderTextureWithSprite3DIssue16894)
cocos2d::RenderTexture * _renderTexDefault
virtual std::string subtitle() const override
cocos2d::RenderTexture * _renderTexWithBuffer
virtual void visit(cocos2d::Renderer *renderer, const cocos2d::Mat4 &parentTransform, uint32_t parentFlags) override
cocos2d::Sprite * sp4
cocos2d::Sprite * sp3
void onTouchesEnded(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
cocos2d::Sprite * sp2
CREATE_FUNC(RenderTextureZbuffer)
cocos2d::Sprite * sp1
cocos2d::SpriteBatchNode * mgr
cocos2d::Sprite * sp5
cocos2d::Sprite * sp7
void onTouchesMoved(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
cocos2d::Sprite * sp9
cocos2d::Sprite * sp8
virtual std::string subtitle() const override
void onTouchesBegan(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
cocos2d::Sprite * sp6
virtual std::string title() const override
virtual void draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags)
static SimpleSprite * create(const char *filename, const cocos2d::Rect &rect)
CREATE_FUNC(SpriteRenderTextureBug)
virtual std::string subtitle() const override
void onTouchesEnded(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *event)
SimpleSprite * addNewSpriteWithCoords(const cocos2d::Vec2 &p)
virtual std::string title() const override