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 { THROUGH, AUTO_DETECT, GLSL1_1, GLSL3_3 };
20 static void reparseGLSL1_1(const std::string &source, std::string &result, std::vector<std::string> &args);
30 ShaderInterface::Version glslversion;
31 std::string orig_source;
32 std::vector<std::string> orig_args;
35 virtual ~ShaderImage();
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);
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
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);
55 class ShaderImage2 : public ShaderImage
\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
65 static Group internal_group;
66 static Image internal_image;
71 ShaderInterface::Version glslversion;
72 std::string orig_source;
73 std::vector<std::string> orig_args;
76 virtual ~ShaderField();
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);
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
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);
98 class ShaderCoordinateTuner : public Rectangle {
100 static const char *glsl_source;
101 static ShaderField field;
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);
110 class ShaderGrating : public Rectangle {
112 static const char *glsl_source;
113 static ShaderField field;
116 Angle orientation, phase;
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);
127 class ShaderGaussianDot : public Rectangle {
129 static const char *glsl_source;
130 static ShaderField field;
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);
140 class ShaderGabor : public Rectangle {
142 static const char *glsl_source;
143 static ShaderField field;
146 // Angle orientation, phase;
147 double orientation, phase;
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);
160 class ShaderGaborAlpha : public Rectangle {
\r
162 static const char *glsl_source;
\r
163 static ShaderField field;
\r
166 // Angle orientation, phase;
\r
167 double orientation, phase;
\r
168 double contrast, alpha;
\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
180 class ShaderPlaid : public Rectangle {
182 static const char *glsl_source;
183 static ShaderField field;
185 Length wavelength, wavelength2;
186 Angle orientation, orientation2, phase, phase2;
187 double contrast, contrast2;
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);
201 class ShaderPlaidAlpha : public Rectangle {
\r
203 static const char *glsl_source;
\r
204 static ShaderField field;
\r
206 Length wavelength, wavelength2;
\r
207 Angle orientation, orientation2, phase, phase2;
\r
208 double contrast, contrast2, alpha;
\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
223 } /* <- namespace Figures */
224 } /* <- namespace Psycholops */