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.
moShader.h
Ir a la documentación de este archivo.
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;
200
virtual
void
CreateGeomShader(
const
moText
& geom_source) = 0;
201
206
virtual
void
CreateTessShader(
const
moText
& tess_source) = 0;
212
virtual
void
CreateShader(
const
moText
& vert_source,
const
moText
& frag_source) = 0;
213
virtual
void
CreateShader(
const
moText
& vert_source,
const
moText
& frag_source,
const
moText
& geom_source) = 0;
214
virtual
void
CreateShader(
const
moText
& vert_source,
const
moText
& frag_source,
const
moText
& geom_source,
const
moText
& tess_source) = 0;
219
virtual
void
LoadVertShader(
const
moText
& vert_filename) = 0;
224
virtual
void
LoadFragShader(
const
moText
& frag_filename) = 0;
229
virtual
void
LoadGeomShader(
const
moText
& geom_filename) = 0;
234
virtual
void
LoadTessShader(
const
moText
& tess_filename) = 0;
241
virtual
void
LoadShader(
const
moText
& vert_filename,
const
moText
& frag_filename) = 0;
242
virtual
void
LoadShader(
const
moText
& vert_filename,
const
moText
& frag_filename,
const
moText
& geom_filename) = 0;
243
virtual
void
LoadShader(
const
moText
& vert_filename,
const
moText
& frag_filename,
const
moText
& geom_filename,
const
moText
& tess_filename) = 0;
244
248
virtual
void
StartShader();
252
virtual
void
StopShader();
257
virtual
MOboolean
ShaderActive();
258
263
MOint
VertErrorCode();
268
MOint
FragErrorCode();
273
MOint
GeomErrorCode();
278
MOint
TessErrorCode();
283
MOuint
GetType
() {
return
m_type; }
288
void
SetType
(
MOuint
p_type) { m_type = p_type; }
293
moText
GetName
() {
return
m_name; }
298
void
SetName
(
const
moText
& p_name) { m_name = p_name; }
299
304
moTexturedGrid
GetGrid
() {
return
m_grid; }
309
void
SetGrid
(
moTexturedGrid
p_grid) { m_grid = p_grid; }
310
317
void
DrawGrid
(
MOint
w,
MOint
h,
MOint
l) { m_grid.Draw(w, h, l); }
318
319
320
321
moConfig
m_Config
;
322
323
protected
:
324
MOuint
m_type
;
325
moText
m_name
;
326
327
moTexturedGrid
m_grid
;
328
329
MOboolean
m_Active
;
330
MOint
m_VertErrorCode
;
331
MOint
m_FragErrorCode
;
332
MOint
m_GeomErrorCode
;
333
MOint
m_TessErrorCode
;
334
335
virtual
void
compileVertShader(
const
moText
& vert_source) = 0;
336
virtual
void
compileFragShader(
const
moText
& frag_source) = 0;
337
virtual
void
compileGeomShader(
const
moText
& geom_source) = 0;
338
virtual
void
compileTessShader(
const
moText
& tess_source) = 0;
339
340
virtual
moText
LoadShaderSource(
const
moText
& p_fn);
341
};
342
343
moDeclareExportedDynamicArray
(
moShader
*, moShaderArray);
344
345
346
#endif
347
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:321
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:304
moArray.h
moShader::SetGrid
void SetGrid(moTexturedGrid p_grid)
Definition:
moShader.h:309
moShader::m_Active
MOboolean m_Active
Definition:
moShader.h:329
moShader::m_name
moText m_name
Definition:
moShader.h:325
MOboolean
#define MOboolean
Definition:
moTypes.h:385
moShader::m_VertErrorCode
MOint m_VertErrorCode
Definition:
moShader.h:330
moShader::GetType
MOuint GetType()
Definition:
moShader.h:283
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:327
LIBMOLDEO_API
#define LIBMOLDEO_API
Definition:
moTypes.h:180
moShader::m_FragErrorCode
MOint m_FragErrorCode
Definition:
moShader.h:331
MOfloat
#define MOfloat
Definition:
moTypes.h:403
moShader::m_TessErrorCode
MOint m_TessErrorCode
Definition:
moShader.h:333
moShader::m_GeomErrorCode
MOint m_GeomErrorCode
Definition:
moShader.h:332
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:288
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
MOuint
#define MOuint
Definition:
moTypes.h:387
moShader::GetName
moText GetName()
Definition:
moShader.h:293
moShader::DrawGrid
void DrawGrid(MOint w, MOint h, MOint l)
Definition:
moShader.h:317
moShader::SetName
void SetName(const moText &p_name)
Definition:
moShader.h:298
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:324
moConfig
almacena la configuraci�n de los par�metros de un objeto en un archivo XML
Definition:
moConfig.h:193
libmoldeo
moShader.h
Generado el Martes, 10 de Septiembre de 2019 21:27:08 para libmoldeo (Moldeo 1.0 Core) por
1.8.13