2 * psychlops_g_shader_fig.h
3 * Psychlops Standard Library (Universal)
5 * Last Modified 2009/12/14 by Kenchi HOSOKAWA
6 * (C) 2009 Kenchi HOSOKAWA, Kazushi MARUYA and Takao SATO
9 #ifndef HEADER_PSYCHLOPS_GRAPHIC_SHADER_FIGURES
10 #define HEADER_PSYCHLOPS_GRAPHIC_SHADER_FIGURES
12 #include "psychlops_g_shader.h"
17 class ShaderInterface {
19 enum Version { AUTO_DETECT, GLSL1_1 };
20 static void reparseGLSL1_1(const std::string &source, std::string &result, std::vector<std::string> &args);
30 std::string orig_source;
31 std::vector<std::string> orig_args;
34 virtual ~ShaderImage();
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);
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
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);
54 class ShaderImage2 : public ShaderImage
\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
64 static Group internal_group;
65 static Image internal_image;
70 std::string orig_source;
71 std::vector<std::string> orig_args;
74 virtual ~ShaderField();
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);
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
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);
96 class ShaderCoordinateTuner : public Rectangle {
98 static const char *glsl_source;
99 static ShaderField field;
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);
108 class ShaderGrating : public Rectangle {
110 static const char *glsl_source;
111 static ShaderField field;
114 Angle orientation, phase;
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);
125 class ShaderGaussianDot : public Rectangle {
127 static const char *glsl_source;
128 static ShaderField field;
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);
138 class ShaderGabor : public Rectangle {
140 static const char *glsl_source;
141 static ShaderField field;
144 // Angle orientation, phase;
145 double orientation, phase;
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);
158 class ShaderGaborAlpha : public Rectangle {
\r
160 static const char *glsl_source;
\r
161 static ShaderField field;
\r
164 // Angle orientation, phase;
\r
165 double orientation, phase;
\r
166 double contrast, alpha;
\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
178 class ShaderPlaid : public Rectangle {
180 static const char *glsl_source;
181 static ShaderField field;
183 Length wavelength, wavelength2;
184 Angle orientation, orientation2, phase, phase2;
185 double contrast, contrast2;
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);
199 class ShaderPlaidAlpha : public Rectangle {
\r
201 static const char *glsl_source;
\r
202 static ShaderField field;
\r
204 Length wavelength, wavelength2;
\r
205 Angle orientation, orientation2, phase, phase2;
\r
206 double contrast, contrast2, alpha;
\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
221 } /* <- namespace Figures */
222 } /* <- namespace Psycholops */