libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
moShader.h
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  moShader.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  Andres Colubri
29 
30  Description:
31  Base class for GLSL and Cg shaders.
32 
33 *******************************************************************************/
34 
35 #ifndef __MO_SHADER_H__
36 #define __MO_SHADER_H__
37 
38 #include "moTypes.h"
39 #include "moAbstract.h"
40 #include "moConfig.h"
41 #include "moArray.h"
42 
43 #define MO_MAX_TEXTURE_UNITS 4
44 
46 
60 {
61 public:
69  virtual ~moTexturedGrid();
70 
80  virtual MOboolean Init(MOint p_size_x, MOint p_size_y, MOint p_num_layers, const MOfloat p_grid_dx[], const MOfloat p_grid_dy[]);
87  virtual MOboolean Init(moConfig* p_cfg, MOuint p_param_idx);
92  virtual MOboolean Finish();
93 
97  void Set1QuadGrid();
98 
105  void Draw(MOint w, MOint h, MOint l);
106 
111  MOint GetWidth() { return m_size_x; }
116  MOint GetHeight() { return m_size_y; }
127  void GetPoint(MOint layer, MOint i, MOint j, MOfloat &x, MOfloat &y);
134  void SetTexCoord(MOint i, MOint j, MOint l);
135 
141  moTexturedGrid &operator = (const moTexturedGrid &p_src_grid);
142 protected:
143  // Number of points in the grid, along each direction.
146 
147  // The layer 0 stores the actual grid, the other layers store the texture coordinates.
151 };
152 
164 {
165 public:
169  moShader();
173  virtual ~moShader();
174 
179  virtual MOboolean Init();
184  virtual MOboolean Finish();
185 
190  virtual void CreateVertShader(const moText& vert_source) = 0;
195  virtual void CreateFragShader(const moText& frag_source) = 0;
201  virtual void CreateShader(const moText& vert_source, const moText& frag_source) = 0;
206  virtual void LoadVertShader(const moText& vert_filename) = 0;
211  virtual void LoadFragShader(const moText& frag_filename) = 0;
218  virtual void LoadShader(const moText& vert_filename, const moText& frag_filename) = 0;
219 
223  virtual void StartShader();
227  virtual void StopShader();
232  virtual MOboolean ShaderActive();
233 
238  MOint VertErrorCode();
243  MOint FragErrorCode();
244 
249  MOuint GetType() { return m_type; }
254  void SetType(MOuint p_type) { m_type = p_type; }
259  moText GetName() { return m_name; }
264  void SetName(const moText& p_name) { m_name = p_name; }
265 
270  moTexturedGrid GetGrid() { return m_grid; }
275  void SetGrid(moTexturedGrid p_grid) { m_grid = p_grid; }
276 
283  void DrawGrid(MOint w, MOint h, MOint l) { m_grid.Draw(w, h, l); }
284 
285 
287 
288 protected:
291 
293 
297 
298  virtual void compileVertShader(const moText& vert_source) = 0;
299  virtual void compileFragShader(const moText& frag_source) = 0;
300 
301  virtual moText LoadShaderSource(const moText& p_fn);
302 };
303 
304 moDeclareExportedDynamicArray( moShader*, moShaderArray);
305 
306 
307 #endif
308 
moDeclareExportedDynamicArray(moShader *, moShaderArray)
MOint m_num_layers
Definition: moShader.h:148
moConfig m_Config
Definition: moShader.h:286
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
Definition: moAbstract.cpp:147
MOint m_size_x
Definition: moShader.h:144
moTexturedGrid GetGrid()
Definition: moShader.h:270
void SetGrid(moTexturedGrid p_grid)
Definition: moShader.h:275
MOboolean m_Active
Definition: moShader.h:294
moText m_name
Definition: moShader.h:290
#define MOboolean
Definition: moTypes.h:385
MOint m_VertErrorCode
Definition: moShader.h:295
MOuint GetType()
Definition: moShader.h:249
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
moTexturedGrid m_grid
Definition: moShader.h:292
#define LIBMOLDEO_API
Definition: moTypes.h:180
MOint m_FragErrorCode
Definition: moShader.h:296
#define MOfloat
Definition: moTypes.h:403
clase de para manejar textos
Definition: moText.h:75
#define MO_MAX_TEXTURE_UNITS
Definition: moShader.h:43
#define MOint
Definition: moTypes.h:388
moShaderLanguage
Definition: moShader.h:45
MOint GetHeight()
Definition: moShader.h:116
void SetType(MOuint p_type)
Definition: moShader.h:254
MOint GetWidth()
Definition: moShader.h:111
MOint m_size_y
Definition: moShader.h:145
moMatrix3 & operator=(const moMatrix3 &rkM)
#define MOuint
Definition: moTypes.h:387
moText GetName()
Definition: moShader.h:259
void DrawGrid(MOint w, MOint h, MOint l)
Definition: moShader.h:283
void SetName(const moText &p_name)
Definition: moShader.h:264
MOuint m_type
Definition: moShader.h:289
almacena la configuración de los parámetros de un objeto en un archivo XML
Definition: moConfig.h:193