PuzzleSDK
ShaderTest2.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 _SHADER_TEST2_H_
26#define _SHADER_TEST2_H_
27
28#include "extensions/cocos-ext.h"
29#include "../BaseTest.h"
30
31
32DEFINE_TEST_SUITE(Shader2Tests);
33
35{
36public:
37 virtual std::string title() const override { return "Effects on Sprites";}
38};
39
40//
41// Effect
42//
43class EffectSprite;
44
45class Effect : public cocos2d::Ref
46{
47public:
48 cocos2d::backend::ProgramState* getProgramState() const { return _programState; }
49 virtual void setTarget(EffectSprite *sprite){}
50
51protected:
52 bool initProgramState(const std::string &fragmentFilename);
53 Effect();
54 virtual ~Effect();
55 cocos2d::backend::ProgramState* _programState = nullptr;
56#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
57 std::string _fragSource;
58 cocos2d::EventListenerCustom* _backgroundListener;
59#endif
60};
61
63{
64public:
67 virtual bool init();
68 virtual std::string subtitle() const {return "Different effects on Sprite";}
69
70protected:
71 ssize_t _vectorIndex;
72 cocos2d::Vector<Effect*> _effects;
74};
75
77{
78public:
81 virtual bool init();
82 virtual std::string subtitle() const {return "Sprite Lamp effects";}
83 //callback
84public:
85 virtual void onTouchesBegan(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* unused_event);
86 virtual void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* unused_event);
87 virtual void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* unused_event);
88protected:
91 cocos2d::Sprite* _lightSprite;
92};
93
94#endif
DEFINE_TEST_SUITE(Shader2Tests)
cocos2d::EventListenerCustom * _backgroundListener
Definition: ShaderTest2.h:58
std::string _fragSource
Definition: ShaderTest2.h:57
cocos2d::backend::ProgramState * _programState
Definition: ShaderTest2.h:55
virtual void setTarget(EffectSprite *sprite)
Definition: ShaderTest2.h:49
bool initProgramState(const std::string &fragmentFilename)
cocos2d::backend::ProgramState * getProgramState() const
Definition: ShaderTest2.h:48
virtual ~Effect()
cocos2d::Sprite * _lightSprite
Definition: ShaderTest2.h:91
virtual void onTouchesEnded(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *unused_event)
virtual std::string subtitle() const
Definition: ShaderTest2.h:82
EffectSprite * _sprite
Definition: ShaderTest2.h:89
virtual bool init()
virtual void onTouchesBegan(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *unused_event)
Effect * _effect
Definition: ShaderTest2.h:90
virtual void onTouchesMoved(const std::vector< cocos2d::Touch * > &touches, cocos2d::Event *unused_event)
CREATE_FUNC(EffectSpriteLamp)
virtual bool init()
cocos2d::Vector< Effect * > _effects
Definition: ShaderTest2.h:72
CREATE_FUNC(EffectSpriteTest)
EffectSprite * _sprite
Definition: ShaderTest2.h:73
virtual std::string subtitle() const
Definition: ShaderTest2.h:68
ssize_t _vectorIndex
Definition: ShaderTest2.h:71
virtual std::string title() const override
Definition: ShaderTest2.h:37