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
moTexture.h
Go to the documentation of this file.
1 /*******************************************************************************
2 
3  moTexture.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 *******************************************************************************/
31 
32 #ifndef __MO_TEXTURE_H__
33 #define __MO_TEXTURE_H__
34 
35 #include "moTypes.h"
36 #include "moText.h"
37 #include "moParam.h"
38 #include "moBuckets.h"
39 #include "moVideoGraph.h"
40 #include "moGsGraph.h"
41 #include "moDsGraph.h"
42 #include "moMathVector3.h"
43 
44 typedef void moBitmap;
45 typedef int moBitmapFormat;
46 typedef void moMemory;
47 
49 
52 typedef enum {
61 
62 class moFBO;
63 class moTexture;
64 class moGLManager;
65 class moDataManager;
66 class moFile;
67 class moFileManager;
68 class moResourceManager;
69 
70 
72 
79  public:
83  moTexture();
87  virtual ~moTexture();
88 
97  virtual MOboolean Init(moText p_name, MOuint p_moid, moResourceManager* p_res, moTexParam p_param = MODefTex2DParams);
102  virtual MOboolean Finish();
103 
110  MOboolean BuildEmpty(MOuint p_width, MOuint p_height);
120  MOboolean BuildFromBuffer(MOuint p_width, MOuint p_height, const GLvoid* p_buffer, GLenum p_format = GL_RGBA, GLenum p_type = GL_UNSIGNED_BYTE);
126  MOboolean BuildFromFile(moText p_filename);
127 
133  MOboolean SupportedFile(moText p_filename);
134 
140  MOboolean Load( moParam* p_param );
141  MOboolean Load( moValue* p_value );
142 
150  MOboolean SetBuffer( const GLvoid* p_buffer, GLenum p_format = GL_RGBA, GLenum p_type = GL_UNSIGNED_BYTE);
160  MOboolean SetBuffer(MOuint p_width, MOuint p_height, const GLvoid* p_buffer, GLenum p_format = GL_RGBA, GLenum p_type = GL_UNSIGNED_BYTE);
161 
169  MOboolean GetBuffer(GLvoid* p_buffer, GLenum p_format = GL_RGBA, GLenum p_type = GL_UNSIGNED_BYTE);
170 
175  void SetGLMan(moGLManager* p_gl) { m_gl = p_gl; }
180  void SetDataMan(moDataManager* p_dataman) { m_pDataMan = p_dataman; }
185  void SetFileMan(moFileManager* p_fileman) { m_pFileMan = p_fileman; }
186 
191  void SetFBO(moFBO* p_fbo) { m_fbo = p_fbo; }
198  MOuint SetFBOandAttachPoint(moFBO* p_fbo);
203  void SetFBOAttachPoint(MOuint p_fbo_attach_point) { m_fbo_attach_point = p_fbo_attach_point; }
208  moFBO* GetFBO() const { return m_fbo; }
213  MOuint GetFBOAttachPoint() const { return m_fbo_attach_point; }
214 
219  moTextureType GetType() const { return m_type; }
224  MOuint GetGLId() const { return m_glid; }
230  MOuint GetGLId( moMoldeoObject* p_src_mob );
235  MOuint GetMOId() const { return m_moid; }
240  void SetMOId(MOuint p_moid) { m_moid = p_moid; }
245  moText GetName() const { return m_name; }
250  void SetName(moText p_name) { m_name = p_name; }
251 
256  MOuint GetWidth() const { return m_width; }
261  MOuint GetHeight() const { return m_height; }
268  MOuint GetDataWidth() const;
275  MOuint GetDataHeight() const;
280  MOuint GetComponents() const { return m_components; }
285  MOlong GetTexelCount() const { return m_width * m_height * m_components; }
290  MOlong GetDataTexelCount() const { return GetDataWidth() * GetDataHeight() * m_components; }
291 
296  MOfloat GetMaxCoordS() const { return m_max_coord_s; }
301  MOfloat GetMaxCoordT() const { return m_max_coord_t; }
302 
307  moTexParam GetTexParam() const { return m_param; }
312  GLenum GetTexTarget() const { return m_param.target; }
318  GLenum GetTexInternalFormat() const { return m_param.internal_format; }
324  GLint GetMinFilter() const { return m_param.min_filter; }
329  GLint GetMagFilter() const { return m_param.mag_filter; }
334  GLint GetWrapS() const { return m_param.wrap_s; }
339  GLint GetWrapT() const { return m_param.wrap_t; }
340 
346  void FlipBufferVert(MOubyte *pBuffer, MOint p_depth);
347 
356  void CopyFromTex(moTexture* p_src_tex, MOboolean p_copy_glid, MOboolean p_copy_moid, MOboolean p_copy_type, MOboolean p_copy_name);
357  moTexture &operator = (const moTexture &p_src_tex);
358 
364  return m_bBuildedFromFile;
365  }
366 
377  moText CreateThumbnail( moText p_bufferformat, int w, int h, moText newfilename = moText("") );
378 
379  bool CalculateLuminanceAndConstrast( int x0 = 0, int y0 = 0, int x1 = 0, int y1 = 0 );
380 
381  int GetLuminance() const { return Luminance; }
382  int GetContrast() const { return Contrast; }
383  static MOuint NextPowerOf2(MOuint p_seed);
384  MOboolean Refresh();
385 
386 protected:
387 
389 
395 
398 
403 
411 
412  void SetParam();
413  void CalculateSize(MOuint p_width, MOuint p_height);
414  MOboolean Build();
415 
417  int Contrast;
418 
419  moDWord Histogram[256];
424  bool ResetBufferData( bool force_creation = false, int bytes_per_pixel=0 );
425 };
426 
427 
428 moDeclareExportedDynamicArray( moTexture*, moTextureArray);
429 
430 
431 
433 
443  public:
447  moTextureMemory();
451  virtual ~moTextureMemory();
452 
461  virtual MOboolean Init( moText p_name, MOuint p_moid, moResourceManager* p_res, moTexParam p_param = MODefTex2DParams);
462 
463  virtual MOboolean Init( moText p_name, MOuint p_moid, moResourceManager* p_res, moText bufferformat, moBitmap* pImageResult, moTexParam p_param = MODefTex2DParams );
464 
465  //virtual MOboolean BuildFromFile( moText p_filename );
466 
467  //virtual MOboolean BuildFromFile( moText p_filename, moText p_bufferformat );
468 
470  virtual MOboolean BuildFromMemory();
471 
473  virtual MOboolean BuildFromBitmap( moBitmap* p_bitmap, moText p_bufferformat = "JPG" );
474 
475 
477  virtual MOboolean LoadFromBitmap( moBitmap* p_bitmap );
478 
479 
484  virtual MOboolean Finish();
485 
491  int GetReference();
492 
496  void ReleaseReference();
497 
498  int GetContrast() { return Contrast; }
499 
500  int GetLuminance() { return Luminance; }
501 
502 
504  moVector3f GetColorMatrixCorner( int corner ) { return color_matrix[corner]; }
505  moVector3f GetColorAverage() { return color_average; }
506 
507  private:
508 
509  //four corners average color
510  moVector3f color_matrix[4];
511  moVector3f color_average;
512 
513  MOint reference_counter;
514 
515  MOint options;
516 
517  moMemory *hmem;
518  moBitmapFormat fif;
519  //FIBITMAP *m_pImage;
520 
521  MOlong m_SizeInMemory;
522 
523  moText m_BufferFormat;
524  MOboolean m_bBitmapInMemory;
525 
528 
530  MOint Contrast;
531 
533  moDWord Histogram[256];
534 
535 };
536 
537 #include "moTextureIndex.h"
538 
539 class moShader;
540 class moTextureFilter;
541 
543 
550 {
551  public:
559  virtual ~moTextureAnimated();
560 
568  virtual MOboolean Init(moText p_name, MOuint p_moid, moResourceManager* p_res, moTexParam p_param = MODefTex2DParams);
573  virtual MOboolean Finish();
574 
578  virtual void Play();
579 
583  virtual void Stop();
584 
589  virtual bool IsPlaying();
590 
591 
597  virtual MOint GetGLId( moTempo *tempo );
603  virtual MOint GetGLId( MOuint p_i );
609  virtual MOint GetGLId( MOfloat p_cycle );
610 
615  virtual MOuint GetFrameCount() { return m_nFrames; }
620  virtual void SetFrameCount( MOuint p_nframes ) { m_nFrames = p_nframes; } //
621 
626  virtual MOfloat GetFramesPerSecond() { return m_fFramesPerSecond; }
627 
632  virtual void SetFramesPerSecond( MOfloat p_fps) { m_fFramesPerSecond = p_fps; }
633 
634 
635  enum moPlayMode {
637  MO_PLAYMODE_FRAMEBASE
638  };
646  virtual void SetPlayMode( moPlayMode playmode );
647 
655  virtual moPlayMode GetPlayMode();
656 
661  virtual void GetFrame( MOuint p_i );
662 
663  virtual MOuint GetActualFrame();
664 
672  virtual void SetInterpolation( MOuint p_FrameJump, MOuint p_InterpolationTime );
677  virtual MOboolean IsInterpolating();
682  virtual MOboolean IsInterpolationActive();
690  virtual MOboolean ActivateInterpolation( MOboolean activate = true );
691 
692  protected:
693 
694  virtual MOboolean NeedsInterpolation();
695  virtual MOint Interpolate();
696 
700 
703 
708 
709  //interpolation flags
712 
713  //interpolation filters
717 
718  //interpolation textures
719  moTextureArray m_srcstart,m_dststart;
720  moTextureArray m_srcend,m_dstend;
721  moTextureArray m_srcinterpol,m_dstinterpol;
722 
723  //interpolation shaders
726 
727  //interpolation parameters
728  MOuint m_FrameJump;/* salto entre el cuadro inicial y final mínimo, para resolver la interpolación*/
729  MOuint m_InterpolationTime;/*intervalo de resolución de la interpolación en milisegundos*/
730 
731  //interpolation variables
733  MOuint m_FrameStart;/*cuadro inicial de la interpolación*/
734  MOuint m_FrameEnd;/*cuadro final de la interpolación*/
735  MOfloat m_InterpolationPosition;/*valor entre 0 y 1 indicando el nivel de interpolación, 0 corresponde al cuadro inicial, 1 al cuadro final*/
736 
737 };
738 
740 
745 {
746  public:
747 
756 
764  virtual MOboolean Init(moText p_name, MOuint p_moid, moResourceManager* p_res, moTexParam p_param = MODefTex2DParams);
769  virtual MOboolean Finish();
770 
775  MOboolean SupportedFile(moText p_filename);
781  MOboolean Load(moParam* p_param);
782 
788  MOboolean Load(moValue* p_value);
789 
799  MOboolean Load(moText p_name, moTextureArray &p_textures, MOuint p_id0, MOuint p_id1);
800 
805  void SetTextureCount(MOuint p_tex_count);
810  MOuint GetTextureCount() { return m_textures_array.Count(); }
815  void GetFrame(MOuint p_i);
821  void SetFrame(MOuint p_i, moTexture* p_texture);
826  void AddFrame(moTexture* p_texture);
832  moTexture* GetTexture( MOuint p_i ) { return m_textures_array[p_i]; }
833 
840  MOboolean ValidTexture(MOuint p_i);
841 
842 
843  protected:
844  moTextureArray m_textures_array;
845 
846 };
847 
849 
854 {
855  public:
859  moMovie();
863  virtual ~moMovie();
864 
872  virtual MOboolean Init(moText p_name, MOuint p_moid, moResourceManager* p_res, moTexParam p_param = MODefTex2DParams);
877  virtual MOboolean Finish();
878 
882  virtual void Play();
883  virtual void Pause();
884  virtual void Continue();
885  virtual void Stop();
886  virtual void Seek( long frame, float rate = 1.0 );
887  virtual bool IsPlaying();
888  virtual bool IsPaused();
889  virtual MOulong GetPosition();
890  virtual moStreamState State();
891 
892  virtual void SetBrightness( float brightness );
893  virtual void SetContrast( float contrast );
894  virtual void SetSaturation( float saturation );
895  virtual void SetHue( float hue );
896 
897  virtual void SetVolume( float volume );
898  virtual void SetBalance( float balance );
899 
905  MOboolean SupportedFile(moText p_filename);
910  MOboolean LoadMovieFile(moText p_filename);
916  MOboolean Load( moParam* p_param );
917  MOboolean Load( moValue* p_value );
918  MOboolean Reload( bool force_kill=true );
919 
920  void EnableVideo(int);
921  bool HasVideo();
922 
923  void EnableAudio(int);
924  bool HasAudio();
925 
926  bool IsEOS();
927 
928  protected:
929 
930  void GetFrame( MOuint p_i );
931 
936 
938 
939 };
940 
941 #include "moFBO.h"
942 #include "moGLManager.h"
943 #include "moTextureFilter.h"
944 
945 #endif
946 
Manejador de archivos.
void moBitmap
Definition: moTexture.h:44
Valor de un Parámetro.
Definition: moValue.h:501
GLenum GetTexTarget() const
Definition: moTexture.h:312
moShader * m_pShaderCopy
Definition: moTexture.h:724
Parámetros internos de una textura.
Definition: moTypes.h:543
MOfloat m_max_coord_t
Definition: moTexture.h:410
MOuint m_FrameStart
Definition: moTexture.h:733
buffer de texturas
Definition: moTexture.h:59
#define MOulong
Definition: moTypes.h:392
Tempo, beat, ritmo.
Definition: moTempo.h:44
int Luminance
Definition: moTexture.h:416
moText m_pFilename
Definition: moTexture.h:934
MOboolean m_bIsPaused
Definition: moTexture.h:699
MOboolean m_bBuildedFromFile
Definition: moTexture.h:388
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
Definition: moAbstract.cpp:147
virtual void GetFrame(MOuint p_i)
Definition: moTexture.cpp:1735
moTextureFilter * m_pCopyStart
Definition: moTexture.h:714
buffer de video
Definition: moTexture.h:57
GLint GetWrapT() const
Definition: moTexture.h:339
textura en memoria
Definition: moTexture.h:58
MOuint m_FramePrevious
Definition: moTexture.h:705
moTextureArray m_srcinterpol
Definition: moTexture.h:721
GLint GetMagFilter() const
Definition: moTexture.h:329
moResourceManager * m_pResourceManager
Definition: moTexture.h:394
#define MOboolean
Definition: moTypes.h:385
MOuint m_buffer_height
Definition: moTexture.h:422
una textura animada basada en una película
Definition: moTexture.h:853
void SetFileMan(moFileManager *p_fileman)
Definition: moTexture.h:185
void SetGLMan(moGLManager *p_gl)
Definition: moTexture.h:175
moVideoGraph * m_pGraph
Definition: moTexture.h:937
int GetContrast() const
Definition: moTexture.h:382
MOfloat m_fFramesPerSecond
Definition: moTexture.h:702
GLint GetWrapS() const
Definition: moTexture.h:334
void moMemory
Definition: moTexture.h:46
const moTexParam MODefTex2DParams
Parámetros internos predeterminados de una textura.
Definition: moTypes.h:562
void SetMOId(MOuint p_moid)
Definition: moTexture.h:240
textura múltiple
Definition: moTexture.h:55
moFBO * GetFBO() const
Definition: moTexture.h:208
moDeclareExportedDynamicArray(moTexture *, moTextureArray)
Clase base abstracta de donde deben derivar los objetos [virtual pura].
Definition: moAbstract.h:191
MOuint m_FrameJump
Definition: moTexture.h:728
virtual MOboolean Init()
Inicializa el objeto.
Definition: moAbstract.cpp:141
MOuint m_glid
Definition: moTexture.h:401
moFileManager * m_pFileMan
Definition: moTexture.h:392
int GetLuminance()
Definition: moTexture.h:500
#define LIBMOLDEO_API
Definition: moTypes.h:180
MOuint m_buffer_width
Definition: moTexture.h:421
#define MOfloat
Definition: moTypes.h:403
MOint lastframe
Definition: moTexture.h:933
Definition: moFBO.h:60
moShader * m_pShaderInterpolate
Definition: moTexture.h:725
MOboolean m_bInterpolating
Definition: moTexture.h:711
clase de para manejar textos
Definition: moText.h:75
moTextureArray m_srcstart
Definition: moTexture.h:719
void SetFBOAttachPoint(MOuint p_fbo_attach_point)
Definition: moTexture.h:203
MOuint m_buffer_bytespp
Definition: moTexture.h:423
MOubyte * m_pBufferData
Definition: moTexture.h:420
#define MOlong
Definition: moTypes.h:391
Grafo de reproducción de video.
Definition: moVideoGraph.h:584
MOuint m_StartTime
Definition: moTexture.h:732
moFBO * m_fbo
Definition: moTexture.h:396
int Contrast
Definition: moTexture.h:417
void SetFBO(moFBO *p_fbo)
Definition: moTexture.h:191
virtual MOuint GetFrameCount()
Definition: moTexture.h:615
moText GetName() const
Definition: moTexture.h:245
GLint GetMinFilter() const
Definition: moTexture.h:324
virtual void SetFrameCount(MOuint p_nframes)
Definition: moTexture.h:620
moText0 moText
Definition: moText.h:291
moStreamState
Definition: moVideoGraph.h:140
MOboolean SupportedFile(moText p_filename)
Definition: moTexture.cpp:345
MOfloat GetMaxCoordT() const
Definition: moTexture.h:301
moVector3f GetColorAverage()
Definition: moTexture.h:505
#define MOint
Definition: moTypes.h:388
moTextureType
Tipos de texturas.
Definition: moTexture.h:52
virtual MOboolean Finish()
Definition: moTexture.cpp:101
void SetName(moText p_name)
Definition: moTexture.h:250
int GetContrast()
Definition: moTexture.h:498
Clase Base para Objetos Moldeo ( moEffect, moIODevice, moResource, moConsole )
moVector3f GetColorMatrixCorner(int corner)
0 left up, 1 right up, 2, left down, 3, righ down
Definition: moTexture.h:504
MOuint GetGLId() const
Definition: moTexture.h:224
GLenum GetTexInternalFormat() const
Definition: moTexture.h:318
MOint frameprevious
Definition: moTexture.h:932
int moBitmapFormat
Definition: moTexture.h:45
clase base para el manejo de una textura
Definition: moTexture.h:78
Administrador de moBucket 's.
Definition: moBuckets.h:152
Administrador de recursos.
void SetDataMan(moDataManager *p_dataman)
Definition: moTexture.h:180
película
Definition: moTexture.h:56
MOuint m_fbo_attach_point
Definition: moTexture.h:397
MOfloat m_InterpolationPosition
Definition: moTexture.h:735
MOuint m_InterpolationTime
Definition: moTexture.h:729
moText m_name
Definition: moTexture.h:402
MOfloat GetMaxCoordS() const
Definition: moTexture.h:296
MOuint GetMOId() const
Definition: moTexture.h:235
MOuint m_ActualFrame
Definition: moTexture.h:707
int GetLuminance() const
Definition: moTexture.h:381
TEXTURA BASE.
Definition: moTexture.h:54
moTextureArray m_srcend
Definition: moTexture.h:720
MOuint m_width
Definition: moTexture.h:405
manejador de operaciones comunes de Open GL
Definition: moGLManager.h:154
moTextureFilter * m_pCopyEnd
Definition: moTexture.h:715
moGLManager * m_gl
Definition: moTexture.h:393
MOboolean m_bIsPlaying
Definition: moTexture.h:698
MOuint m_FrameNext
Definition: moTexture.h:704
moTextureType m_type
Definition: moTexture.h:399
MOuint GetHeight() const
Definition: moTexture.h:261
MOboolean Load(moParam *p_param)
Definition: moTexture.cpp:358
MOuint GetFBOAttachPoint() const
Definition: moTexture.h:213
virtual MOfloat GetFramesPerSecond()
Definition: moTexture.h:626
Secuencia de texturas.
Definition: moTexture.h:744
moFile * m_pFile
Definition: moTexture.h:390
virtual void SetFramesPerSecond(MOfloat p_fps)
Definition: moTexture.h:632
MOint m_components
Definition: moTexture.h:408
moMatrix3 & operator=(const moMatrix3 &rkM)
MOlong GetDataTexelCount() const
Definition: moTexture.h:290
moTextureFilter * m_pInterpolator
Definition: moTexture.h:716
moTextureType GetType() const
Definition: moTexture.h:219
MOuint GetComponents() const
Definition: moTexture.h:280
MOuint GetTextureCount()
Definition: moTexture.h:810
#define MOuint
Definition: moTypes.h:387
MOboolean m_bInterpolation
Definition: moTexture.h:710
moTextureArray m_textures_array
Definition: moTexture.h:844
virtual void Play()
Definition: moTexture.cpp:1441
MOboolean IsBuildedFromFile() const
Definition: moTexture.h:363
virtual MOboolean Finish()
Definition: moTexture.cpp:1421
MOuint m_height
Definition: moTexture.h:406
clase base para el manejo de una textura con su copia comprimida en memoria
Definition: moTexture.h:442
MOint m_moid
Definition: moTexture.h:400
moBucketsPool m_BucketsPool
Definition: moTexture.h:935
una textura asociada a una animación de cuadros
Definition: moTexture.h:549
virtual bool IsPlaying()
Definition: moTexture.cpp:1451
moPlayMode m_PlayMode
Definition: moTexture.h:697
MOuint GetWidth() const
Definition: moTexture.h:256
virtual void Stop()
Definition: moTexture.cpp:1446
MOuint m_bytespp
Definition: moTexture.h:407
moTexture * GetTexture(MOuint p_i)
Definition: moTexture.h:832
MOfloat m_max_coord_s
Definition: moTexture.h:409
#define MOubyte
Definition: moTypes.h:399
MOlong GetTexelCount() const
Definition: moTexture.h:285
moDataManager * m_pDataMan
Definition: moTexture.h:391
moTexParam m_param
Definition: moTexture.h:404
moTexParam GetTexParam() const
Definition: moTexture.h:307