added 3dengfx into the repo, probably not the correct version for this
[summerhack] / src / 3dengfx / src / dsys / fx.hpp
1 /*
2 This file is part of the 3dengfx demo system.
3
4 Copyright (c) 2004, 2005 John Tsiombikas <nuclear@siggraph.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20 #ifndef _FX_HPP_
21 #define _FX_HPP_
22
23 #include "n3dmath2/n3dmath2.hpp"
24 #include "gfx/color.hpp"
25 #include "3dengfx/3denginefx_types.hpp"
26
27 class Texture;
28
29 namespace dsys {
30
31         enum {BLUR_DIR_X, BLUR_DIR_Y};
32         
33         // effects
34         void radial_blur(Texture *tex, float ammount, const Vector2 &origin = Vector2(0.5f, 0.5f), bool additive = false);
35         void dir_blur(Texture *tex, float ammount, int dir);
36         //void blur(Texture *tex, float ammount, bool additive = false);
37         void overlay(Texture *tex, const Vector2 &corner1, const Vector2 &corner2, const Color &color, GfxProg *pprog=0, bool handle_blending = true);
38         void negative(const Vector2 &corner1 = Vector2(0,0), const Vector2 &corner2 = Vector2(1,1));
39         void flash(unsigned long time, unsigned long when, unsigned long dur, const Color &col = Color(1,1,1));
40         
41         // integration with the scripting system
42         
43         class ImageFx;
44
45         void add_image_fx(ImageFx *fx);
46         void remove_image_fx(ImageFx *fx);
47         void apply_image_fx(unsigned long time);
48
49         class ImageFx {
50         protected:
51                 unsigned long time, duration;
52
53         public:
54                 ImageFx();
55                 virtual ~ImageFx();
56                 virtual bool parse_script_args(const char **args);
57
58                 virtual void set_time(unsigned long time);
59                 virtual void set_duration(unsigned long dur);
60
61                 virtual void apply(unsigned long time) = 0;
62         };
63
64         class FxNegative : public ImageFx {
65         public:
66                 virtual ~FxNegative();
67                 virtual void apply(unsigned long time);
68         };
69
70         class FxFlash : public ImageFx {
71         protected:
72                 Color color;
73
74         public:
75                 FxFlash();
76                 virtual ~FxFlash();
77                 virtual bool parse_script_args(const char **args);
78                 
79                 virtual void set_color(const Color &col);
80                 virtual void apply(unsigned long time);
81         };
82
83         class FxFade : public ImageFx {
84         protected:
85                 Color color1, color2;
86                 Texture *tex1, *tex2;
87
88         public:
89                 FxFade();
90                 virtual ~FxFade();
91                 virtual bool parse_script_args(const char **args);
92
93                 virtual void apply(unsigned long time);
94         };
95
96         class FxOverlay : public ImageFx {
97         protected:
98                 Texture *tex;
99                 GfxProg *shader;
100
101         public:
102                 FxOverlay();
103                 virtual ~FxOverlay();
104                 virtual bool parse_script_args(const char **args);
105
106                 virtual void set_texture(Texture *tex);
107                 virtual void set_shader(GfxProg *sdr);
108                 virtual void apply(unsigned long time);
109         };
110 }
111
112 #endif  // _FX_HPP_