2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2022-10-01 16:24:52 +08:00
|
|
|
https://axmolengine.github.io/
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
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:
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
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:
|
2021-12-28 16:06:23 +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;
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
class Effect : public axis::Ref
|
2014-04-14 11:52:17 +08:00
|
|
|
{
|
|
|
|
public:
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::backend::ProgramState* getProgramState() const { return _programState; }
|
2021-12-28 16:06:23 +08:00
|
|
|
virtual void setTarget(EffectSprite* sprite) {}
|
2014-05-15 04:09:33 +08:00
|
|
|
|
|
|
|
protected:
|
2021-12-28 17:20:17 +08:00
|
|
|
bool initProgramState(std::string_view fragmentFilename);
|
2014-05-29 12:43:04 +08:00
|
|
|
Effect();
|
|
|
|
virtual ~Effect();
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::backend::ProgramState* _programState = nullptr;
|
2022-07-15 19:17:01 +08:00
|
|
|
#if (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID)
|
2014-05-29 12:43:04 +08:00
|
|
|
std::string _fragSource;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::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();
|
2021-12-28 16:06:23 +08:00
|
|
|
virtual std::string subtitle() const { return "Different effects on Sprite"; }
|
2014-05-15 04:09:33 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
ssize_t _vectorIndex;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::Vector<Effect*> _effects;
|
2021-12-28 16:06:23 +08:00
|
|
|
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();
|
2021-12-28 16:06:23 +08:00
|
|
|
virtual std::string subtitle() const { return "Sprite Lamp effects"; }
|
|
|
|
// callback
|
2014-10-14 16:54:52 +08:00
|
|
|
public:
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void onTouchesBegan(const std::vector<axis::Touch*>& touches, axis::Event* unused_event);
|
|
|
|
virtual void onTouchesMoved(const std::vector<axis::Touch*>& touches, axis::Event* unused_event);
|
|
|
|
virtual void onTouchesEnded(const std::vector<axis::Touch*>& touches, axis::Event* unused_event);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2014-10-14 16:54:52 +08:00
|
|
|
protected:
|
2021-12-28 16:06:23 +08:00
|
|
|
EffectSprite* _sprite;
|
2014-10-14 16:54:52 +08:00
|
|
|
Effect* _effect;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::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
|