2013-09-09 17:49:13 +08:00
|
|
|
#ifndef _SHADER_TEST2_H_
|
|
|
|
#define _SHADER_TEST2_H_
|
2015-06-25 23:15:39 +08:00
|
|
|
|
2013-10-16 16:48:39 +08:00
|
|
|
#include "extensions/cocos-ext.h"
|
2013-09-09 17:49:13 +08:00
|
|
|
#include "../BaseTest.h"
|
|
|
|
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
DEFINE_TEST_SUITE(Shader2Tests);
|
2013-09-09 17:49:13 +08:00
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
class ShaderTestDemo2 : public TestCase
|
2013-09-09 17:49:13 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual std::string title() const override { return "Effects on Sprites";}
|
2013-09-09 17:49:13 +08:00
|
|
|
};
|
|
|
|
|
2014-05-15 04:09:33 +08:00
|
|
|
//
|
|
|
|
// Effect
|
|
|
|
//
|
|
|
|
class EffectSprite;
|
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
class Effect : public cocos2d::Ref
|
2014-04-14 11:52:17 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::GLProgramState* getGLProgramState() const { return _glprogramstate; }
|
2014-05-15 04:09:33 +08:00
|
|
|
virtual void setTarget(EffectSprite *sprite){}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool initGLProgramState(const std::string &fragmentFilename);
|
2014-05-29 12:43:04 +08:00
|
|
|
Effect();
|
|
|
|
virtual ~Effect();
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::GLProgramState* _glprogramstate;
|
2015-05-09 00:19:13 +08:00
|
|
|
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
2014-05-29 12:43:04 +08:00
|
|
|
std::string _fragSource;
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::EventListenerCustom* _backgroundListener;
|
2014-05-29 12:43:04 +08:00
|
|
|
#endif
|
2014-04-14 11:52:17 +08:00
|
|
|
};
|
|
|
|
|
2014-05-15 04:09:33 +08:00
|
|
|
class EffectSpriteTest : public ShaderTestDemo2
|
2014-05-14 09:12:58 +08:00
|
|
|
{
|
|
|
|
public:
|
2014-05-15 04:09:33 +08:00
|
|
|
CREATE_FUNC(EffectSpriteTest);
|
|
|
|
EffectSpriteTest();
|
2015-08-24 18:19:28 +08:00
|
|
|
virtual bool init();
|
2014-05-15 07:55:57 +08:00
|
|
|
virtual std::string subtitle() const {return "Different effects on Sprite";}
|
2014-05-15 04:09:33 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
ssize_t _vectorIndex;
|
|
|
|
cocos2d::Vector<Effect*> _effects;
|
|
|
|
EffectSprite *_sprite;
|
2014-05-14 09:12:58 +08:00
|
|
|
};
|
|
|
|
|
2014-10-14 16:54:52 +08:00
|
|
|
class EffectSpriteLamp : public ShaderTestDemo2
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CREATE_FUNC(EffectSpriteLamp);
|
|
|
|
EffectSpriteLamp();
|
2015-08-24 18:19:28 +08:00
|
|
|
virtual bool init();
|
2014-10-14 16:54:52 +08:00
|
|
|
virtual std::string subtitle() const {return "Sprite Lamp effects";}
|
|
|
|
//callback
|
|
|
|
public:
|
2015-04-09 08:37:30 +08:00
|
|
|
virtual void onTouchesBegan(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* unused_event);
|
|
|
|
virtual void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* unused_event);
|
|
|
|
virtual void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* unused_event);
|
2014-10-14 16:54:52 +08:00
|
|
|
protected:
|
|
|
|
EffectSprite *_sprite;
|
|
|
|
Effect* _effect;
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::Sprite* _lightSprite;
|
2014-10-14 16:54:52 +08:00
|
|
|
};
|
2014-05-07 02:19:51 +08:00
|
|
|
|
2014-06-19 19:45:49 +08:00
|
|
|
#endif
|