cff868556e004d166be65f48cdab5ef1c09be787
[blender.git] / source / gameengine / Rasterizer / RAS_2DFilterManager.h
1 /**
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  *
18  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): none yet.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 #ifndef __RAS_I2DFILTER
29 #define __RAS_I2DFILTER
30
31
32
33 #define MAX_RENDER_PASS 100
34
35 class RAS_2DFilterManager
36 {
37 private:
38         unsigned int    CreateShaderProgram(char* shadersource);
39         unsigned int    CreateShaderProgram(int filtermode);
40         void                    StartShaderProgram(unsigned int shaderprogram);
41         void                    EndShaderProgram();
42
43         float                   textureoffsets[18];
44         float                   view[4];
45         unsigned int    texname;
46         int                             texturewidth;
47         int                             textureheight;
48         int                             canvaswidth;
49         int                             canvasheight;
50         int                             numberoffilters;
51
52         bool                    isshadersupported;
53 public:
54         enum RAS_2DFILTER_MODE {
55                 RAS_2DFILTER_ENABLED = -2,
56                 RAS_2DFILTER_DISABLED = -1,
57                 RAS_2DFILTER_NOFILTER = 0,
58                 RAS_2DFILTER_MOTIONBLUR,
59                 RAS_2DFILTER_BLUR,
60                 RAS_2DFILTER_SHARPEN,
61                 RAS_2DFILTER_DILATION,
62                 RAS_2DFILTER_EROSION,
63                 RAS_2DFILTER_LAPLACIAN,
64                 RAS_2DFILTER_SOBEL,
65                 RAS_2DFILTER_PREWITT,
66                 RAS_2DFILTER_GRAYSCALE,
67                 RAS_2DFILTER_SEPIA,
68                 RAS_2DFILTER_INVERT,
69                 RAS_2DFILTER_CUSTOMFILTER,
70                 RAS_2DFILTER_NUMBER_OF_FILTERS
71         };
72
73         unsigned int    m_filters[MAX_RENDER_PASS];
74         short                   m_enabled[MAX_RENDER_PASS];
75
76         RAS_2DFilterManager();
77
78         ~RAS_2DFilterManager();
79
80         void SetupTexture();
81
82         void UpdateOffsetMatrix(int width, int height);
83
84         void RenderFilters(RAS_ICanvas* canvas);
85
86         void EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_String& text);
87 };
88 #endif