soc-2008-mxcurioni: merged changes to revision 15705
[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 #define MAX_RENDER_PASS 100
32
33 class RAS_2DFilterManager
34 {
35 private:
36         unsigned int    CreateShaderProgram(char* shadersource);
37         unsigned int    CreateShaderProgram(int filtermode);
38         void            AnalyseShader(int passindex, vector<STR_String>& propNames);
39         void                    StartShaderProgram(int passindex);
40         void                    EndShaderProgram();
41
42         void SetupTextures(bool depth, bool luminance);
43         void FreeTextures();
44
45         void UpdateOffsetMatrix(RAS_ICanvas* canvas);
46
47         float                   textureoffsets[18];
48         float                   view[4];
49         /* texname[0] contains render to texture, texname[1] contains depth texture,  texname[2] contains luminance texture*/
50         unsigned int    texname[3]; 
51         int                             texturewidth;
52         int                             textureheight;
53         int                             canvaswidth;
54         int                             canvasheight;
55         int                             numberoffilters;
56         /* bit 0: enable/disable depth texture
57          * bit 1: enable/disable luminance texture*/
58         short                   texflag[MAX_RENDER_PASS];
59
60         bool                    isshadersupported;
61
62         unsigned int    m_filters[MAX_RENDER_PASS];
63         short           m_enabled[MAX_RENDER_PASS];
64
65         // stores object properties to send to shaders in each pass
66         vector<STR_String>      m_properties[MAX_RENDER_PASS];
67         void* m_gameObjects[MAX_RENDER_PASS];
68 public:
69         enum RAS_2DFILTER_MODE {
70                 RAS_2DFILTER_ENABLED = -2,
71                 RAS_2DFILTER_DISABLED = -1,
72                 RAS_2DFILTER_NOFILTER = 0,
73                 RAS_2DFILTER_MOTIONBLUR,
74                 RAS_2DFILTER_BLUR,
75                 RAS_2DFILTER_SHARPEN,
76                 RAS_2DFILTER_DILATION,
77                 RAS_2DFILTER_EROSION,
78                 RAS_2DFILTER_LAPLACIAN,
79                 RAS_2DFILTER_SOBEL,
80                 RAS_2DFILTER_PREWITT,
81                 RAS_2DFILTER_GRAYSCALE,
82                 RAS_2DFILTER_SEPIA,
83                 RAS_2DFILTER_INVERT,
84                 RAS_2DFILTER_CUSTOMFILTER,
85                 RAS_2DFILTER_NUMBER_OF_FILTERS
86         };
87
88         RAS_2DFilterManager();
89
90         ~RAS_2DFilterManager();
91
92         void RenderFilters(RAS_ICanvas* canvas);
93
94         void EnableFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text);
95 };
96 #endif