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.
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
45
typedef
enum
{
MO_SHADER_GLSL
,
MO_SHADER_CG
}
moShaderLanguage
;
46
59
class
LIBMOLDEO_API
moTexturedGrid
:
public
moAbstract
60
{
61
public
:
65
moTexturedGrid
();
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.
144
MOint
m_size_x
;
145
MOint
m_size_y
;
146
147
// The layer 0 stores the actual grid, the other layers store the texture coordinates.
148
MOint
m_num_layers
;
149
MOfloat
m_grid_dx[
MO_MAX_TEXTURE_UNITS
+ 1];
150
MOfloat
m_grid_dy[
MO_MAX_TEXTURE_UNITS
+ 1];
151
};
152
163
class
LIBMOLDEO_API
moShader
:
public
moAbstract
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
286
moConfig
m_Config
;
287
288
protected
:
289
MOuint
m_type
;
290
moText
m_name
;
291
292
moTexturedGrid
m_grid
;
293
294
MOboolean
m_Active
;
295
MOint
m_VertErrorCode
;
296
MOint
m_FragErrorCode
;
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
moDeclareExportedDynamicArray(moShader *, moShaderArray)
moTexturedGrid::m_num_layers
MOint m_num_layers
Definition:
moShader.h:148
moShader::m_Config
moConfig m_Config
Definition:
moShader.h:286
moAbstract::Finish
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
Definition:
moAbstract.cpp:147
moTexturedGrid::m_size_x
MOint m_size_x
Definition:
moShader.h:144
moShader::GetGrid
moTexturedGrid GetGrid()
Definition:
moShader.h:270
moArray.h
moShader::SetGrid
void SetGrid(moTexturedGrid p_grid)
Definition:
moShader.h:275
moShader::m_Active
MOboolean m_Active
Definition:
moShader.h:294
moShader::m_name
moText m_name
Definition:
moShader.h:290
MOboolean
#define MOboolean
Definition:
moTypes.h:385
moShader::m_VertErrorCode
MOint m_VertErrorCode
Definition:
moShader.h:295
moShader::GetType
MOuint GetType()
Definition:
moShader.h:249
moTypes.h
moAbstract
Clase base abstracta de donde deben derivar los objetos [virtual pura].
Definition:
moAbstract.h:191
moAbstract::Init
virtual MOboolean Init()
Inicializa el objeto.
Definition:
moAbstract.cpp:141
moAbstract.h
moShader::m_grid
moTexturedGrid m_grid
Definition:
moShader.h:292
LIBMOLDEO_API
#define LIBMOLDEO_API
Definition:
moTypes.h:180
moShader::m_FragErrorCode
MOint m_FragErrorCode
Definition:
moShader.h:296
MOfloat
#define MOfloat
Definition:
moTypes.h:403
moConfig.h
moText0
clase de para manejar textos
Definition:
moText.h:75
MO_MAX_TEXTURE_UNITS
#define MO_MAX_TEXTURE_UNITS
Definition:
moShader.h:43
MOint
#define MOint
Definition:
moTypes.h:388
moShaderLanguage
moShaderLanguage
Definition:
moShader.h:45
moTexturedGrid::GetHeight
MOint GetHeight()
Definition:
moShader.h:116
moShader::SetType
void SetType(MOuint p_type)
Definition:
moShader.h:254
moTexturedGrid::GetWidth
MOint GetWidth()
Definition:
moShader.h:111
moShader
Definition:
moShader.h:163
moTexturedGrid::m_size_y
MOint m_size_y
Definition:
moShader.h:145
operator=
moMatrix3 & operator=(const moMatrix3 &rkM)
Definition:
moMathMatrix.h:2102
MOuint
#define MOuint
Definition:
moTypes.h:387
moShader::GetName
moText GetName()
Definition:
moShader.h:259
moShader::DrawGrid
void DrawGrid(MOint w, MOint h, MOint l)
Definition:
moShader.h:283
moShader::SetName
void SetName(const moText &p_name)
Definition:
moShader.h:264
MO_SHADER_GLSL
Definition:
moShader.h:45
moTexturedGrid
Definition:
moShader.h:59
MO_SHADER_CG
Definition:
moShader.h:45
moShader::m_type
MOuint m_type
Definition:
moShader.h:289
moConfig
almacena la configuración de los parámetros de un objeto en un archivo XML
Definition:
moConfig.h:193
libmoldeo
moShader.h
Generated on Wed May 17 2017 14:09:19 for libmoldeo (Moldeo 1.0 Core) by
1.8.8