OSDN Git Service

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