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

95 lines
3.0 KiB
C
Raw Normal View History

/****************************************************************************
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
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
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
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_
#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:
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;
class Effect : public axis::Ref
2014-04-14 11:52:17 +08:00
{
public:
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);
Effect();
virtual ~Effect();
axis::backend::ProgramState* _programState = nullptr;
2022-07-15 19:17:01 +08:00
#if (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID)
std::string _fragSource;
axis::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();
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;
axis::Vector<Effect*> _effects;
2021-12-28 16:06:23 +08:00
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();
2021-12-28 16:06:23 +08:00
virtual std::string subtitle() const { return "Sprite Lamp effects"; }
// callback
public:
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
protected:
2021-12-28 16:06:23 +08:00
EffectSprite* _sprite;
Effect* _effect;
axis::Sprite* _lightSprite;
};
2014-05-07 02:19:51 +08:00
#endif