2012-03-21 17:27:13 +08:00
|
|
|
#ifndef _SHADER_TEST_H_
|
|
|
|
#define _SHADER_TEST_H_
|
|
|
|
|
2014-05-16 07:45:46 +08:00
|
|
|
#include "ui/CocosGUI.h"
|
|
|
|
|
2012-03-21 17:27:13 +08:00
|
|
|
#include "../testBasic.h"
|
2013-10-16 16:48:39 +08:00
|
|
|
#include "extensions/cocos-ext.h"
|
2013-06-08 08:21:11 +08:00
|
|
|
#include "../BaseTest.h"
|
2012-07-19 17:22:36 +08:00
|
|
|
|
|
|
|
USING_NS_CC_EXT;
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2013-06-08 08:21:11 +08:00
|
|
|
class ShaderTestDemo : public BaseTest
|
2012-03-21 17:27:13 +08:00
|
|
|
{
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
ShaderTestDemo(void);
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void restartCallback(Ref* sender);
|
|
|
|
void nextCallback(Ref* sender);
|
|
|
|
void backCallback(Ref* sender);
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2012-08-27 16:11:07 +08:00
|
|
|
CREATE_FUNC(ShaderTestDemo);
|
2012-03-21 17:27:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ShaderMonjori : public ShaderTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShaderMonjori();
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual bool init();
|
2012-03-21 17:27:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ShaderMandelbrot : public ShaderTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
ShaderMandelbrot();
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual bool init();
|
2012-03-21 17:27:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ShaderJulia : public ShaderTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
ShaderJulia();
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual bool init();
|
2012-03-21 17:27:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ShaderHeart : public ShaderTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
ShaderHeart();
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual bool init();
|
2012-03-21 17:27:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ShaderFlower : public ShaderTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
ShaderFlower();
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual bool init();
|
2012-03-21 17:27:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ShaderPlasma : public ShaderTestDemo
|
|
|
|
{
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
ShaderPlasma();
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual bool init();
|
2012-03-21 17:27:13 +08:00
|
|
|
};
|
|
|
|
|
2012-04-17 18:31:31 +08:00
|
|
|
class SpriteBlur;
|
|
|
|
class ShaderBlur : public ShaderTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShaderBlur();
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-04-17 18:31:31 +08:00
|
|
|
virtual bool init();
|
2013-06-20 14:17:10 +08:00
|
|
|
ControlSlider* createSliderCtl();
|
2014-02-20 10:53:49 +08:00
|
|
|
void sliderAction(Ref* sender, Control::EventType controlEvent);
|
2012-04-17 18:31:31 +08:00
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
SpriteBlur* _blurSprite;
|
2013-06-20 14:17:10 +08:00
|
|
|
ControlSlider* _sliderCtl;
|
2012-04-17 18:31:31 +08:00
|
|
|
};
|
|
|
|
|
2012-04-18 13:58:24 +08:00
|
|
|
class ShaderRetroEffect : public ShaderTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShaderRetroEffect();
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
2012-04-18 13:58:24 +08:00
|
|
|
bool init();
|
2012-06-08 13:55:28 +08:00
|
|
|
void update(float dt);
|
2012-04-18 13:58:24 +08:00
|
|
|
protected:
|
2014-03-05 14:41:13 +08:00
|
|
|
Label* _label;
|
2013-06-15 14:03:30 +08:00
|
|
|
float _accum;
|
2012-04-18 13:58:24 +08:00
|
|
|
};
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class ShaderNode : public Node
|
2012-03-21 17:27:13 +08:00
|
|
|
{
|
|
|
|
public:
|
2014-05-13 10:12:56 +08:00
|
|
|
static ShaderNode* shaderNodeWithVertex(const std::string &vert, const std::string &frag);
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float dt);
|
2014-05-15 01:07:09 +08:00
|
|
|
virtual void setPosition(const Vec2 &newPosition);
|
2014-05-31 07:42:05 +08:00
|
|
|
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2013-12-25 16:38:43 +08:00
|
|
|
protected:
|
2014-05-13 10:12:56 +08:00
|
|
|
ShaderNode();
|
|
|
|
~ShaderNode();
|
|
|
|
|
|
|
|
bool initWithVertex(const std::string &vert, const std::string &frag);
|
|
|
|
void loadShaderVertex(const std::string &vert, const std::string &frag);
|
|
|
|
|
2014-05-31 07:42:05 +08:00
|
|
|
void onDraw(const Mat4 &transform, uint32_t flags);
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 _center;
|
|
|
|
Vec2 _resolution;
|
2013-06-15 14:03:30 +08:00
|
|
|
float _time;
|
|
|
|
std::string _vertFileName;
|
|
|
|
std::string _fragFileName;
|
2013-12-26 21:19:12 +08:00
|
|
|
CustomCommand _customCommand;
|
2012-03-21 17:27:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class ShaderTestScene : public TestScene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void runThisTest();
|
|
|
|
};
|
|
|
|
|
2014-05-10 11:34:15 +08:00
|
|
|
class ShaderLensFlare : public ShaderTestDemo
|
2014-05-10 02:48:11 +08:00
|
|
|
{
|
|
|
|
public:
|
2014-05-10 11:34:15 +08:00
|
|
|
ShaderLensFlare();
|
2014-05-10 02:48:11 +08:00
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
virtual bool init();
|
|
|
|
};
|
|
|
|
|
2014-05-14 03:55:34 +08:00
|
|
|
class ShaderGlow : public ShaderTestDemo
|
2014-05-10 02:48:11 +08:00
|
|
|
{
|
|
|
|
public:
|
2014-05-14 03:55:34 +08:00
|
|
|
ShaderGlow();
|
2014-05-10 02:48:11 +08:00
|
|
|
|
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
virtual bool init();
|
|
|
|
};
|
|
|
|
|
2014-05-14 03:55:34 +08:00
|
|
|
class ShaderMultiTexture : public ShaderTestDemo
|
2014-05-10 02:48:11 +08:00
|
|
|
{
|
2014-06-09 10:58:28 +08:00
|
|
|
static const int rightSpriteTag = 2014;
|
2014-05-10 02:48:11 +08:00
|
|
|
public:
|
2014-05-14 03:55:34 +08:00
|
|
|
ShaderMultiTexture();
|
2014-05-16 07:45:46 +08:00
|
|
|
ui::Slider* createSliderCtl();
|
2014-06-09 10:58:28 +08:00
|
|
|
void changeTexture(Ref*);
|
|
|
|
int _changedTextureId;
|
2014-05-16 07:45:46 +08:00
|
|
|
Sprite *_sprite;
|
2014-05-14 03:55:34 +08:00
|
|
|
|
2014-05-10 02:48:11 +08:00
|
|
|
virtual std::string title() const override;
|
|
|
|
virtual std::string subtitle() const override;
|
|
|
|
virtual bool init();
|
|
|
|
};
|
|
|
|
|
2012-03-21 17:27:13 +08:00
|
|
|
#endif
|