OSDN Git Service

first
[psychlops/cpp.git] / psychlops / extension / standard / shader / psychlops_g_shader_fig.h
1 /*
2  *  psychlops_g_shader_fig.h
3  *  Psychlops Standard Library (Universal)
4  *
5  *  Last Modified 2009/12/14 by Kenchi HOSOKAWA
6  *  (C) 2009 Kenchi HOSOKAWA, Kazushi MARUYA and Takao SATO
7  */
8
9 #ifndef HEADER_PSYCHLOPS_GRAPHIC_SHADER_FIGURES
10 #define HEADER_PSYCHLOPS_GRAPHIC_SHADER_FIGURES
11
12 #include "psychlops_g_shader.h"
13
14
15 namespace Psychlops {
16
17         class ShaderInterface {
18                 public:
19                 enum Version { AUTO_DETECT, GLSL1_1 };
20                 static void reparseGLSL1_1(const std::string &source, std::string &result, std::vector<std::string> &args);
21         };
22
23 namespace Figures {
24
25         class ShaderImage {
26         protected:
27                 Shader api;
28                 bool initialized;
29         public:
30                 std::string orig_source;
31                 std::vector<std::string> orig_args;
32                 double arg_tmp[16];
33         public:
34                 virtual ~ShaderImage();
35                 ShaderImage();
36                 void setBase();
37                 void setFunction(const char* source, ShaderInterface::Version reparse = ShaderInterface::AUTO_DETECT);
38                 void setFunction(const std::string &source, ShaderInterface::Version reparse = ShaderInterface::AUTO_DETECT);
39                 void argf(
40                         double  a0=0.0, double  a1=0.0, double  a2=0.0, double  a3=0.0,
41                         double  a4=0.0, double  a5=0.0, double  a6=0.0, double  a7=0.0,
42                         double  a8=0.0, double  a9=0.0, double a10=0.0, double a11=0.0,
43                         double a12=0.0, double a13=0.0, double a14=0.0, double a15=0.0
44                 );
45                 virtual void cache(DrawableWithCache &target = *DrawableWithCache::prime);
46                 void cache(const char *source, DrawableWithCache &target = *DrawableWithCache::prime);
47                 void cacheFromFile(const std::string path, DrawableWithCache &target = *DrawableWithCache::prime);
48                 virtual ShaderImage& draw(Image &img, const double *argv, const int argn, Canvas &target = *Display::the_canvas);
49                 void to(Image &dest, Image &img, const double *argv, const int argn, Canvas &media = *Display::the_canvas);
50                 ShaderImage& draw(Image &img, Canvas &target = *Display::the_canvas);
51                 void to(Image &dest, Image &img, Canvas &media = *Display::the_canvas);
52         };
53 \r
54         class ShaderImage2 : public ShaderImage\r
55         {\r
56         public:\r
57                 Image params;\r
58                 virtual void cache(DrawableWithCache &target = *DrawableWithCache::prime);\r
59                 virtual ShaderImage2& draw(Image &img, const double *argv, const int argn, Canvas &target = *Display::the_canvas);\r
60         };\r
61
62         class ShaderField {
63         protected:
64                 static Group internal_group;
65                 static Image internal_image;
66
67                 Shader api;
68                 bool initialized;
69         public:
70                 std::string orig_source;
71                 std::vector<std::string> orig_args;
72                 double arg_tmp[16];
73         public:
74                 virtual ~ShaderField();
75                 ShaderField();
76                 void setBase();
77                 void setFunction(const char* source, ShaderInterface::Version reparse = ShaderInterface::AUTO_DETECT);
78                 void setFunction(const std::string &source, ShaderInterface::Version reparse = ShaderInterface::AUTO_DETECT);
79                 void argf(
80                         double  a0=0.0, double  a1=0.0, double  a2=0.0, double  a3=0.0,
81                         double  a4=0.0, double  a5=0.0, double  a6=0.0, double  a7=0.0,
82                         double  a8=0.0, double  a9=0.0, double a10=0.0, double a11=0.0,
83                         double a12=0.0, double a13=0.0, double a14=0.0, double a15=0.0
84                 );
85                 void cache(DrawableWithCache &target = *DrawableWithCache::prime);
86                 void cache(const char *source, DrawableWithCache &target = *DrawableWithCache::prime);
87                 void cacheFromFile(const std::string path, DrawableWithCache &target = *DrawableWithCache::prime);
88                 void draw(const Rectangle &rect, const double* argv, const int argn, Drawable &target = *Display::the_canvas);
89                 void to(Image &dest, const Rectangle &rect, const double* argv, const int argn, Canvas &media = *Display::the_canvas);
90                 void draw(const Rectangle &rect, Drawable &target = *Display::the_canvas);
91                 void to(Image &dest, const Rectangle &rect, Canvas &media = *Display::the_canvas);
92         };
93
94
95
96         class ShaderCoordinateTuner : public Rectangle {
97         protected:
98                 static const char *glsl_source;
99                 static ShaderField field;
100         public:
101                 ShaderCoordinateTuner();
102                 virtual ShaderCoordinateTuner& cache(DrawableWithCache &target = *DrawableWithCache::prime);
103                 virtual ShaderCoordinateTuner& draw(Canvas &target = *Display::the_canvas);
104                 virtual void to(Image &dest, Canvas &media = *Display::the_canvas);
105         };
106
107
108         class ShaderGrating : public Rectangle {
109         protected:
110                 static const char *glsl_source;
111                 static ShaderField field;
112         public:
113                 Length wavelength;
114                 Angle orientation, phase;
115                 double contrast;
116         public:
117                 ShaderGrating();
118                 virtual ShaderGrating& setWave(double wavelen, double cont = 0.5, double orient = 0.0, double phs=0.0);
119                 virtual ShaderGrating& setWave(Length wavelen, double cont = 0.5, Angle orient = 0.0*degree, Angle phs=0.0*degree);
120                 virtual ShaderGrating& cache(DrawableWithCache &target = *DrawableWithCache::prime);
121                 virtual ShaderGrating& draw(Drawable &target = *DrawableWithCache::prime);
122                 virtual void to(Image &dest, Canvas &media = *Display::the_canvas);
123         };
124
125         class ShaderGaussianDot : public Rectangle {
126         protected:
127                 static const char *glsl_source;
128                 static ShaderField field;
129         public:
130                 Color bgcolor;
131                 ShaderGaussianDot();
132                 virtual ShaderGaussianDot& setSigma(double sigma);
133                 virtual ShaderGaussianDot& cache(DrawableWithCache &target = *DrawableWithCache::prime);
134                 virtual ShaderGaussianDot& draw(Drawable &target = *DrawableWithCache::prime);
135                 virtual void to(Image &dest, Canvas &media = *Display::the_canvas);
136         };
137
138         class ShaderGabor : public Rectangle {
139         protected:
140                 static const char *glsl_source;
141                 static ShaderField field;
142         public:
143                 Length wavelength;
144 //              Angle orientation, phase;
145                 double orientation, phase;
146                 double contrast;
147         public:
148                 ShaderGabor();
149                 virtual ShaderGabor& setSigma(double sigma);
150                 virtual ShaderGabor& setSigma(Length sigma);
151                 virtual ShaderGabor& setWave(double wavelen, double cont = 0.5, double orient = 0.0, double phs=0.0);
152                 virtual ShaderGabor& setWave(Length wavelen, double cont = 0.5, Angle orient = 0.0*degree, Angle phs=0.0*degree);
153                 virtual ShaderGabor& cache(DrawableWithCache &target = *DrawableWithCache::prime);
154                 virtual ShaderGabor& draw(Drawable &target = *DrawableWithCache::prime);
155                 virtual void to(Image &dest, Canvas &media = *Display::the_canvas);
156         };\r
157 \r
158         class ShaderGaborAlpha : public Rectangle {\r
159         protected:\r
160                 static const char *glsl_source;\r
161                 static ShaderField field;\r
162         public:\r
163                 Length wavelength;\r
164 //              Angle orientation, phase;\r
165                 double orientation, phase;\r
166                 double contrast, alpha;\r
167         public:\r
168                 ShaderGaborAlpha();\r
169                 virtual ShaderGaborAlpha& setSigma(double sigma);\r
170                 virtual ShaderGaborAlpha& setSigma(Length sigma);\r
171                 virtual ShaderGaborAlpha& setWave(double wavelen, double cont = 0.5, double orient = 0.0, double phs=0.0);\r
172                 virtual ShaderGaborAlpha& setWave(Length wavelen, double cont = 0.5, Angle orient = 0.0*degree, Angle phs=0.0*degree);\r
173                 virtual ShaderGaborAlpha& cache(DrawableWithCache &target = *DrawableWithCache::prime);\r
174                 virtual ShaderGaborAlpha& draw(Drawable &target = *DrawableWithCache::prime);\r
175                 virtual void to(Image &dest, Canvas &media = *Display::the_canvas);\r
176         };
177
178         class ShaderPlaid : public Rectangle {
179         protected:
180                 static const char *glsl_source;
181                 static ShaderField field;
182         public:
183                 Length wavelength, wavelength2;
184                 Angle orientation, orientation2, phase, phase2;
185                 double contrast, contrast2;
186         public:
187                 ShaderPlaid();
188                 virtual ShaderPlaid& setSigma(double sigma);
189                 virtual ShaderPlaid& setSigma(Length sigma);
190                 virtual ShaderPlaid& setWave(double wavelen, double cont = 0.5, double orient = 0.0, double phs=0.0);
191                 virtual ShaderPlaid& setWave(Length wavelen, double cont = 0.5, Angle orient = 0.0*degree, Angle phs=0.0*degree);
192                 virtual ShaderPlaid& setWave2(double wavelen, double cont = 0.5, double orient = 0.0, double phs=0.0);
193                 virtual ShaderPlaid& setWave2(Length wavelen, double cont = 0.5, Angle orient = 0.0*degree, Angle phs=0.0*degree);
194                 virtual ShaderPlaid& cache(DrawableWithCache &target = *DrawableWithCache::prime);
195                 virtual ShaderPlaid& draw(Drawable &target = *DrawableWithCache::prime);
196                 virtual void to(Image &dest, Canvas &media = *Display::the_canvas);
197         };\r
198 \r
199         class ShaderPlaidAlpha : public Rectangle {\r
200         protected:\r
201                 static const char *glsl_source;\r
202                 static ShaderField field;\r
203         public:\r
204                 Length wavelength, wavelength2;\r
205                 Angle orientation, orientation2, phase, phase2;\r
206                 double contrast, contrast2, alpha;\r
207         public:\r
208                 ShaderPlaidAlpha();\r
209                 virtual ShaderPlaidAlpha& setSigma(double sigma);\r
210                 virtual ShaderPlaidAlpha& setSigma(Length sigma);\r
211                 virtual ShaderPlaidAlpha& setWave(double wavelen, double cont = 0.5, double orient = 0.0, double phs=0.0);\r
212                 virtual ShaderPlaidAlpha& setWave(Length wavelen, double cont = 0.5, Angle orient = 0.0*degree, Angle phs=0.0*degree);\r
213                 virtual ShaderPlaidAlpha& setWave2(double wavelen, double cont = 0.5, double orient = 0.0, double phs=0.0);\r
214                 virtual ShaderPlaidAlpha& setWave2(Length wavelen, double cont = 0.5, Angle orient = 0.0*degree, Angle phs=0.0*degree);\r
215                 virtual ShaderPlaidAlpha& cache(DrawableWithCache &target = *DrawableWithCache::prime);\r
216                 virtual ShaderPlaidAlpha& draw(Drawable &target = *DrawableWithCache::prime);\r
217                 virtual void to(Image &dest, Canvas &media = *Display::the_canvas);\r
218         };\r
219
220
221 }       /*      <- namespace Figures    */
222 }       /*      <- namespace Psycholops         */
223
224 #endif