2012-03-21 17:27:13 +08:00
|
|
|
#ifndef _SHADER_TEST_H_
|
|
|
|
#define _SHADER_TEST_H_
|
|
|
|
|
|
|
|
#include "../testBasic.h"
|
2012-07-20 14:05:52 +08:00
|
|
|
#include "cocos-ext.h"
|
2012-07-19 17:22:36 +08:00
|
|
|
|
|
|
|
USING_NS_CC_EXT;
|
2012-03-21 17:27:13 +08:00
|
|
|
|
|
|
|
class ShaderTestDemo : public CCLayer
|
|
|
|
{
|
|
|
|
public:
|
2012-04-19 14:35:52 +08:00
|
|
|
ShaderTestDemo(void);
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
virtual bool init();
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
void restartCallback(CCObject* pSender);
|
|
|
|
void nextCallback(CCObject* pSender);
|
|
|
|
void backCallback(CCObject* pSender);
|
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();
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
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
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
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
|
|
|
|
|
|
|
virtual std::string title();
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual std::string subtitle();
|
|
|
|
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
|
|
|
|
|
|
|
virtual std::string title();
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual std::string subtitle();
|
|
|
|
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
|
|
|
|
|
|
|
virtual std::string title();
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual std::string subtitle();
|
|
|
|
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
|
|
|
|
|
|
|
virtual std::string title();
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual std::string subtitle();
|
|
|
|
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();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
virtual bool init();
|
|
|
|
CCControlSlider* createSliderCtl();
|
2012-06-14 18:32:44 +08:00
|
|
|
void sliderAction(CCObject* sender, CCControlEvent controlEvent);
|
2012-04-17 18:31:31 +08:00
|
|
|
protected:
|
2012-04-18 13:58:24 +08:00
|
|
|
SpriteBlur* m_pBlurSprite;
|
|
|
|
CCControlSlider* m_pSliderCtl;
|
2012-04-17 18:31:31 +08:00
|
|
|
};
|
|
|
|
|
2012-04-18 13:58:24 +08:00
|
|
|
class ShaderRetroEffect : public ShaderTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShaderRetroEffect();
|
|
|
|
virtual std::string title();
|
|
|
|
virtual std::string subtitle();
|
|
|
|
bool init();
|
2012-06-08 13:55:28 +08:00
|
|
|
void update(float dt);
|
2012-04-18 13:58:24 +08:00
|
|
|
protected:
|
|
|
|
CCLabelBMFont* m_pLabel;
|
2012-06-08 13:55:28 +08:00
|
|
|
float m_fAccum;
|
2012-04-18 13:58:24 +08:00
|
|
|
};
|
2012-03-21 17:27:13 +08:00
|
|
|
|
|
|
|
class ShaderNode : public CCNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShaderNode();
|
2012-10-18 10:15:46 +08:00
|
|
|
~ShaderNode();
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
bool initWithVertex(const char *vert, const char *frag);
|
|
|
|
void loadShaderVertex(const char *vert, const char *frag);
|
2012-10-18 10:15:46 +08:00
|
|
|
void listenBackToForeground(CCObject *obj);
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
virtual void update(float dt);
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void setPosition(const CCPoint &newPosition);
|
|
|
|
virtual void draw();
|
2012-03-21 17:27:13 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
static ShaderNode* shaderNodeWithVertex(const char *vert, const char *frag);
|
2012-03-21 17:27:13 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
ccVertex2F m_center;
|
|
|
|
ccVertex2F m_resolution;
|
|
|
|
float m_time;
|
|
|
|
GLuint m_uniformCenter, m_uniformResolution, m_uniformTime;
|
2012-10-18 10:15:46 +08:00
|
|
|
std::string m_vertFileName;
|
|
|
|
std::string m_fragFileName;
|
2012-03-21 17:27:13 +08:00
|
|
|
};
|
|
|
|
|
2012-11-20 16:16:16 +08:00
|
|
|
class ShaderFail : public ShaderTestDemo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShaderFail();
|
|
|
|
std::string title();
|
|
|
|
std::string subtitle();
|
|
|
|
};
|
|
|
|
|
2012-03-21 17:27:13 +08:00
|
|
|
class ShaderTestScene : public TestScene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void runThisTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
//CCLayer* nextAction();
|
|
|
|
|
|
|
|
#endif
|