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
moGLManager.h
Ir a la documentación de este archivo.
1 /*******************************************************************************
2 
3  moGLManager.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  Andrés Colubri
29 
30 *******************************************************************************/
31 
32 #ifndef __MO_GLMANAGER_H__
33 #define __MO_GLMANAGER_H__
34 
35 #define MO_GPU_NV 0
36 #define MO_GPU_ATI 1
37 #define MO_GPU_INTEL 2
38 #define MO_GPU_OTHER 3
39 
40 #include "moTypes.h"
41 #include "moText.h"
42 #include "moMathMatrix.h"
43 #include "moShaderGLSL.h"
44 #include "moFBO.h"
45 
46 #include "moResourceManager.h"
47 
48 
49 typedef void* moGLContext;
50 typedef void* moDisplayServer;
51 typedef void* moDisplayScreen;
52 typedef void* moDisplayWindow;
53 
54 /*
55 class moGLContext {
56 
57  public:
58  moGLContext();
59  virtual ~moGLContext();
60 
61  void *m_Context;
62 };
63 */
64 
65 
67 
72 
73  public:
74  moGLMatrixf(bool bZero = true) : moMatrix4f(bZero) {}
75  moGLMatrixf( const moMatrix4f& p_src ) : moMatrix4f( p_src ) {}
76  moGLMatrixf( const moGLMatrixf& rkM );
77  moGLMatrixf& operator= (const moGLMatrixf& rkM );
78  virtual ~moGLMatrixf() {}
79  //const moGLMatrixf& operator= (const moMatrix4f& p_src );
80 
81 // operator const moMatrix4f* () const { return (moMatrix4f*) this; }
82  inline operator const float* () const { return moMatrix4f::GetPointer(); }
83  inline operator float* () { return moMatrix4f::GetPointer(); }
84  //inline const float* operator[] (int iRow) const { return moMatrix4f::GetRow(iRow); }
85  //inline float* operator[] (int iRow) { return moMatrix4f::GetRow(iRow); }
86  // inline float operator() (int iRow, int iCol) const { return moMatrix4f::Get( iRow, iCol); }
87  // inline float& operator() (int iRow, int iCol) { return m_afEntry[iCol+4*iRow]; }
88 
91  moGLMatrixf& MakePerspective( float fovy, float aspect, float zNear, float zFar );
92  moGLMatrixf& MakeLookAt( float eyeX=0.0, float eyeY=0.0, float eyeZ=-10.0, float centerX=0.0, float centerY=0.0, float centerZ=0.0, float upX=0.0, float upY=0.0, float upZ=1.0 );
93  moGLMatrixf& MakeFrustrum( float left=-1.0, float right=1.0, float bottom=-1.0, float top=1.0, float near=0.0001, float far=1000.0f );
94  moGLMatrixf& MakeOrthographic( float left=-1.0, float right=1.0, float bottom=-1.0, float top=1.0, float near=0.0001, float far=1000.0f );
95  moGLMatrixf& Translate( float x, float y, float z );
96  moGLMatrixf& Translate( const moGLMatrixf& m, float x, float y, float z );
97  moGLMatrixf& Rotate( float angle, float vx, float vy, float vz );
98  moGLMatrixf& Rotate( const moGLMatrixf& m, float rx, float ry, float rz );
99  moGLMatrixf& Scale( float sx, float sy, float sz );
100  moGLMatrixf& Scale( const moGLMatrixf& m, float sx, float sy, float sz );
101 
102  moText ToJSON() const;
103  static const moGLMatrixf ZERO;
104  static const moGLMatrixf IDENTITY;
105 
106 };
107 
108 
110  public:
112  virtual ~moGLMatrixd() { }
113 };
114 
116 
117  public:
118  moGLViewport( float p_width=1.0, float p_height=1.0 ): moVector2f() {
119  X()=p_width;
120  Y()=p_height;
121  Proportion = 1.0;
122  if (Y()>0.0) {
123  Proportion = X()/Y();
124  }
125  }
126  virtual ~moGLViewport() {}
127 
128  moGLViewport( const moGLViewport& p_src ): moVector2f() {
129  (*this) = p_src;
130  }
131 
133  X() = p_src.X();
134  Y() = p_src.Y();
135  Proportion = p_src.Proportion;
136  return (*this);
137  }
138 
139  float GetWidth() { return X(); }
140  float GetHeight() { return Y(); }
141  float GetProportion() { return Proportion; }
142  float GetProportionInvert() { return 1.0/Proportion; }
143 
144  float Proportion;
145 
146 };
147 
148 
150 
155 {
156  public:
160  moGLManager();
164  virtual ~moGLManager();
165 
170  virtual MOboolean Init();
175  virtual MOboolean Finish();
176 
182  MOboolean CheckErrors(moText p_location);
183 
188  MOuint GetGPUVendorCode() { return m_gpu_vendor_code; }
193  const moText& GetGPUVendorString() { return m_gpu_vendor_string; }
198  const moText& GetGPURendererString() { return m_gpu_renderer_string; }
199 
207  void SetPerspectiveView(MOint p_width, MOint p_height, double fovy=60.0, double aspect=1.0, double znear=0.1, double zfar=4000.0 );
208  void LookAt( float eyeX=0.0, float eyeY=0.0, float eyeZ=-10.0, float centerX=0.0, float centerY=0.0, float centerZ=0.0, float upX=0.0, float upY=0.0, float upZ=1.0 );
209 
226  void SetDefaultPerspectiveView(MOint p_width, MOint p_height);
227 
234  void SetOrthographicView(MOint p_width=0, MOint p_height=0, float left=0.0, float right=1.0, float bottom=0.0, float top=1.0, float znear=-1.0, float zfar=1.0);
235 
248  void SetDefaultOrthographicView( MOint p_width=0, MOint p_height=0 );
249 
255  MOint GetRenderMode();
260  void SetRenderMode(MOint p_mode);
261 
266  void SetMoldeoGLState();
271  void SetDefaultGLState();
275  void SetDefaultPixelStorageModes();
280  void SaveGLState();
284  void SaveGLMatrices();
288  void SaveView();
292  void SaveFramebuffer();
296  void RestoreGLState();
300  void RestoreGLMatrices();
305  void RestoreView();
310  void RestoreFramebuffer();
311 
319  moTexParam BuildFPTexParam(MOboolean p_16bits = true, MOushort p_num_components = 4);
325  MOboolean RectTexture(GLenum p_target) const;
331  MOboolean FPTexture(GLint p_internal_format);
337  MOboolean MipMapTexture(GLint p_min_filter);
338 
343  void SetCurrentFBO(MOuint m_fbo);
348  MOuint GetCurrentFBO() { return m_current_fbo; }
349 
354  void SetCurrentReadBuffer(MOint p_buffer);
359  MOint GetCurrentReadBuffer() { return m_current_read_buffer; }
364  void SetCurrentDrawBuffer(MOint p_buffer);
369  MOint GetCurrentDrawBuffer() { return m_current_draw_buffer; }
373  void SaveFBOState();
377  void RestoreFBOState();
378 
379  const moText& GetGLVersion() {
380  return m_gl_version;
381  }
382 
384  return m_gl_major_version;
385  }
387  return m_gl_minor_version;
388  }
389 
390  int CreateContext( int p_width, int p_height );
391  moGLContext GetContext();
392  void SetContext(moGLContext p_Context);
393  moDisplayServer GetDisplayServer();
394  moDisplayScreen GetDisplayScreen();
395  moDisplayWindow GetDisplayWindow();
396 
397  void SetFrameBufferObjectActive( bool active = true );
398 
399  moGLMatrixf& GetModelMatrix();
400  moGLMatrixf& SetModelMatrix( const moGLMatrixf& p_mat4 );
401  moGLMatrixf& GetProjectionMatrix();
402  moGLMatrixf& SetProjectionMatrix( const moGLMatrixf& p_mat4 );
403  const moGLViewport& GetViewport() const { return m_Viewport; }
404 
405  private:
406 
407  moGLContext m_Context;
408  moDisplayServer m_DisplayServer;
409  moDisplayScreen m_DisplayScreen;
410  moDisplayWindow m_DisplayWindow;
411 
412  MOuint m_gpu_vendor_code;
413  moText m_gpu_vendor_string;
414  moText m_gpu_renderer_string;
415 
416  moText m_gl_version;
417  MOint m_gl_major_version;
418  MOint m_gl_minor_version;
419 
420  MOuint m_current_fbo;
421  MOint m_current_read_buffer;
422  MOint m_current_draw_buffer;
423  MOuint m_previous_fbo;
424  MOint m_previous_read_buffer;
425  MOint m_previous_draw_buffer;
426  MOuint m_saved_fbo;
427  MOint m_saved_read_buffer;
428  MOint m_saved_draw_buffer;
429 
430  moGLViewport m_Viewport;
431  moGLMatrixf m_ModelMatrix;
432  moGLMatrixf m_ProjectionMatrix;
433  moGLMatrixf* m_StackModelMatrices;
434  moGLMatrixf* m_StackProjectionMatrices;
435 
436  bool m_bFrameBufferObjectActive;
437 
438  void QueryGPUVendorString();
439 };
440 
441 
442 #endif
int GetGLMajorVersion()
Definition: moGLManager.h:383
Parámetros internos de una textura.
Definition: moTypes.h:543
MOuint GetCurrentFBO()
Definition: moGLManager.h:348
moVector2 & operator=(const moVector2 &rkV)
Definition: moMathVector.h:83
Recurso ( objeto para cargar y manipular objetos físicos de datos de imágenes, audio, video, 3d, 2d, fuentes, shaders y de cualquier otro tipo extendible por un plugin )
float Proportion
Definition: moGLManager.h:144
#define MOboolean
Definition: moTypes.h:385
float GetWidth()
Definition: moGLManager.h:139
Matrices para transformaciones en Open GL.
Definition: moGLManager.h:71
static const moGLMatrixf ZERO
Definition: moGLManager.h:103
void * moGLContext
Definition: moGLManager.h:49
function x(bx)
Definition: jquery.js:30
f
Definition: jquery.js:71
moGLViewport(float p_width=1.0, float p_height=1.0)
Definition: moGLManager.h:118
virtual ~moGLMatrixf()
Definition: moGLManager.h:78
moGLMatrixf(const moMatrix4f &p_src)
Definition: moGLManager.h:75
moGLMatrixf(bool bZero=true)
Definition: moGLManager.h:74
const moText & GetGLVersion()
Definition: moGLManager.h:379
#define LIBMOLDEO_API
Definition: moTypes.h:180
const moGLViewport & GetViewport() const
Definition: moGLManager.h:403
virtual MOboolean Init()
const moText & GetGPURendererString()
Definition: moGLManager.h:198
float GetProportionInvert()
Definition: moGLManager.h:142
clase de para manejar textos
Definition: moText.h:75
#define MOushort
Definition: moTypes.h:402
void * moDisplayScreen
Definition: moGLManager.h:51
#define MOint
Definition: moTypes.h:388
virtual ~moGLViewport()
Definition: moGLManager.h:126
void * moDisplayWindow
Definition: moGLManager.h:52
virtual ~moGLMatrixd()
Definition: moGLManager.h:112
static const moGLMatrixf IDENTITY
Definition: moGLManager.h:104
Real X() const
Definition: moMathVector.h:77
MOuint GetGPUVendorCode()
Definition: moGLManager.h:188
Real Y() const
Definition: moMathVector.h:79
float GetProportion()
Definition: moGLManager.h:141
float GetHeight()
Definition: moGLManager.h:140
moMatrix3< Real > & MakeZero()
Definition: moMathMatrix.h:804
manejador de operaciones comunes de Open GL
Definition: moGLManager.h:154
moMatrix4< MOfloat > moMatrix4f
virtual MOboolean Finish()
moGLViewport(const moGLViewport &p_src)
Definition: moGLManager.h:128
MOint GetCurrentReadBuffer()
Definition: moGLManager.h:359
moMatrix3 & operator=(const moMatrix3 &rkM)
const moText & GetGPUVendorString()
Definition: moGLManager.h:193
moMatrix4< MOdouble > moMatrix4d
#define MOuint
Definition: moTypes.h:387
moMatrix3< Real > & MakeIdentity()
Definition: moMathMatrix.h:819
void * moDisplayServer
Definition: moGLManager.h:50
MOint GetCurrentDrawBuffer()
Definition: moGLManager.h:369
int GetGLMinorVersion()
Definition: moGLManager.h:386