axmol/tests/cpp-tests/Classes/ShaderTest/ShaderTest2.h

71 lines
1.8 KiB
C
Raw Normal View History

2013-09-09 17:49:13 +08:00
#ifndef _SHADER_TEST2_H_
#define _SHADER_TEST2_H_
#include "extensions/cocos-ext.h"
2013-09-09 17:49:13 +08:00
#include "../BaseTest.h"
DEFINE_TEST_SUITE(Shader2Tests);
2013-09-09 17:49:13 +08:00
class ShaderTestDemo2 : public TestCase
2013-09-09 17:49:13 +08:00
{
public:
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;
class Effect : public cocos2d::Ref
2014-04-14 11:52:17 +08:00
{
public:
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);
Effect();
virtual ~Effect();
cocos2d::GLProgramState* _glprogramstate;
2015-05-09 00:19:13 +08:00
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
std::string _fragSource;
cocos2d::EventListenerCustom* _backgroundListener;
#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
};
class EffectSpriteLamp : public ShaderTestDemo2
{
public:
CREATE_FUNC(EffectSpriteLamp);
EffectSpriteLamp();
2015-08-24 18:19:28 +08:00
virtual bool init();
virtual std::string subtitle() const {return "Sprite Lamp effects";}
//callback
public:
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);
protected:
EffectSprite *_sprite;
Effect* _effect;
cocos2d::Sprite* _lightSprite;
};
2014-05-07 02:19:51 +08:00
#endif