libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo es el conjunto de objetos y funciones, que permiten ejecutar las operaciones básicas de la plataforma Moldeo, y que compone su núcleo.
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Amigas 'defines' Grupos Páginas
moTextureFilter.h
Ir a la documentación de este archivo.
1 /*******************************************************************************
2 
3  moTextureFilter.h
4 
5  ****************************************************************************
6  * *
7  * This source is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This code is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15  * General Public License for more details. *
16  * *
17  * A copy of the GNU General Public License is available on the World *
18  * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19  * obtain it by writing to the Free Software Foundation, *
20  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  * *
22  ****************************************************************************
23 
24  Copyright(C) 2006 Fabricio Costa
25 
26  Authors:
27  Fabricio Costa
28 
29 
30 *******************************************************************************/
31 
32 #ifndef __MO_TEXTURE_FILTER_H
33 #define __MO_TEXTURE_FILTER_H
34 
35 #include "moTypes.h"
36 #include "moAbstract.h"
37 #include "moConfig.h"
38 #include "moParam.h"
39 #include "moMoldeoObject.h"
40 
41 #include "moShader.h"
42 #include "moShaderGLSL.h"
43 
44 class moGLManager;
45 class moRenderManager;
46 class moShaderManager;
47 
48 #define RLUM ((float) (0.3086))
49 #define GLUM ((float) (0.6094))
50 #define BLUM ((float) (0.0820))
51 
52 #include "moTextFilterParam.h"
53 
54 #define MAX_UNIFORM_VARS 256
55 
56 // Base class to implement color transformation matrices.
58 {
59 public:
60  moColorMatrix();
61  virtual ~moColorMatrix();
62 
63  virtual void Init();
64  virtual void Finish();
65 
66  void Copy(moColorMatrix& p_mat);
67  void Multiply(moColorMatrix& p_mat);
68  void SetZero() { ZeroMatrix(); }
69  void SetIndentity() { IdentityMatrix(); }
70 
71  MOfloat* GetMatrixPointer() { return m_Matrix; }
72 protected:
73  MOfloat m_Matrix[16];
74  MOfloat m_MatrixChg[16];
75  MOfloat m_MatrixTemp[16];
76 
77  int MatIdx(int i, int j) { return j * 4 + i; }
78 
79  void ZeroMatrix();
80  void IdentityMatrix();
81 
82  void SetXRotateMatrix(float rs, float rc);
83  void SetYRotateMatrix(float rs, float rc);
84  void SetZRotateMatrix(float rs, float rc);
85  void SetZShearMatrix(float dx, float dy);
86  void XFormPoint(float &tx, float &ty, float &tz);
87 
88  void ApplyChgMatrix();
89 };
90 
91 // Class that generates a Hue/Staturation/Intensity matrix
92 // Based on the Hue/Saturation/Intensity Filter for VirtualDub
93 // written by Donald A. Graft
94 // Some useful explanations on Matrix Operations for Image Processing
95 // can be found here:
96 // http://www.graficaobscura.com/matrix/index.html
98 {
99 public:
102 
103  void Init(MOboolean p_PreserveLuminance = true,
104  MOfloat p_min_int = 0.0, MOfloat p_max_int = 2.0,
105  MOfloat p_min_sat = 0.0, MOfloat p_max_sat = 2.0,
106  MOfloat p_min_hue = 0.0, MOfloat p_max_hue = 2 * moMathf::PI);
107  void Finish();
108 
109  // Updates the matrix using the provided intensity, saturation and
110  // hue values (all in [0, 1]).
111  void Update(MOfloat p_int, MOfloat p_sat, MOfloat p_hue);
112 protected:
114  MOfloat m_int, m_sat, m_hue;
115  MOfloat m_min_int, m_max_int;
116  MOfloat m_min_sat, m_max_sat;
117  MOfloat m_min_hue, m_max_hue;
118 
119  void IntensityMatrix();
120  void SaturateMatrix();
121  void HueRotateMatrix();
122  void SimpleHueRotateMatrix();
123 };
124 
125 // Class that generates a Brightness/Contrast matrix.
127 {
128 public:
131 
132  void Init(MOfloat p_min_bright = 0.0, MOfloat p_max_bright = 2.0,
133  MOfloat p_min_cont = 0.0, MOfloat p_max_cont = 2.0);
134  void Finish();
135 
136  void Update(MOfloat p_bright, MOfloat p_cont);
137 protected:
138  MOfloat m_bright, m_cont;
139  MOfloat m_min_bright, m_max_bright;
140  MOfloat m_min_cont, m_max_cont;
141 
142  void BrightnessMatrix();
143  void ContrastMatrix();
144 };
145 
146 class moTextureIndex;
147 
148 #include "moVideoManager.h"
157 {
158 public:
162  moTextureFilter();
166  virtual ~moTextureFilter() { Finish(); }
167 
178  virtual MOboolean Init(moGLManager* p_glman, moRenderManager* p_renderman, moTextureArray &p_src_tex, moTextureArray &p_dest_tex, moShader *p_shader, const moTextFilterParam& p_params);
183  virtual MOboolean Finish();
184 
191  void Apply(MOuint p_i, MOfloat p_fade, const moTextFilterParam& p_params);
192  void Apply(MOuint p_i);
199  void Apply(MOfloat p_cycle, MOfloat p_fade, const moTextFilterParam& p_params);
200  void Apply(MOfloat p_cycle);
207  void Apply(moTempo *p_tempo, MOfloat p_fade, const moTextFilterParam& p_params);
208  void Apply(moTempo *p_tempo);
209 
210 
211  void Apply( moMoldeoObject *p_src_mob, MOfloat p_fade, const moTextFilterParam& p_params );
212  void Apply( moMoldeoObject *p_src_mob, moTempo *p_tempo, MOfloat p_fade, const moTextFilterParam& p_params);
213  void Apply( moMoldeoObject *p_src_mob);
214 
219  moTextureIndex* GetSrcTex() { return &m_src_tex; }
224  moTextureIndex* GetDestTex() { return &m_dest_tex; }
225 
226  moShader* GetShader() { return m_shader; }
227 
228 
234  void CheckDestTexAttachStatus();
235 
236 
238  m_TextureFilterLabelName = p_text;
239  }
241  return m_TextureFilterLabelName;
242  }
243 
245  return m_DefParams;
246  }
247 
248 protected:
252 
254 
255  // Shader parameters.
256  GLint m_src_tex_unit[MO_MAX_TEXTURE_UNITS];
257  GLint m_src_tex_offset[MO_MAX_TEXTURE_UNITS];
259  GLint m_tempo_dt;
266 
267 
269  int m_uniform_variables_idx[MAX_UNIFORM_VARS];
270 
271  //moTextFilterParam *m_DefParams;
273 
274  // Texture indices.
277 
278  GLboolean m_blend_on;
279  GLint m_poly_mode;
280  GLenum m_draw_buffers[MO_MAX_COLOR_ATTACHMENTS_EXT];
281 
284 
285  void SetupShader(MOint w, MOint h, moTempo *p_tempo, MOfloat p_fade, const moTextFilterParam& p_params, moMoldeoObject* p_src_object = NULL);
286  void SetGLConf(MOint w, MOint h);
287  void RestoreGLConf();
288  void BindDestFBO();
289  void UnbindDestFBO();
290 
291  void BindSrcTex(MOuint p_i);
292  void BindSrcTex(MOfloat p_cycle);
293  void BindSrcTex(moTempo *p_tempo);
294  void BindSrcTex( moMoldeoObject* p_mob );
295  void UnbindSrcTex();
296  void RenderTexQuad(MOint w, MOint h);
297 };
298 
299 moDeclareExportedDynamicArray( moTextureFilter*, moTextureFilterArray)
300 
301 #include "moVideoManager.h"
302 #include "moShaderManager.h"
303 #include "moTextureManager.h"
304 #include "moGLManager.h"
305 #include "moRenderManager.h"
306 
307 #endif
308 
moGLManager * m_glman
int MatIdx(int i, int j)
MOboolean m_reattach_dest_tex
Tempo, beat, ritmo.
Definition: moTempo.h:44
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
Definition: moAbstract.cpp:147
#define MAX_UNIFORM_VARS
moTextureIndex m_dest_tex
#define MOboolean
Definition: moTypes.h:385
moShader * GetShader()
moTextureIndex m_src_tex
Clase base abstracta de donde deben derivar los objetos [virtual pura].
Definition: moAbstract.h:191
virtual MOboolean Init()
Inicializa el objeto.
Definition: moAbstract.cpp:141
const moTextFilterParam & GetTextFilterParam()
#define LIBMOLDEO_API
Definition: moTypes.h:180
#define MOfloat
Definition: moTypes.h:403
clase de para manejar textos
Definition: moText.h:75
moTypes MOint moText moParamIndex moParamReference int iRow int int i int i
Definition: all_f.js:18
MOboolean m_PreserveLuminance
virtual ~moTextureFilter()
moText m_TextureFilterLabelName
#define MO_MAX_COLOR_ATTACHMENTS_EXT
Definition: moFBO.h:46
#define MO_MAX_TEXTURE_UNITS
Definition: moShader.h:43
#define MOint
Definition: moTypes.h:388
moText GetTextureFilterLabelName()
Clase Base para Objetos Moldeo ( moEffect, moIODevice, moResource, moConsole )
moTextureIndex * GetDestTex()
moRenderManager * m_renderman
const MOlong PI
Definition: moMath.cpp:44
Clase que implementa un administrador de shaders.
manejador de operaciones comunes de Open GL
Definition: moGLManager.h:154
moShader * m_shader
moTypes h
Definition: all_0.js:5
MOfloat * GetMatrixPointer()
void SetTextureFilterLabelName(moText p_text)
virtual void Finish()
#define MOuint
Definition: moTypes.h:387
virtual void Init()
#define moDeclareExportedDynamicArray(T, name)
Definition: moArrayH.h:278
moTextFilterParam m_DefParams
idx of uniform variables in shader code moShader
moTextureIndex * GetSrcTex()
GLboolean m_blend_on
MOboolean m_use_screen_tex