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.
moTexture.cpp
Ir a la documentación de este archivo.
1 /*******************************************************************************
2 
3  moTexture.cpp
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 #include <moTexture.h>
33 #include <moTextureFilterIndex.h>
34 #include <FreeImage.h>
35 #include <moFileManager.h>
36 #include <moDataManager.h>
37 
38 #include "moArray.h"
39 moDefineDynamicArray(moTextureArray)
40 
41 //===========================================
42 //
43 // moTexture
44 //
45 //===========================================
46 
48 {
49  m_pFile = NULL;
50  m_bBuildedFromFile = false;
52  SetName(moText(""));
53  m_moid = -1;
54  m_glid = 0;
55 
56  m_width = 0;
57  m_height = 0;
58  m_bytespp = 0;
59  m_components = 0;
60  m_max_coord_s = 0.0;
61  m_max_coord_t = 0.0;
62 
63  m_pResourceManager = NULL;
64  m_gl = NULL;
65  m_pDataMan = NULL;
66  m_pFileMan = NULL;
67  m_fbo = NULL;
69 
71 
72  Luminance = -1;
73  Contrast = -1;
74  m_pBufferData = NULL;
75  m_buffer_width = 0;
76  m_buffer_height = 0;
77  m_buffer_bytespp = 0;
78 }
79 
81 {
82  Finish();
83 }
84 
86 {
87  m_pFile = NULL;
88  SetName(p_name);
89  m_moid = p_moid;
90  if (p_res) {
91  m_pResourceManager = p_res;
92  m_gl = p_res->GetGLMan();
93  m_pDataMan = p_res->GetDataMan();
94  m_pFileMan = p_res->GetFileMan();
95  }
96  m_param = p_param;
97  m_bInitialized = (m_gl!=NULL) && (m_pDataMan!=NULL) && (m_pFileMan!=NULL);
98  return m_bInitialized;
99 }
100 
102 {
103  if ((m_type != MO_TYPE_TEXTURE_MULTIPLE) && (0 < m_glid))
104  {
105  glDeleteTextures(1, &m_glid);
106  m_glid = 0;
107  }
108  m_bInitialized = false;
109  return true;
110 }
111 
112 
114 {
115  // int ii;
116  /*if ( 0 < m_glid ) {
117  //ii = m_glid;
118  glDeleteTextures(1, &m_glid);
119  m_glid = 0;
120  //m_glid = ii;
121  }*/
122 
123  if (m_glid<=0) {
124  glGenTextures(1, &m_glid);
125  }
126 
127 
128  CalculateSize(p_width, p_height);
129 /*
130  unsigned char* buffer = new unsigned char [m_width*m_height]();
131  SetBuffer(m_width, m_height, buffer );
132 */
133  return Build();
134 }
135 
136 MOboolean moTexture::BuildFromBuffer(MOuint p_width, MOuint p_height, const GLvoid* p_buffer, GLenum p_format, GLenum p_type)
137 {
138  BuildEmpty(p_width, p_height);
139  return SetBuffer(p_width, p_height, p_buffer, p_format, p_type);
140 }
141 
143 {
144  MOboolean res;
145  moFile* pFile = NULL;
146 
147  //check for file
148  if ( m_pFileMan->Load(p_filename)) {
149  pFile = m_pFileMan->GetFile(p_filename);
150  } else return false;
151  if ( pFile==NULL ) return false;
152  m_pFile = pFile;
153 
154  FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
155  FIBITMAP *m_pImage = NULL;
156 
158 
159  fif = FreeImage_GetFileType( m_pFile->GetCompletePath(), 0);
160 
161  if( fif == FIF_UNKNOWN ) {
162  // try to guess the file format from the file extension
163  fif = FreeImage_GetFIFFromFilename(m_pFile->GetCompletePath());
164  }
165 
166  if( (fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif) ) {
167  // ok, let's load the file
168  m_pImage = FreeImage_Load( fif, m_pFile->GetCompletePath(), 0);
169  }
170  } else if ( m_pFile->IsRemote() ) {
171  //set an internal flag for texture to always check if file has finished downloading
172  //and build
174  //we check from filename
175  fif = FreeImage_GetFIFFromFilename(m_pFile->GetCompletePath());
176  if( (fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif) ) {
177  // ok, let's load the file
178  m_pImage = FreeImage_LoadFromMemory( fif, (FIMEMORY*)m_pFile->GetData(), 0);
179  }
180  }
181  }
182 
183  moMathd Mathd;
184 
185  if (m_pImage != NULL)
186  {
187  MOuint p_width;
188  MOuint p_height;
189  FIBITMAP* pImageScaled = NULL;
190 
191  p_width = FreeImage_GetWidth(m_pImage);
192  p_height = FreeImage_GetHeight(m_pImage);
193 
194  bool size_mult_4 = ( p_width % 4 ) != 0 || ( p_height % 4) == 0;
195  bool size_power_2 = ( !Mathd.IsPowerOfTwo( (int)p_width ) || !Mathd.IsPowerOfTwo( (int)p_height ) );
196  bool resize_image = false;
198 
199  if (size_power_2
200  &&
201  no_power ) {
202  if (!Mathd.IsPowerOfTwo(p_width)) p_width = NextPowerOf2( p_width );
203  if (!Mathd.IsPowerOfTwo(p_height)) p_height = NextPowerOf2( p_height );
204  resize_image = true;
205  }
206 
207  if ( size_mult_4 ) {
208 
209  p_width = p_width / 4;
210  p_width = p_width * 4;
211 
212  p_height = p_height / 4;
213  p_height = p_height* 4;
214  resize_image = true;
215  }
216 
217 
218  if (resize_image) {
219  pImageScaled = FreeImage_Rescale( m_pImage, p_width, p_height, FILTER_BICUBIC );
220  if (pImageScaled) {
221  FreeImage_Unload( m_pImage );
222  m_pImage = pImageScaled;
223  }
224  }
225 
226  MOuint bpp = FreeImage_GetBPP(m_pImage);
227  FREE_IMAGE_COLOR_TYPE colortype = FreeImage_GetColorType(m_pImage);
228  FREE_IMAGE_TYPE image_type = FreeImage_GetImageType(m_pImage);
229  MOuint p_format;
230  MOuint red_mask = FreeImage_GetRedMask(m_pImage);
231  MOuint blue_mask = FreeImage_GetBlueMask(m_pImage);
232  MOuint green_mask = FreeImage_GetGreenMask(m_pImage);
233  MOuint pitch = FreeImage_GetPitch(m_pImage);
234  MODebug2->Log( GetName()+ " bpp: "+IntToStr(bpp)
235  +" colortype:"+IntToStr(colortype)
236  +" image_type:"+IntToStr(image_type)
237  +" pitch:"+IntToStr(pitch)
238  +" > blue_mask: " +IntToStr(blue_mask)
239  +" green_mask:"+IntToStr(green_mask)
240  +" red_mask:"+ IntToStr(red_mask) );
241 
242  m_param.target = GL_TEXTURE_2D;
243  switch (bpp)
244  {
245  case 8: // 8 bit, indexed or grayscale
246  m_param.internal_format = GL_RGB;
247  p_format = GL_LUMINANCE;
248  break;
249  case 16: // 16 bits
250  /*
251  if((FreeImage_GetRedMask(dib) == FI16_565_RED_MASK) && (FreeImage_GetGreenMask(dib) == FI16_565_GREEN_MASK) && (FreeImage_GetBlueMask(dib) == FI16_565_BLUE_MASK)) {
252  value->rgbBlue = (BYTE)((((*pixel & FI16_565_BLUE_MASK) >> FI16_565_BLUE_SHIFT) * 0xFF) / 0x1F);
253  value->rgbGreen = (BYTE)((((*pixel & FI16_565_GREEN_MASK) >> FI16_565_GREEN_SHIFT) * 0xFF) / 0x3F);
254  value->rgbRed = (BYTE)((((*pixel & FI16_565_RED_MASK) >> FI16_565_RED_SHIFT) * 0xFF) / 0x1F);
255  value->rgbReserved = 0;
256  } else {
257  value->rgbBlue = (BYTE)((((*pixel & FI16_555_BLUE_MASK) >> FI16_555_BLUE_SHIFT) * 0xFF) / 0x1F);
258  value->rgbGreen = (BYTE)((((*pixel & FI16_555_GREEN_MASK) >> FI16_555_GREEN_SHIFT) * 0xFF) / 0x1F);
259  value->rgbRed = (BYTE)((((*pixel & FI16_555_RED_MASK) >> FI16_555_RED_SHIFT) * 0xFF) / 0x1F);
260  value->rgbReserved = 0;
261  }
262  */
263  break;
264  case 24: // 24 bits
265  m_param.internal_format = GL_RGB;
266 /*
267 #ifndef OPENGLESV2
268  if ( red_mask == 0x0000FF || red_mask==0) p_format = GL_BGR;
269  else
270 #endif
271  p_format = GL_RGB;
272 #ifndef OPENGLESV2
273  if (fif==FIF_JPEG) p_format = GL_BGR;
274 #endif
275 */
276  p_format = GL_RGB;
277  if ( image_type==FIT_BITMAP && (fif==FIF_JPEG || fif==FIF_PNG) ) {
278  //BYTE* pbits = (BYTE*)FreeImage_GetBits(m_pImage);
279  for( int j = 0; j < (int)p_height; j++) {
280  //BYTE *pixel = (BYTE*)pbits;
281  BYTE *pixel = (BYTE *) FreeImage_GetScanLine( m_pImage, j );
282  for(int i = 0; i < (int)p_width; i++) {
283  BYTE tmp = pixel[FI_RGBA_RED];
284  pixel[FI_RGBA_RED] = pixel[FI_RGBA_BLUE];
285  //pixel[FI_RGBA_GREEN] = 128;
286  pixel[FI_RGBA_BLUE] = tmp;
287  pixel += 3;
288  }
289  // next line
290  //pbits += pitch;
291  }
292  }
293  break;
294  case 32: // 32 bits
295  {
296  m_param.internal_format = GL_RGBA;
297 #ifndef OPENGLESV2
298  //if ( blue_mask == 0xFF0000 || blue_mask==0 ) p_format = GL_BGRA_EXT;
299  //else
300 #endif
301  if ( image_type==FIT_BITMAP && fif==FIF_PNG ) {
302  //BYTE* pbits = (BYTE*)FreeImage_GetBits(m_pImage);
303  for( int j = 0; j < (int)p_height; j++) {
304  //BYTE *pixel = (BYTE*)pbits;
305  BYTE *pixel = (BYTE *) FreeImage_GetScanLine( m_pImage, j );
306  for(int i = 0; i < (int)p_width; i++) {
307  BYTE tmp = pixel[FI_RGBA_RED];
308  pixel[FI_RGBA_RED] = pixel[FI_RGBA_BLUE];
309  //pixel[FI_RGBA_GREEN] = 128;
310  pixel[FI_RGBA_BLUE] = tmp;
311  pixel += 4;
312  }
313  // next line
314  //pbits += pitch;
315  }
316  }
317  p_format = GL_RGBA;
318 #ifndef OPENGLESV2
319  //if (fif==FIF_PNG) p_format = GL_BGRA_EXT;
320 #else
321 
322 #endif
323  }
324  break;
325  case 64:
326  m_param.internal_format = GL_RGBA16F;
327  break;
328  case 128:
329  m_param.internal_format = GL_RGBA32F;
330  break;
331  default:
332  break;
333  }
334 
335  BuildEmpty(p_width, p_height);
336  FlipBufferVert((MOubyte *)FreeImage_GetBits(m_pImage), FreeImage_GetBPP(m_pImage) / 8 );
337  res = SetBuffer(p_width, p_height, FreeImage_GetBits(m_pImage), p_format);
338 
339  FreeImage_Unload(m_pImage);
340  }
341  else {
342  if (MODebug2 != NULL) MODebug2->Error(moText("Error at image load: ") + (moText)p_filename);
343  res = false;
344  }
345 
346  m_bBuildedFromFile = res;
347 
348  return res;
349 }
350 
352 {
353  moText extension = p_filename;
354  extension.Right(3);
355  return (!stricmp(extension,"tga") ||
356  !stricmp(extension,"jpg") ||
357  !stricmp(extension,"png") ||
358  !stricmp(extension,"gif") ||
359  !stricmp(extension,"bmp") ||
360  !stricmp(extension,"xpm") ||
361  !stricmp(extension,"ppm") ||
362  !stricmp(extension,"exr") ||
363  !stricmp(extension,"web") ||
364  !stricmp(extension,"hdr") ||
365  !stricmp(extension,"mng") ||
366  !stricmp(extension,"jp2") ||
367  !stricmp(extension,"tif") ||
368  !stricmp(extension,"j2k") ||
369  !stricmp(extension,"j2c") ||
370  !stricmp(extension,"ico") ||
371  !stricmp(extension,"pcx") ||
372  !stricmp(extension,"psd"));
373 }
374 
376 {
377  moValue* pValue = &p_param->GetValue();
378  return Load( pValue );
379 }
380 
382 {
383  SetName( p_value->GetSubValue(0).Text() );
384  moText namefull = m_pDataMan->GetDataPath() + moSlash + (moText)m_name;
385  return BuildFromFile(namefull);
386 }
387 
388 MOboolean moTexture::SetBuffer( const GLvoid* p_buffer, GLenum p_format, GLenum p_type)
389 {
390  return SetBuffer(m_width, m_height, p_buffer, p_format, p_type);
391 }
392 
393 MOboolean moTexture::SetBuffer(MOuint p_width, MOuint p_height, const GLvoid* p_buffer, GLenum p_format, GLenum p_type)
394 {
395  glBindTexture(m_param.target, m_glid);
396 
397  // Aqui hay que destruir la textura si los nuevos alto y anchos son diferentes de los actuales!!!!
398  moMathi mathi;
399 #ifndef OPENGLESV2
400  if ((m_gl != NULL) && m_gl->MipMapTexture(m_param.min_filter)
401  && ( mathi.IsPowerOfTwo( p_width ) )
402  && ( mathi.IsPowerOfTwo( p_height ) )
403  )
404  gluBuild2DMipmaps(m_param.target, m_param.internal_format, p_width, p_height, p_format, p_type, p_buffer);
405  else
406 #endif
407  glTexSubImage2D(m_param.target, 0, 0, 0, p_width, p_height, p_format, p_type, p_buffer);
408  glBindTexture(m_param.target, 0);
409 
410 #ifdef OPENGLESV2
411 //TODO: in OpenGL ES V2 GPU, we must save the last buffer data, so we dont need to use glGetTexImage, to fetch the texture pixels
412 if (m_pBufferData==NULL) {
413  ResetBufferData( true, 3 );
414 }
415 if (m_pBufferData) {
416  //copy buffer
417  memccpy( m_pBufferData, p_buffer, 1, p_width*p_height );
418 }
419 #endif
420  //if (m_gl != NULL) return !m_gl->CheckErrors("copying buffer to texture");
421  //else return true;
422 
423  return true;
424 }
425 
426 MOboolean moTexture::GetBuffer(GLvoid* p_buffer, GLenum p_format, GLenum p_type)
427 {
429  glBindTexture(m_param.target, this->m_glid);
431  if ( p_buffer == NULL ) {
432  MODebug2->Error("moTexture::GetBuffer > p_buffer: " + IntToStr((MOlong)p_buffer));
433  return false;
434  }
435  if (
436 #ifndef OPENGLESV2
437 p_format!=GL_BGR &&
438 p_format!=GL_BGRA &&
439 #endif
440 p_format!=GL_RGB && p_format!=GL_RGBA ) {
441  MODebug2->Error("moTexture::GetBuffer > p_format: " + IntToStr((int)p_format));
442  return false;
443  }
444  if ( p_type!=GL_UNSIGNED_BYTE && p_type!=GL_FLOAT && p_type!=GL_BYTE ) {
445  MODebug2->Error("moTexture::GetBuffer > p_type: " + IntToStr((int)p_type) );
446  return false;
447  }
448  try {
449 #ifndef OPENGLESV2
450  glGetTexImage( m_param.target, 0, p_format, p_type, p_buffer);
451 #else
452  return m_pBufferData;
453 #endif
454  } catch(...) {
455  MODebug2->Error("moTexture::GetBuffer > exception getting texture buffer. p_buffer: " + IntToStr((MOlong)p_buffer));
456  }
457  glBindTexture( m_param.target, 0);
458 
459  if (m_gl) {
460  if (m_gl->CheckErrors("copying texture to buffer")) {
461  //MODebug2->Error("moTexture::GetBuffer > GL ERROR: target: " + IntToStr((int)m_param.target) + " p_format: " + IntToStr((int)p_format) +" p_type:" + IntToStr((int)p_type) +" p_buffer:" + IntToStr((int)p_buffer) );
462  }
463  }
464  //else return true;
465  return true;
466 }
467 
468 bool moTexture::CalculateLuminanceAndConstrast( int x0, int y0, int x1, int y1 ) {
469 
470  //FREE_IMAGE_FORMAT fif;
471  FIBITMAP* fbitmap = NULL;
472  FIBITMAP* fbitmapcopy = NULL;
473  //configint options = 0;
474  BYTE* tempbuffer = NULL;
475 
476  if (GetHeight()==0 || GetWidth()==0) return false;
477 
478  if (x0 == 0 && y0 == 0 && x1 == 0 && y1 == 0) {
479 
480  tempbuffer = new BYTE [ GetHeight() * GetWidth() * 4 ];
481  if (tempbuffer==NULL) return false;
482  if (!GetBuffer( tempbuffer, GL_RGBA, GL_UNSIGNED_BYTE ) ) return false;
483  int bpp = 32;
484  int pitch = 4 * GetWidth();
485  fbitmap = FreeImage_ConvertFromRawBits( (BYTE*)tempbuffer, GetWidth(), GetHeight(), pitch, bpp, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, false );
486  if (tempbuffer)
487  delete [] tempbuffer;
488 
489  } else {
490 
491  int ww = (x1 - x0 - 1);
492  int hh = (y1 - y0 - 1);
493  if (ww>0 && hh>0) {
494  tempbuffer = new BYTE [ GetHeight() * GetWidth() * 4 ];
495  if (tempbuffer==NULL) return false;
496  //glReadPixels( x0, y0, ww, hh, GL_RGBA, GL_UNSIGNED_BYTE, tempbuffer);
497  if (!GetBuffer( tempbuffer, GL_RGBA, GL_UNSIGNED_BYTE ) ) return false;
498  int bpp = 32;
499  int pitch = 4 * GetWidth();
500  fbitmap = FreeImage_ConvertFromRawBits( (BYTE*)tempbuffer, GetWidth(), GetHeight(), pitch, bpp, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, false );
501  fbitmapcopy = FreeImage_Copy( fbitmap, x0, y0, x1, y1 );
502  FreeImage_Unload(fbitmap);
503  fbitmap = fbitmapcopy;
504  if (tempbuffer)
505  delete [] tempbuffer;
506 
507  } else {
508  MODebug2->Error(moText("moTexture::CalculateLuminanceAndConstrast ") + moText("freeimage problem"));
509  return false;
510  }
511 
512  }
513 
514  if (fbitmap && FreeImage_GetHistogram( (FIBITMAP *)fbitmap, (DWORD*)Histogram, FICC_BLACK )) {
515 
517  Luminance = 0;
518  long Total = 0;
519 
520  for(int ih=0; ih <256; ih++) {
521  Total+= Histogram[ih];
522  Luminance+= Histogram[ih]*ih;
523 
524  }
525 
526  Luminance = Luminance / Total;
527 
529  int Group[5];
530  int Totals[5];
531 
532  Group[0] = 0;
533  Group[1] = 0;
534  Group[2] = 0;
535  Group[3] = 0;
536  Group[4] = 0;
537 
538  Totals[0] = 0;
539  Totals[1] = 0;
540  Totals[2] = 0;
541  Totals[3] = 0;
542  Totals[4] = 0;
543 
544 
545  int zone = 0;
546  long dif = 0;
547  for(int ih=0; ih <256; ih++) {
548  zone = ih / 52;
549  dif = ( Histogram[ih]*(ih - Luminance)*(ih - Luminance));
550  Group[zone]+= dif;
551  Totals[zone]+= Histogram[ih];
552  }
553 
554  Contrast = 0;
555  for(int z=0;z<5;z++) {
556  if (Totals[z]>0) Contrast+= Group[z] / Totals[z];
557  }
558  Contrast = Contrast / 5;
559 
560  MODebug2->Push( moText("moTexture::CalculateLuminanceAndConstrast Histogram OK"));
561 
562  } else MODebug2->Error( moText("moTexture::CalculateLuminanceAndConstrast Histogram error"));
563 
564  if (fbitmap) FreeImage_Unload( fbitmap );
565  return true;
566 }
567 
569 {
570  MOuint AttachPt;
571  SetFBO(p_fbo);
572  p_fbo->AddTexture(GetWidth(), GetHeight(), GetTexParam(), GetGLId(), AttachPt);
573  SetFBOAttachPoint(AttachPt);
574  return AttachPt;
575 }
576 
578 {
579  if ((m_gl != NULL) && m_gl->RectTexture(m_param.target)) return m_width;
580  else return (MOuint)(m_max_coord_s * m_width);
581 }
582 
584 {
585  if ((m_gl != NULL) && m_gl->RectTexture(m_param.target)) return m_height;
586  else return (MOuint)(m_max_coord_t * m_height);
587 }
588 
591  if (p_src_mob==NULL) return GetGLId();
592  return 0;
593 }
594 
595 void moTexture::FlipBufferVert(MOubyte *pBuffer, MOint p_depth)
596 {
597  MOubyte *top;
598  MOubyte *bottom;
599  MOubyte *tmp_buffer;
600  int lineWidth = m_width * p_depth;
601 
602  tmp_buffer = new MOubyte[m_width * p_depth];
603 
604  top =(MOubyte*)pBuffer;
605  bottom =(MOubyte*)((BYTE*)pBuffer + lineWidth*(m_height - 1));
606  for(MOuint i = 0; i < (m_height >> 1); i++)
607  {
608  memcpy(tmp_buffer, top, lineWidth);
609  memcpy(top, bottom, lineWidth);
610  memcpy(bottom, tmp_buffer, lineWidth);
611 
612  top =(MOubyte*)((BYTE*) top + lineWidth);
613  bottom =(MOubyte*)((BYTE*) bottom - lineWidth);
614  }
615 }
616 
617 void moTexture::CopyFromTex(moTexture* p_src_tex, MOboolean p_copy_glid, MOboolean p_copy_moid, MOboolean p_copy_type, MOboolean p_copy_name)
618 {
619  if (p_src_tex != NULL)
620  {
621  m_gl = p_src_tex->m_gl;
622 
623  m_fbo = p_src_tex->m_fbo;
625 
626  if (p_copy_type) m_type = p_src_tex->m_type;
627  if (p_copy_moid) m_moid = p_src_tex->m_moid;
628  if (p_copy_glid) m_glid = p_src_tex->m_glid;
629  if (p_copy_name) m_name = p_src_tex->m_name;
630 
631  m_param = p_src_tex->m_param;
632  m_width = p_src_tex->m_width;
633  m_height = p_src_tex->m_height;
634  m_components = p_src_tex->m_components;
635  m_max_coord_s = p_src_tex->m_max_coord_s;
636  m_max_coord_t = p_src_tex->m_max_coord_t;
637  }
638 }
639 
641 {
642  m_gl = p_src_tex.m_gl;
643 
644  m_fbo = p_src_tex.m_fbo;
646 
647  m_type = p_src_tex.m_type;
648  m_moid = p_src_tex.m_moid;
649  m_glid = p_src_tex.m_glid;
650  m_name = p_src_tex.m_name;
651 
652  m_param = p_src_tex.m_param;
653  m_width = p_src_tex.m_width;
654  m_height = p_src_tex.m_height;
655  m_components = p_src_tex.m_components;
656  m_max_coord_s = p_src_tex.m_max_coord_s;
657  m_max_coord_t = p_src_tex.m_max_coord_t;
658 
659  return *this;
660 }
661 
663 {
664  glTexParameteri(m_param.target, GL_TEXTURE_MIN_FILTER, m_param.min_filter);
665  glTexParameteri(m_param.target, GL_TEXTURE_MAG_FILTER, m_param.mag_filter);
666  glTexParameteri(m_param.target, GL_TEXTURE_WRAP_S, m_param.wrap_s);
667  glTexParameteri(m_param.target, GL_TEXTURE_WRAP_T, m_param.wrap_t);
668  /*glTexParameteri(m_param.target, GL_GENERATE_MIPMAP, GL_TRUE );*/
669 }
670 
671 void moTexture::CalculateSize(MOuint p_width, MOuint p_height)
672 {
673 
674  p_width = ( p_width / 4 ) * 4;
675  p_height = ( p_height / 4 ) * 4;
676 
677  if ((m_gl != NULL) && m_gl->RectTexture(m_param.target))
678  {
679  m_width = p_width;
680  m_height = p_height;
681  m_max_coord_s = p_width;
682  m_max_coord_t = p_height;
683 
684 
685 
686 
687  }
688  /*
689  else
690  {
691  m_width = p_width;
692  m_height = p_height;
693  m_max_coord_s = 1.0;
694  m_max_coord_t = 1.0;
695  }*/
696  else if (RenderMan()->IsTextureNonPowerOf2Disabled())
697  {
698 
699  m_width = NextPowerOf2(p_width);
700  m_height = NextPowerOf2(p_height);
701 
702  m_max_coord_s = (float)p_width / (float)m_width;
703  m_max_coord_t = (float)p_height / (float)m_height;
704  moDebugManager::Message(" moTexture::CalculateSize of texture: " + GetName() + " from "
705  + IntToStr(p_width) + "x" + IntToStr(p_height)
706  + " to " + IntToStr(m_width) + "x" + IntToStr(m_height) );
707  }
708  else
709  {
710  m_width = p_width;
711  m_height = p_height;
712  m_max_coord_s = 1.0;
713  m_max_coord_t = 1.0;
714 
715  }
716 
717 }
718 
721 bool moTexture::ResetBufferData( bool force_creation, int bytes_per_pixel ) {
722 
723  bool resized = m_buffer_width!=m_width || m_buffer_height!=m_height;
724 
725  if (bytes_per_pixel>0) resized = resized || bytes_per_pixel!=(int)m_buffer_bytespp;
726  else resized = resized || m_buffer_bytespp!=m_bytespp;
727 
728  bool create_buffer = force_creation;
729 
730  if ( resized || force_creation ) {
731 
732  if (m_pBufferData && resized) {
734  delete [] m_pBufferData;
735  m_pBufferData = NULL;
736  create_buffer = true;
737  }
738 
739  if (create_buffer && m_pBufferData==NULL) {
745  if (bytes_per_pixel!=0) m_buffer_bytespp = bytes_per_pixel;
747 
748  if (bufsize>0) {
749  m_pBufferData = new BYTE [bufsize];
750  if (m_pBufferData) return true;
751  }
752  }
753  }
754 
755  return false;
756 }
757 
759 {
760  MOuint i;
761  for (i = 1; i < p_seed; i *= 2);
762  return i;
763 }
764 
766 {
767  glBindTexture(m_param.target, m_glid);
768  SetParam();
769 
770  GLenum pixel_format = GL_RGBA;
771  GLenum pixel_type_format = GL_UNSIGNED_BYTE;
772  void* blankdata = NULL;
773  MOubyte* ub_blankdata = NULL;
774  MOint* i_blankdata = NULL;
775  MOfloat* f_blankdata = NULL;
776 
777  switch(m_param.internal_format) {
778  case GL_RGBA:
779  pixel_format = GL_RGBA;
780  pixel_type_format = GL_UNSIGNED_BYTE;
781  m_bytespp = 4;
782  blankdata = new MOubyte [m_width*m_height*m_bytespp]();
783  ub_blankdata = (MOubyte*) blankdata;
784  break;
785  case GL_RGB:
786  pixel_format = GL_RGBA;
787  pixel_type_format = GL_UNSIGNED_BYTE;
788  m_bytespp = 4;
789  blankdata = new MOubyte [m_width*m_height*m_bytespp]();
790  ub_blankdata = (MOubyte*) blankdata;
791  break;
792 #ifndef OPENGLESV2
793  case GL_RGBA32I:
794  case GL_RGBA16I:
795  pixel_format = GL_RGBA_INTEGER;
796  pixel_type_format = GL_INT;
797  m_bytespp = 4;
798  blankdata = new MOint [m_width*m_height*m_bytespp]();
799  i_blankdata = (MOint*) blankdata;
800  break;
801  case GL_RGBA32F:
802  case GL_RGBA16F:
803  pixel_format = GL_RGBA;
804  pixel_type_format = GL_FLOAT;
805  m_bytespp = 4;
806  blankdata = new MOfloat [m_width*m_height*m_bytespp]();
807  f_blankdata = (MOfloat*) blankdata;
808  break;
809 #endif
810  default:
811  pixel_format = GL_RGBA;
812  pixel_type_format = GL_UNSIGNED_BYTE;
813  m_bytespp = 4;
814  blankdata = new MOint [m_width*m_height*m_bytespp]();
815  i_blankdata = (MOint*) blankdata;
816  break;
817  }
818 
819  glTexImage2D( m_param.target, 0,
821  m_width, m_height, 0,
822  pixel_format,
823  pixel_type_format,
824  blankdata );
825 
826  if (i_blankdata) delete [] i_blankdata;
827  if (ub_blankdata) delete [] ub_blankdata;
828  if (f_blankdata) delete [] f_blankdata;
829 #ifndef OPENGLESV2
830  glGetTexLevelParameteriv(m_param.target, 0, GL_TEXTURE_COMPONENTS, &m_components);
831 #else
832  //glGetTexParameteriv(m_param.target, GL_TEXTURE_COMPONENTS, &m_components);
833 #endif
834  ResetBufferData();
835  //if (m_gl != NULL) return !m_gl->CheckErrors("texture build");
836  if (m_gl != NULL) m_gl->CheckErrors("texture build");
837  return true;
838 }
839 
841  m_glid = 0;//reset gl texture id
842  moText namefull = m_pDataMan->GetDataPath() + moSlash + (moText)m_name;
843  return BuildFromFile( namefull );
844 }
845 
846 
847 static void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message) {
848  moText error_message = message;
849  if(fif != FIF_UNKNOWN) {
850  //FreeImage_GetFormatFromFIF(fif));
851  }
852  //moDebugManager::Error(error_message);
853  cout << message << endl;
854 }
855 
856 moText moTexture::CreateThumbnail( moText p_bufferformat, int w, int h, moText newfilename ) {
857 
858  moText thumbnailfilename;
859 
860  FreeImage_SetOutputMessage(FreeImageErrorHandler);
861 
862  if ( newfilename==moText("") ) {
863 
864  //old version
865  //moThm
866  moFile SrcFile( m_name );
867  thumbnailfilename = (moText)m_pDataMan->GetDataPath() + moSlash + SrcFile.GetFileName();
868 
869  /*
870  // new version:
871  moFile SrcFile( m_name );
872  moDirectory Dir( (moText)m_pDataMan->GetDataPath() + moThm );
873  if ( ! Dir.Exists() ) {
874 
875  }
876  thumbnailfilename = (moText)m_pDataMan->GetDataPath() + moSlash + (moText)m_name + moText(".thm");
877  //thumbnailfilename = (moText)m_pDataMan->GetDataPath() + moThm + moSlash + SrcFile.GetFileName() + moText(".thm");
878  */
879 
880 
881  } else {
882  thumbnailfilename = newfilename;
883  }
884 
885  FREE_IMAGE_FORMAT fif = FIF_PNG;
886  FREE_IMAGE_TYPE fit = FIT_BITMAP;
887  FIBITMAP* fbitmap = NULL;
888  int options = 0;
889 
890  if (GetHeight()==0 || GetWidth()==0) {
891  MODebug2->Error("moTexture::CreateThumbnail > no width or height, texture surface is 0.");
892  return moText("");
893  }
894 
895  unsigned int bpp = 24;
896  unsigned int bytesperpixel = 3;
897  unsigned int pitch = bytesperpixel * GetWidth();
898 #ifndef OPENGLESV2
899  GLenum gbufferformat = GL_BGR;
900 #else
901  GLenum gbufferformat = GL_RGB;
902 #endif
903  GLenum gcomponenttype = GL_UNSIGNED_BYTE;
904 
905  if ( p_bufferformat == moText("PNGA")) {
906 
907  fif = FIF_PNG;
908  options = PNG_DEFAULT;
909  thumbnailfilename+= moText(".png");
910  bpp = 32;
911  bytesperpixel = 4;
912 #ifndef OPENGLESV2
913  gbufferformat = GL_BGRA;
914 #else
915  gbufferformat = GL_RGBA;
916 #endif
917  } else if ( p_bufferformat == moText("PNGF")) {
918 
919  fif = FIF_PNG;
920  options = PNG_DEFAULT;
921  thumbnailfilename+= moText(".png");
922  bpp = 32;
923  bytesperpixel = 4;
924 #ifndef OPENGLESV2
925  gbufferformat = GL_BGRA;
926 #else
927  gbufferformat = GL_RGBA;
928 #endif
929  gcomponenttype = GL_FLOAT;
930 
931  } else if ( p_bufferformat == moText("PNG")) {
932  fif = FIF_PNG;
933  options = PNG_DEFAULT;
934  thumbnailfilename+= moText(".png");
935  } else
936  if ( p_bufferformat == moText("JPG") || p_bufferformat == moText("JPGNORMAL")) {
937 
938  fif = FIF_JPEG;
939  options = JPEG_QUALITYNORMAL;
940  thumbnailfilename+= moText(".jpg");
941 
942  } else if ( p_bufferformat == moText("JPGSUPERB") ) {
943 
944  fif = FIF_JPEG;
945  options = JPEG_QUALITYSUPERB;
946  thumbnailfilename+= moText(".jpg");
947 
948  } else if ( p_bufferformat == moText("JPGBAD") ) {
949 
950  fif = FIF_JPEG;
951  options = JPEG_QUALITYBAD;
952  thumbnailfilename+= moText(".jpg");
953 
954  } else if ( p_bufferformat == moText("JPGAVERAGE") ) {
955 
956  fif = FIF_JPEG;
957  options = JPEG_QUALITYAVERAGE;
958  thumbnailfilename+= moText(".jpg");
959 
960  } else if ( p_bufferformat == moText("JPGGOOD") ) {
961 
962  fif = FIF_JPEG;
963  options = JPEG_QUALITYGOOD;
964  thumbnailfilename+= moText(".jpg");
965 
966  } else if ( p_bufferformat == moText("TGA") ) {
967 
968  fif = FIF_TARGA;
969  options = 0;
970  thumbnailfilename+= moText(".tga");
971 
972  } else if ( p_bufferformat == moText("EXR") ) {
973 
974  fif = FIF_EXR;
975  options = EXR_NONE | EXR_FLOAT;
976  thumbnailfilename+= moText(".exr");
977  fit = FIT_RGBAF;
978  gcomponenttype = GL_FLOAT;
979  bpp = 128;//32*4
980  bytesperpixel = 128/8;//32/4 bits/bytes por componente (4 bytes por float, 16 bytes por pixel)
981  pitch = bytesperpixel*GetWidth();
982 
983  } else if ( p_bufferformat == moText("HDR") ) {
984 
985  fif = FIF_HDR;
986  options = 0;
987  thumbnailfilename+= moText(".hdr");
988  } else if ( p_bufferformat == moText("WEBP") ) {
989 
990  fif = FIF_WEBP;
991  options = 0;
992  thumbnailfilename+= moText(".webp");
993 
994  } else if ( p_bufferformat == moText("GIF") ) {
995 
996  fif = FIF_GIF;
997  options = 0;
998  thumbnailfilename+= moText(".gif");
999 
1000  } else if ( p_bufferformat == moText("TIFF") ) {
1001 
1002  fif = FIF_TIFF;
1003  options = 0;
1004  thumbnailfilename+= moText(".tif");
1005 
1006  } else if ( p_bufferformat == moText("XPM") ) {
1007 
1008  fif = FIF_XPM;
1009  options = 0;
1010  thumbnailfilename+= moText(".xpm");
1011 
1012  } else if ( p_bufferformat == moText("PFM") ) {
1013 
1014  fif = FIF_PFM;
1015  options = 0;
1016  thumbnailfilename+= moText(".pfm");
1017 
1018  } else if ( p_bufferformat == moText("PBM") ) {
1019 
1020  fif = FIF_PBM;
1021  options = 0;
1022  thumbnailfilename+= moText(".pbm");
1023 
1024  } else if ( p_bufferformat == moText("JXR") ) {
1025 
1026  fif = FIF_JXR;
1027  options = 0;
1028  thumbnailfilename+= moText(".jxr");
1029 
1030  } else if ( p_bufferformat == moText("J2K") ) {
1031 
1032  fif = FIF_J2K;
1033  options = 0;
1034  thumbnailfilename+= moText(".j2k");
1035 
1036  } else if ( p_bufferformat == moText("BMP") ) {
1037 
1038  fif = FIF_BMP;
1039  options = 0;
1040  thumbnailfilename+= moText(".bmp");
1041  }
1042 
1043  pitch = bytesperpixel * GetWidth();
1044  //pitch = ((GetWidth() * bpp + 31) /31 ) *4;
1045 
1046  if (gcomponenttype==GL_UNSIGNED_BYTE)
1047  ResetBufferData( true, bytesperpixel );
1048 
1049  if (gcomponenttype==GL_FLOAT) {
1050  //CONVERT
1051  void* float_buffer;
1052  //if (m_pBufferData==NULL) {
1053  m_pBufferData = new BYTE[ 4*4*GetWidth()*GetHeight() ];
1054  //m_pBufferData = (BYTE*) float_buffer;
1055  //}
1056  //if (m_pBufferData) {
1057  //float_buffer = (GLfloat*) m_pBufferData;
1058  glBindTexture(m_param.target, this->m_glid);
1059  //FIRGBAF
1060  glGetTexImage( GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, (void *) m_pBufferData );
1061  //}
1062  } else {
1063 
1064  if (m_pBufferData==NULL) {
1065  MODebug2->Error("moTexture::CreateThumbnail > no memory for buffer data allocation or invalid component type.");
1066  return moText("");
1067  }
1068 
1069  if (!GetBuffer( m_pBufferData, gbufferformat, gcomponenttype ) ) {
1070  MODebug2->Error("moTexture::CreateThumbnail > GetBuffer from texture " + GetName()+" failed.");
1071  return moText("");
1072  }
1073  }
1088  //fbitmap = FreeImage_ConvertFromRawBits( (BYTE*)m_pBufferData,
1089  fbitmap = FreeImage_ConvertFromRawBitsEx( TRUE, (BYTE*)m_pBufferData,
1090  fit,
1091  GetWidth(),
1092  GetHeight(),
1093  pitch,
1094  bpp,
1095  //0xFF0000,
1096  FI_RGBA_RED_MASK,
1097  //0x00FF00,
1098  FI_RGBA_GREEN_MASK,
1099  //0x0000FF,
1100  FI_RGBA_BLUE_MASK
1101 #ifdef MO_WIN32
1102  , MO_TRUE
1103 #endif // MO_WIN
1104  );
1105 
1106  //TODO: add alpha channel for RGBA: FreeImage_SetTransparent(fbitmap, image.flags & ImageData::ALPHA_BIT);
1107 
1108  if (!fbitmap) {
1109 
1110  MODebug2->Error("moTexture::CreateThumbnail > FreeImage_ConvertFromRawBits failed from: " + GetName() + " width:" + IntToStr(GetWidth())+" height:"+IntToStr(GetHeight()) );
1111  return moText("");
1112  }
1113 
1114  unsigned int fwidth = FreeImage_GetWidth(fbitmap);
1115  unsigned int fheight = FreeImage_GetHeight(fbitmap);
1116  unsigned int fpitch = FreeImage_GetPitch(fbitmap);
1117  unsigned int fbpp = FreeImage_GetBPP(fbitmap);
1118  //FREE_IMAGE_TYPE image_type = FreeImage_GetImageType( fbitmap );
1119 
1120 
1121  if ((fwidth!=GetWidth() && fheight!=GetHeight()) ) {
1122 
1123  MODebug2->Error("moTexture::CreateThumbnail > freeimage width and height does not match texture wxh > fwidth:" + IntToStr(fwidth) + " fheight:" + IntToStr(fheight) );
1124  return moText("");
1125  }
1126 
1127  if ( fbpp!=bpp /*|| fpitch!=pitch*/ ) {
1128  MODebug2->Error("moTexture::CreateThumbnail > freeimage bpp and pitch does not match texture > fpitch:" + IntToStr(fpitch) +" vs pitch:" + IntToStr(pitch) + " fbpp (bits per pixel):" + IntToStr(bpp) +" vs bpp:" + IntToStr(bpp) );
1129  return moText("");
1130 
1131  }
1132 
1133 /*
1134  RGBQUAD colorv;
1135  if( FALSE==FreeImage_GetPixelColor( fbitmap, 0, 0, &colorv )) {
1136  MODebug2->Error("moTexture::CreateThumbnail > freeimage conversion failed somehow: no FreeImage_GetPixelColor!");
1137  return moText("");
1138  } else {
1139  MODebug2->Message("moTexture::CreateThumbnail > ");
1140  }
1141  */
1142 /*
1143  FILE* fp = fopen( thumbnailfilename ,"wb" );
1144  fwrite( FreeImage_, sizeof(BYTE), m_width * m_height * 3 , fp );
1145  fclose(fp);
1146  */
1147 
1148  FIBITMAP* fbitmap2 = NULL;
1150  //crop image...to match resolution
1151  if ( m_pResourceManager->GetRenderMan()->ScreenWidth() == w && w <= (int)GetWidth()
1152  && m_pResourceManager->GetRenderMan()->ScreenHeight() == h && h <= (int)GetHeight() ) {
1153  //MODebug2->Message("FreeImage_Copy");
1154  fbitmap2 = FreeImage_Copy( fbitmap, 0, 0, w, h);
1155  if (fbitmap2 && fbitmap) { FreeImage_Unload( fbitmap ); fbitmap=fbitmap2; }
1156  }
1157  } else {
1158  //MODebug2->Message("FreeImage_Rescale");
1159  w = (w / 4 ) * 4;
1160  h = (h / 4 ) * 4;
1161  if (w!=(int)GetWidth() || h!=(int)GetHeight()) fbitmap2 = FreeImage_Rescale( fbitmap, w, h, FILTER_BICUBIC );
1162  if (fbitmap2 && fbitmap) { FreeImage_Unload( fbitmap ); fbitmap=fbitmap2; }
1163  }
1164 
1165  //MODebug2->Message("FreeImage_FlipVertical");
1166  //MODebug2->Message("FreeImage_GetVersion:" + moText(FreeImage_GetVersion()));
1167  //FreeImage_FlipVertical( fbitmap );
1168 
1169 
1170  if (!FreeImage_Save( fif, fbitmap, thumbnailfilename, options )) {
1171  MODebug2->Error("moTexture::CreateThumbnail > not saved to disc. thumbnailfilename: " + thumbnailfilename);
1172  }
1173 
1174  if (fbitmap) { FreeImage_Unload( fbitmap ); }
1175 
1177  /*
1178  if (m_pBufferData)
1179  delete [] m_pBufferData;
1180  */
1181 
1182 
1183 
1184  //return ( moText("width:") + IntToStr(width) + moText("height:") + IntToStr(height) + moText("pitch") + IntToStr(ppitch) + moText("fif") + IntToStr(fif) + moText("oo") + IntToStr((int)fbitmap) );
1185 
1186  return thumbnailfilename;
1187 
1188 }
1189 
1190 
1191 //===========================================
1192 //
1193 // moTextureMemory
1194 //
1195 //===========================================
1196 
1198  reference_counter = 0;
1199  m_SizeInMemory = 0;
1200  m_bBitmapInMemory = false;
1201  hmem = NULL;
1202  fif = 0;
1203  m_BufferFormat = moText("JPG");
1204  Luminance = -1;
1205  Contrast = -1;
1206 
1207  int i = 0;
1208  for( i = 0; i<256; i++) Histogram[i] = 0;
1209 
1210 }
1211 
1213 
1214 }
1215 
1217 
1218  return moTexture::Init( p_name, p_moid, p_res, p_param );
1219 
1220 }
1221 
1222 MOboolean moTextureMemory::Init( moText p_name, MOuint p_moid, moResourceManager* p_res, moText bufferformat, moBitmap* pImageResult, moTexParam p_param ) {
1223 
1224  m_BufferFormat = bufferformat;
1225 
1226  if (pImageResult) LoadFromBitmap(pImageResult);
1227 
1228  return moTexture::Init( p_name, p_moid, p_res, p_param );
1229 }
1230 
1232 
1233  if ( m_bBitmapInMemory && hmem!=NULL ) {
1235  reference_counter = 1;
1236  ReleaseReference();
1238  FreeImage_CloseMemory((FIMEMORY*)hmem);
1239  hmem = NULL;
1240  }
1241 
1242  if (!hmem) {
1243  hmem = FreeImage_OpenMemory();
1244  }
1245  if (hmem) {
1246 
1247  if ( m_BufferFormat == moText("JPG")) {
1248  fif = FIF_JPEG;
1249  options = JPEG_QUALITYNORMAL;
1250  } else if ( m_BufferFormat == moText("JPGSUPERB") ) {
1251  fif = FIF_JPEG;
1252  options = JPEG_QUALITYSUPERB;
1253  } else if ( m_BufferFormat == moText("JPGBAD") ) {
1254  fif = FIF_JPEG;
1255  options = JPEG_QUALITYBAD;
1256  } else if ( m_BufferFormat == moText("JPGAVERAGE") ) {
1257  fif = FIF_JPEG;
1258  options = JPEG_QUALITYAVERAGE;
1259  } else if ( m_BufferFormat == moText("JPGGOOD") ) {
1260  fif = FIF_JPEG;
1261  options = JPEG_QUALITYGOOD;
1262  } else if ( m_BufferFormat == moText("TGA") ) {
1263  fif = FIF_TARGA;
1264  options = 0;
1265  } else if ( m_BufferFormat == moText("PNG") ) {
1266  fif = FIF_PNG;
1267  options = 0;
1268  } else if ( m_BufferFormat == moText("XPM") ) {
1269  fif = FIF_XPM;
1270  options = 0;
1271  } else if ( m_BufferFormat == moText("RAW") ) {
1272  fif = FIF_PPMRAW;
1273  options = 0;
1274  } else if ( m_BufferFormat == moText("EXR") ) {
1275  fif = FIF_EXR;
1276  options = 0;
1277  } else if ( m_BufferFormat == moText("HDR") ) {
1278  fif = FIF_HDR;
1279  options = 0;
1280  } else if ( m_BufferFormat == moText("JXR") ) {
1281  fif = FIF_JXR;
1282  options = 0;
1283  } else if ( m_BufferFormat == moText("GIF") ) {
1284  fif = FIF_GIF;
1285  options = 0;
1286  } else if ( m_BufferFormat == moText("PSD") ) {
1287  fif = FIF_PSD;
1288  options = 0;
1289  } else if ( m_BufferFormat == moText("PPM") ) {
1290  fif = FIF_PPM;
1291  options = 0;
1292  } else if ( m_BufferFormat == moText("TIFF") ) {
1293  fif = FIF_TIFF;
1294  options = 0;
1295  } else if ( m_BufferFormat == moText("JP2") ) {
1296  fif = FIF_JP2;
1297  options = 0;
1298  } else if ( m_BufferFormat == moText("BMP") ) {
1299  fif = FIF_BMP;
1300  options = 0;
1301  } else if ( m_BufferFormat == moText("WEBP") ) {
1302  fif = FIF_WEBP;
1303  options = 0;
1304  } else if ( m_BufferFormat == moText("XPM") ) {
1305  fif = FIF_XPM;
1306  options = 0;
1307  } else if ( m_BufferFormat == moText("XBM") ) {
1308  fif = FIF_XBM;
1309  options = 0;
1310  }
1311  //syntax: FreeImage_SaveToMemory(FREE_IMAGE_FORMAT fif, FIBITMAP *dib, FIMEMORY *stream, int flags FI_DEFAULT(0));
1312  if ( FreeImage_SaveToMemory( (FREE_IMAGE_FORMAT)fif, (FIBITMAP *)p_bitmap, (FIMEMORY*)hmem, options ) ) {
1313  m_SizeInMemory = FreeImage_TellMemory((FIMEMORY*)hmem);
1314  m_bBitmapInMemory = true;
1315 
1316  m_width = FreeImage_GetWidth((FIBITMAP *)p_bitmap);
1317  m_height = FreeImage_GetHeight((FIBITMAP *)p_bitmap);
1318 
1320 
1321  if (FreeImage_GetHistogram( (FIBITMAP *)p_bitmap, (DWORD*)Histogram, FICC_BLACK )) {
1322 
1324  Luminance = 0;
1325  long Total = 0;
1326 
1327  for(int ih=0; ih <256; ih++) {
1328  Total+= Histogram[ih];
1329  Luminance+= Histogram[ih]*ih;
1330 
1331  }
1332 
1333  Luminance = Luminance / Total;
1334 
1335 
1336 
1338  int Group[5];
1339  int Totals[5];
1340 
1341  Group[0] = 0;
1342  Group[1] = 0;
1343  Group[2] = 0;
1344  Group[3] = 0;
1345  Group[4] = 0;
1346 
1347  Totals[0] = 0;
1348  Totals[1] = 0;
1349  Totals[2] = 0;
1350  Totals[3] = 0;
1351  Totals[4] = 0;
1352 
1353 
1354  int zone = 0;
1355  long dif = 0;
1356  for(int ih=0; ih <256; ih++) {
1357  zone = ih / 52;
1358  dif = ( Histogram[ih]*(ih - Luminance)*(ih - Luminance));
1359  Group[zone]+= dif;
1360  Totals[zone]+= Histogram[ih];
1361  }
1362 
1363  Contrast = 0;
1364  for(int z=0;z<5;z++) {
1365  if (Totals[z]>0) Contrast+= Group[z] / Totals[z];
1366  }
1367  Contrast = Contrast / 5;
1368 
1369  } else MODebug2->Error( moText("moTextureMemory::LoadFromBitmap Histogram error"));
1370 
1371 
1372 
1373  //MODebug2->Push( moText("moTextureMemory::LoadFromBitmap success: hmem:") + IntToStr((int)hmem));
1374  //MODebug2->Push( moText("moTextureMemory::LoadFromBitmap luminance:") + IntToStr(Luminance) + moText(" contrast:") + IntToStr(Contrast) );
1375  } else m_bBitmapInMemory = false;
1376 
1377  }
1378 
1379  return m_bBitmapInMemory;
1380 
1381 }
1382 
1384 
1385  FIBITMAP *pImage;
1386  MODebug2->Message("LoadFromMemory: size in memory: " + IntToStr(m_SizeInMemory)+" m_glid:" + IntToStr(m_glid));
1387  if (hmem!=NULL && m_glid>=0) {
1388 
1389  //FIMEMORY *hmem;
1390 
1391  //MOuint _format;
1392 
1393  //MOint FrameSize =
1394  FreeImage_TellMemory((FIMEMORY*)hmem);
1395  FreeImage_SeekMemory( (FIMEMORY*)hmem, 0L, SEEK_SET);
1396 
1397  //hmem = FreeImage_OpenMemory( pVideoFrame->hmem, pVideoFrame->m_FrameSize);
1398  //FreeImage_TellMemory(VideoFrame->hmem);
1399  // load an image from the memory stream
1400  pImage = FreeImage_LoadFromMemory( (FREE_IMAGE_FORMAT)fif, (FIMEMORY*)hmem, 0);
1401 
1402  switch (FreeImage_GetBPP(pImage))
1403  {
1404  case 8: // 8 bit, indexed or grayscale
1405  m_param.internal_format = GL_RGB;
1406  _format = GL_LUMINANCE;
1407  break;
1408  case 16: // 16 bits
1409  break;
1410  case 24: // 24 bits
1411  m_param.internal_format = GL_RGB;
1412 #ifndef OPENGLESV2
1413  if (FreeImage_GetBlueMask(pImage) == 0x000000FF) _format = GL_BGR;
1414  else
1415 #endif
1416  _format = GL_RGB;
1417 #ifndef OPENGLESV2
1418  #ifdef WIN32
1419  _format = GL_BGR;
1420  #endif // WIN32
1421 #endif
1422  break;
1423  case 32: // 32 bits
1424  m_param.internal_format = GL_RGBA;
1425 #ifndef OPENGLESV2
1426  if (FreeImage_GetBlueMask(pImage) == 0x000000FF) _format = GL_BGRA_EXT;
1427  else
1428 #endif
1429  _format = GL_RGBA;
1430  break;
1431  default:
1432  m_param.internal_format = GL_RGBA;
1433  _format = GL_RGBA;
1434  break;
1435  }
1436  FlipBufferVert((MOubyte *)FreeImage_GetBits(pImage), FreeImage_GetBPP(pImage) / 8 );
1437  return (moBitmap*)pImage;
1438  }
1439  return NULL;
1440 }
1441 
1443  FIBITMAP *pImage = (FIBITMAP*) LoadFromMemory();
1444  if (pImage) {
1445  return (MOubyte*)FreeImage_GetBits(pImage);
1446  }
1447  return NULL;
1448 }
1449 
1451  if (p_bitmap) {
1452  FreeImage_Unload( (FIBITMAP*)p_bitmap );
1453  }
1454 }
1455 
1457 
1458 
1459  FIBITMAP *pImage = (FIBITMAP*) LoadFromMemory();
1460  if (pImage) {
1462  Build();
1464  SetBuffer( m_width, m_height, FreeImage_GetBits(pImage), _format);
1465  FreeImage_Unload( pImage );
1466  //MODebug2->Push( moText("moTextureMemory::BuildFromMemory: success: hmem:") + IntToStr((int)hmem) + moText("glid:") + IntToStr(m_glid));
1467  return true;
1468  } else {
1469  //MODebug2->Error( moText("moTextureMemory::BuildFromMemory: Error GLID or Memory never assigned. hmem:") + IntToStr((int)hmem) + moText("glid:") + IntToStr(m_glid));
1470  return false;
1471  }
1472 }
1473 
1474 
1475 
1477 {
1478  MOboolean res = false;
1479 
1480  m_BufferFormat = p_bufferformat;
1481 
1482  if (p_bitmap != NULL)
1483  {
1485  res = LoadFromBitmap( p_bitmap );
1487 
1488  }
1489  else {
1490  if (MODebug2 != NULL) MODebug2->Error(moText("Error at image build from bitmap: [pointer is null] ") + (moText) this->GetName());
1491  res = false;
1492  }
1493 
1494  return res;
1495 }
1496 
1497 
1499 
1500 
1501  //si la referencia es 0:
1502  //asigna la textura
1503  if (this->Initialized()) {
1504 
1505  if (reference_counter==0) {
1506  if (m_bBitmapInMemory) {
1507  glGenTextures(1, &m_glid);
1509  if (BuildFromMemory()) {
1510  //MODebug2->Push( moText("moTextureMemory::GetReference success: glid: ") + IntToStr(m_glid) );
1512  }
1513  } else MODebug2->Push( moText("moTextureMemory::GetReference no bitmap in memory ") );
1514  }
1515  } else MODebug2->Error( moText("moTextureMemory::GetReference Error: object not initialized") );
1516 
1517  return ((int)reference_counter);
1518 }
1519 
1521  if (reference_counter>0) {
1523  if ( reference_counter==0 ) {
1525  if (m_glid>0) {
1526  glDeleteTextures(1,&m_glid);
1527  m_glid = 0;
1528  }
1529  }
1530  }
1531 }
1532 
1534 
1535  if (hmem) {
1536  FreeImage_CloseMemory( (FIMEMORY*)hmem );
1537  hmem = NULL;
1538  }
1539 
1540  m_SizeInMemory = 0;
1541  hmem = NULL;
1542  fif = (int)FIF_UNKNOWN;
1543 
1544  return moTexture::Finish();
1545 
1546 }
1547 
1548 //===========================================
1549 //
1550 // moTextureAnimated
1551 //
1552 //===========================================
1553 
1555 {
1556  m_FrameJump = 0;
1557  m_FrameNext = 0;
1558  m_FramePrevious = 0;
1559  m_FrameStart = 0;
1560  m_FrameEnd = 0;
1561  m_ActualFrame = 0;
1562  m_nFrames = 0;
1563  m_InterpolationTime = 0;
1564  m_bInterpolation = false;
1565  m_bInterpolating = false;
1566  m_pShaderCopy = NULL;
1567  m_pShaderInterpolate = NULL;
1568  m_pCopyStart = NULL;
1569  m_pCopyEnd = NULL;
1570  m_pInterpolator = NULL;
1572 }
1573 
1575 {
1576  Finish();
1577 }
1578 
1580 {
1581  m_FrameJump = 0;
1582  m_FrameNext = 0;
1583  m_FramePrevious = 0;
1584  m_FrameStart = 0;
1585  m_FrameEnd = 0;
1586  m_nFrames = 0;
1587  m_InterpolationTime = 0;
1588  m_bInterpolation = false;
1589  m_bInterpolating = false;
1590  m_pShaderCopy = NULL;
1591  m_pShaderInterpolate = NULL;
1592  m_pCopyStart = NULL;
1593  m_pCopyEnd = NULL;
1594  m_pInterpolator = NULL;
1596 
1597  return moTexture::Init(p_name, p_moid, p_res, p_param);
1598 }
1599 
1601 {
1616  return moTexture::Finish();
1617 }
1618 
1619 
1621  m_bIsPlaying = true;
1622 }
1623 
1624 
1626  m_bIsPlaying = false;
1627 }
1628 
1629 
1631  //m_bIsPlaying = true;
1632  return m_bIsPlaying;
1633 }
1634 
1635 void
1636 moTextureAnimated::SetInterpolation( MOuint p_FrameJump, MOuint p_InterpolationTime ) {
1637 
1638  m_FrameJump = p_FrameJump;
1639  m_InterpolationTime = p_InterpolationTime;
1657 
1660  if (!m_pCopyStart && this->GetWidth()>0 ) {
1661  moTextArray copy_filter_0;
1662  copy_filter_0.Add( moText( this->m_name+" shaders/Copy.cfg "+this->m_name+"copyStart") );
1663  int idx = SM->GetTextureFilterIndex()->LoadFilters( &copy_filter_0 );
1664  if (idx>-1) {
1665  m_pCopyStart = SM->GetTextureFilterIndex()->Get(idx-1);
1666  MODebug2->Message( moText("filter loaded m_pCopyStart") );
1667  }
1668  }
1669 
1670  if (!m_pCopyEnd && this->GetWidth()>0 ) {
1671  moTextArray copy_filter_0;
1672  copy_filter_0.Add( moText( this->m_name+" shaders/Copy.cfg "+this->m_name+"copyEnd") );
1673  int idx = SM->GetTextureFilterIndex()->LoadFilters( &copy_filter_0 );
1674  if (idx>-1) {
1675  m_pCopyEnd = SM->GetTextureFilterIndex()->Get(idx-1);
1676  MODebug2->Message( moText("filter loaded m_pCopyEnd") );
1677  }
1678  }
1679 
1680  if (!m_pInterpolator && this->GetWidth()>0 ) {
1681  moTextArray copy_filter_0;
1682  copy_filter_0.Add( moText( this->m_name+"copyStart "+this->m_name+"copyEnd shaders/TexInterpolator.cfg "+this->m_name+"") );
1683  int idx = SM->GetTextureFilterIndex()->LoadFilters( &copy_filter_0 );
1684  if (idx>-1) {
1685  m_pInterpolator = SM->GetTextureFilterIndex()->Get(idx-1);
1686  MODebug2->Message( moText("filter loaded m_pInterpolator") );
1687  }
1688  }
1728 }
1729 
1730 MOboolean
1732  return m_bInterpolating;
1733 }
1734 
1735 MOboolean
1737  return m_bInterpolation;
1738 }
1739 
1740 MOboolean
1742  if (m_pCopyStart && m_pCopyEnd && m_pInterpolator && activate) {
1743  m_bInterpolation = true;
1744  } else {
1745  m_bInterpolation = false;
1746  m_bInterpolating = false;
1747  }
1748  return m_bInterpolation;
1749 }
1750 
1751 
1752 //Cuando necesitamos interpolacion?
1753 //
1754 // Suavizado de saltos:
1755 // 1) se paso el intervalo maximo entre el cuadro actual y el siguiente
1756 // 2) todavia se esta en un ciclo de interpolacion
1757 //
1758 // Camara lenta: (a implementar)
1759 // 1) el tiempo maximo entre dos cuadros contiguos fue superado, entonces se generará un cuadro intermedio proporcional
1760 // 2) todavia se esta en un ciclo de interpolacion
1761 MOboolean
1763  // pasamos la barrera del m_FrameJump
1764  // !!!chequear que el next y el previous esten correctamente fijados
1765  //MODebug2->Push( moText("Pr:")+IntToStr(m_FramePrevious)+moText("Nxt:")+IntToStr(m_FrameNext) );
1766  //return false;
1767  if (!m_bInterpolation)
1768  return false;
1769 
1770  if (!m_bInterpolating) {
1771  if ( fabs( (double)((double)m_FrameNext - (double)m_FramePrevious) ) > (double)m_FrameJump ) {
1774  //desactivamos la interpolacion para poder acceder a los cuadros correspondientes libremente
1775  m_bInterpolating = false;
1776  ActivateInterpolation(false);
1777  //TODO: fix this
1778  moTextFilterParam DefParam;
1779  if (m_pCopyStart) m_pCopyStart->Apply( m_FrameStart, 1.0, DefParam );
1780  if (m_pCopyEnd) m_pCopyEnd->Apply( m_FrameEnd, 1.0, DefParam );
1781  //activamos nuevamente la interpolacion una vez copiados los cuadros
1782  ActivateInterpolation(true);
1783  m_bInterpolating = true;
1784  //fijamos nuevamente el previous y el next
1785  m_FramePrevious = m_FrameStart;
1787  m_StartTime = moGetTicks();
1788  return true;
1789  }
1790  } else {
1791  if ( m_InterpolationPosition >= 1.0 ) {
1792  m_StartTime = 0;
1793  m_bInterpolating = false;
1794  }
1795  }
1796  return m_bInterpolating;
1797 }
1798 
1799 
1800 MOint
1802  moTextFilterParam filterparam;
1803 
1805  if (m_bInterpolating) {
1806  MOuint m_ActualTime = moGetTicks();
1807  m_InterpolationPosition = (float)( m_ActualTime - m_StartTime ) / (m_InterpolationTime);
1810  filterparam = m_pInterpolator->GetTextFilterParam();
1811  filterparam.par_flt1 = m_InterpolationPosition;
1812  //TODO: fix this
1813  MODebug2->Message( moText("IP:")+FloatToStr(m_InterpolationPosition)+moText(" Param par_flt1:")+FloatToStr(filterparam.par_flt1)+moText(" Param UNIFORM ID:")+IntToStr(filterparam.m_par_flt1) );
1814 
1815  m_pInterpolator->Apply( m_InterpolationPosition, 1.0, filterparam );
1816 
1817  //MODebug2->Message( moText("IP:")+FloatToStr(m_InterpolationPosition) );
1818  return 1;
1819  }
1820  }
1821  return 0;
1822 }
1823 
1824 
1825 // NOTA: este algoritmo fija el cuadro next emparejando el moTempo con la cantidad de frames...
1826 MOint
1828  //segun el tempo elige el cuadro!
1829  int t;
1830  float ft,PeliV;
1831 
1832  //MODebug2->Message("moTextureAnimated::GetGLId > "+this->GetName()
1833  //+ " m_FrameNext:"+IntToStr(m_FrameNext)+"/m_nFrames:"+IntToStr(m_nFrames));
1834  if(p_tempo==NULL) {
1835  t = m_Time - moGetTicks();
1836  ft = (t / 1000) * m_fFramesPerSecond;//frames que deberian haber pasado en este lapso...
1837 
1838  if(ft >= 0.99) {
1839 
1840  m_FrameNext++;
1841 
1842  if( m_FrameNext >= m_nFrames ) {
1843  m_FrameNext = 0;
1844  }
1845 
1846  }
1847 
1848  } else {
1849  PeliV = fmod( p_tempo->ang*double(m_nFrames) / double(2*moMathf::PI) , double(m_nFrames) );
1850  m_FrameNext = min( int(ceilf(PeliV)), int(m_nFrames - 1) );
1851  //MODebug2->Push( "peliv:" + FloatToStr(PeliV) + " fnext: " + IntToStr(m_FrameNext));
1852  //PeliV = fmod( float( p_tempo->ang ), float(2*moMathf::PI)) /(2*moMathf::PI);
1853  //m_FrameNext = min(int(PeliV * m_nFrames), m_nFrames - 1);
1854  }
1855 
1856  if (NeedsInterpolation()) {
1857  Interpolate();
1858  } else {
1859  //MODebug2->Message(" fprev:"+IntToStr(m_FramePrevious)+" fnext:" + IntToStr(m_FrameNext));
1862  }
1863 
1864  return m_glid;
1865 }
1866 
1867 // NOTA: este devuelve simplemente el glid correspondiente al cuadro interno "i"
1868 //como en este caso no estan definidos las sub-texturas, ya q depende de cada implementaci�
1869 //devuelve el m_glid de moTexture
1870 MOint
1872 
1873  if (/*p_i>2000 ||*/ p_i>m_nFrames) {
1874  //WTF
1875  p_i = 0;
1876  }
1877 
1878  m_FrameNext = p_i;
1879 
1880  if (NeedsInterpolation()) {
1881 
1882  MODebug2->Message( moText("moTextureAnimated::GetGLId( MOuint p_i ) > Interpolating image! ")+GetName()+
1883  " From m_FramePrevious: " + IntToStr( m_FramePrevious )+
1884  " To m_FrameNext: " + IntToStr( m_FrameNext )+
1885  " At m_InterpolationPosition: " + FloatToStr( m_InterpolationPosition, 2, 2 )+
1886  "From m_FrameStart: " + IntToStr( m_FrameStart )+
1887  " To m_FrameEnd: " + IntToStr( m_FrameEnd )
1888  );
1889  Interpolate();
1890  } else {
1891  //MODebug2->Message(" fprev:"+IntToStr(m_FramePrevious)+" fnext:" + IntToStr(m_FrameNext));
1892  if(m_FramePrevious!=p_i) this->GetFrame(p_i);
1893  m_FramePrevious = m_FrameNext = p_i;
1894  }
1895 
1896  return m_glid;
1897 }
1898 
1900 
1901  MOfloat PeliV;
1902 
1903  PeliV = fmod( (float)p_cycle, (float)1.0 );
1904  m_FrameNext = min(int(PeliV * m_nFrames), int(m_nFrames - 1));
1905 
1906  if (NeedsInterpolation()) {
1907  Interpolate();
1908  } else {
1911  }
1912  return m_glid;
1913 
1914 }
1915 
1916 void
1918 
1920  if (p_i>0) return;
1921  return;
1922 }
1923 
1924 MOuint
1926 
1927  return this->m_ActualFrame;
1928 }
1929 
1930 
1932  m_PlayMode = playmode;
1933 }
1934 
1936  return m_PlayMode;
1937 }
1938 
1939 
1940 //===========================================
1941 //
1942 // moTextureMultiple
1943 //
1944 //===========================================
1945 
1947 {
1949 }
1950 
1952 {
1953  Finish();
1954 }
1955 
1957 {
1958  moTextureAnimated::Init(p_name, p_moid, p_res, p_param);
1959 
1960  m_nFrames = 0;
1961  m_fFramesPerSecond = 24.0;
1962  m_textures_array.Init(0, NULL);
1963  return true;
1964 }
1965 
1967 {
1968  m_textures_array.Finish();
1970  return true;
1971 }
1972 
1974 {
1975  moText begin = p_filename;
1976  begin.Left(7);
1977  return !stricmp(begin,"multiple");
1978 }
1979 
1981 {
1982  moValue* pValue = &p_param->GetValue();
1983  return Load(pValue);
1984 }
1985 
1987 {
1988  SetName(p_value->GetSubValue(0).Text());
1989 
1990  int nframes = p_value->GetSubValueCount() - 1;
1991  moText fn;
1992  moTexture* newtex;
1993  for (int i = 0; i < nframes; i++)
1994  {
1995  fn = m_pDataMan->GetDataPath() + moSlash + p_value->GetSubValue(i + 1).Text();
1996  if (moTexture::SupportedFile(fn))
1997  {
1998  if (BuildFromFile(fn))
1999  {
2000  newtex = new moTexture;
2001  newtex->SetName(fn);
2002  newtex->CopyFromTex((moTexture*)this, true, false, false, false);
2003  m_textures_array.Add(newtex);
2004  }
2005  }
2006  }
2008 
2009  m_bBuildedFromFile = (0 < m_textures_array.Count());
2010 
2011  return 0 < m_textures_array.Count();
2012 }
2013 
2014 MOboolean moTextureMultiple::Load(moText p_name, moTextureArray &p_textures, MOuint p_id0, MOuint p_id1)
2015 {
2016  SetName(p_name);
2017  m_textures_array.Copy(p_textures, p_id0, p_id1);
2019  return 0 < m_textures_array.Count();
2020 }
2021 
2023 {
2024  m_textures_array.Init(p_tex_count, NULL);
2025  SetFrameCount(p_tex_count);
2026 }
2027 
2029 {
2030  if (ValidTexture(p_i)) {
2031  this->CopyFromTex(m_textures_array[p_i], true, false, false, false);
2032  this->m_ActualFrame = p_i;
2033  }
2034  else m_glid = 0;
2035 }
2036 
2038 {
2039  if (p_i < m_textures_array.Count() && p_texture) {
2040  if (ValidTexture(p_i)) {
2041  m_textures_array[p_i]->CopyFromTex(p_texture, true, true, true, true);
2042  }
2043  else
2044  {
2045  m_textures_array[p_i] = p_texture;
2046  }
2047  }
2048 }
2049 
2051 {
2052  m_textures_array.Add(p_texture);
2053  m_nFrames++;
2054 }
2055 
2057 {
2058  return ((p_i < (MOuint)m_textures_array.Count()) && (m_textures_array[p_i] != NULL));
2059 }
2060 
2061 //===========================================
2062 //
2063 // moMovie
2064 //
2065 //===========================================
2066 
2068 {
2070  m_pGraph = NULL;
2072  m_pFilename = "";
2073  m_bIsPlaying = false;
2074  m_bIsPaused = false;
2075 }
2076 
2078 {
2079  Finish();
2080 }
2081 
2083 {
2084  moTextureAnimated::Init(p_name, p_moid, p_res, p_param);
2085  if(!m_pGraph) {
2086 
2087  #ifdef MO_DIRECTSHOW
2088  m_pGraph = (moVideoGraph*) new moDsGraph();
2089  #endif
2090 
2091  #ifdef MO_GSTREAMER
2092  m_pGraph = (moVideoGraph*) new moGsGraph();
2093  #endif
2094  }
2095 
2097 
2098  return true;
2099 }
2100 
2102 {
2103  if (m_pGraph!=NULL)
2104  {
2105  delete m_pGraph;
2106  m_pGraph = NULL;
2107  }
2109  return true;
2110 }
2111 
2113  if (m_pGraph) {
2114  m_pGraph->Play();
2115  m_bIsPlaying = true;
2116  m_bIsPaused = false;
2117  }
2118 }
2119 
2121  if (m_pGraph) {
2122  m_pGraph->Pause();
2123  m_bIsPlaying = false;
2124  m_bIsPaused = true;
2125  }
2126 }
2127 
2129  if (m_pGraph) {
2130  m_pGraph->Play();
2131  m_bIsPlaying = true;
2132  m_bIsPaused = false;
2133  }
2134 }
2135 /*
2136 void BackToBlack( moTexture* pTex ) {
2137  if (pTex) {
2138  long size = pTex->GetWidth() * pTex->GetHeight() * 4;
2139  MOubyte* allblack = new MOubyte [size];
2140  memset( allblack, 0 , size);
2141  pTex->SetBuffer( allblack );
2142  }
2143 }
2144 */
2145 
2147  if (m_pGraph) {
2148  //if (GetPosition()==0 && m_pGraph->GetState()!=MO_STREAMSTATE_STOPPED) {
2149 
2150  m_pGraph->Stop();
2151  m_bIsPlaying = false;
2152  m_bIsPaused = false;
2153 
2154  //} else if ( GetPosition()!=0) {
2155  // m_pGraph->Pause();
2156  // m_pGraph->Seek(0);
2157  // m_bIsPlaying = true;
2158  //}
2159  }
2160 }
2161 
2162 void moMovie::Seek( long frame, float rate ) {
2163  if (m_pGraph) {
2164  m_pGraph->Seek( frame, rate );
2165  }
2166 }
2167 
2169  if (m_pGraph)
2170  return m_pGraph->GetPosition();
2171  return 0;
2172 }
2173 
2175 
2176  moStreamState stream_state = MO_STREAMSTATE_UNKNOWN;
2177 
2178  if (m_pGraph) {
2179 
2180  stream_state = m_pGraph->GetState();
2181 
2182  switch(stream_state) {
2184  m_bIsPlaying = true;
2185  m_bIsPaused = false;
2186  break;
2187  case MO_STREAMSTATE_PAUSED:
2188  m_bIsPlaying = false;
2189  m_bIsPaused = true;
2190  break;
2191  default:
2192  m_bIsPlaying = false;
2193  m_bIsPaused = false;
2194  break;
2195  }
2196 
2197  }
2198 
2199  return stream_state;
2200 }
2201 
2203 
2204  if (m_pGraph) {
2205  //MODebug2->Message("moMovie::IsPlaying > calling m_pGraph->GetState()");
2206  //m_pGraph->GetState();
2207  this->State();
2208  //MODebug2->Message("moMovie::IsPlaying > GetState returned");
2209  }
2210  return m_bIsPlaying;
2211 }
2212 
2214 
2215  if (m_pGraph) {
2216  //MODebug2->Message("moMovie::IsPlaying > calling m_pGraph->GetState()");
2217  //m_pGraph->GetState();
2218  this->State();
2219  //MODebug2->Message("moMovie::IsPlaying > GetState returned");
2220  }
2221  return m_bIsPaused;
2222 }
2223 
2224 
2225 void moMovie::SetBrightness( float brightness ) {
2226  if (m_pGraph) {
2227  m_pGraph->SetContrast( brightness );
2228  }
2229 }
2230 
2231 
2232 
2233 void moMovie::SetContrast( float contrast ) {
2234  if (m_pGraph) {
2235  m_pGraph->SetContrast( contrast );
2236  }
2237 }
2238 
2239 
2240 
2241 void moMovie::SetHue( float hue ) {
2242  if (m_pGraph) {
2243  m_pGraph->SetHue( hue );
2244  }
2245 }
2246 
2247 
2248 
2249 void moMovie::SetSaturation( float saturation ) {
2250  if (m_pGraph) {
2251  m_pGraph->SetSaturation( saturation);
2252  }
2253 }
2254 
2255 void moMovie::SetVolume( float volume ) {
2256 
2257  if ( HasAudio() && m_pGraph) {
2258  m_pGraph->SetVolume( volume);
2259  }
2260 }
2261 
2262 void moMovie::SetBalance( float balance ) {
2263  if ( HasAudio() && m_pGraph) {
2264  m_pGraph->SetBalance( balance);
2265  }
2266 }
2267 
2269  return true;
2270 }
2271 
2273  return true;
2274 }
2275 
2277 
2278  if (m_pGraph) {
2279  return m_pGraph->IsEOS();
2280  }
2281  return false;
2282 
2283 }
2284 
2286 {
2287 
2288  moFile FileName(p_filename);
2289  moText extension = FileName.GetExtension();
2290  return (!stricmp(extension,".avi") ||
2291  !stricmp(extension,".mov") ||
2292  !stricmp(extension,".mpg") ||
2293  !stricmp(extension,".mp4")||
2294  !stricmp(extension,".ogg") ||
2295  !stricmp(extension,".ogm") ||
2296  !stricmp(extension,".ogv") ||
2297  !stricmp(extension,".webm") ||
2298  !stricmp(extension,".web") ||
2299  !stricmp(extension,".mpv") ||
2300  !stricmp(extension,".mkv") ||
2301  !stricmp(extension,".m2v"));
2302 }
2303 
2305 {
2306  moText extension;
2307  MOboolean result = false;
2308  bool quicktime = false;
2309 
2310  extension = p_filename;
2311  extension.Right(3);
2312 
2313  if (extension==moText("mov")) quicktime = true;
2314 
2315  MOulong frames;
2316  MOboolean graphloaded = false;
2317  if (m_pGraph)
2318  {
2319  if (!m_pGraph->InitGraph())
2320  return false;
2321 
2322  if (quicktime)
2323  {
2325  graphloaded = m_pGraph->BuildLiveQTVideoGraph( p_filename, &m_BucketsPool);
2326  }
2327  else
2328  {
2330  graphloaded = m_pGraph->BuildLiveVideoGraph( p_filename, &m_BucketsPool);
2331  }
2332 
2333  if ( graphloaded )
2334  {
2335  m_pGraph->Pause();
2336 
2337  frames = m_pGraph->GetFramesLength();
2338  frameprevious = 0;
2339 
2340  SetFramesPerSecond(( (double) m_pGraph->GetVideoFormat().m_FrameRate ) / (double)( 100.0 ) );
2341 
2343 
2345 
2346  if (result)
2347  {
2348  lastframe = frames;
2349  SetFrameCount( frames );
2350  }
2351  }
2352  }
2353 
2354  if (result) {
2355  m_bBuildedFromFile = true;
2356  m_pFilename = p_filename;
2357  }
2358 
2359  return result;
2360 }
2361 
2363 {
2364  moValue* pValue = &p_param->GetValue();
2365  return Load( pValue );
2366 }
2367 
2369 {
2370  moText namefull;
2371 
2372  SetName( p_value->GetSubValue(0).Text());
2373 
2374  namefull = m_pDataMan->GetDataPath() + moSlash + (moText)m_name;
2375 
2376  return LoadMovieFile(namefull);
2377 }
2378 
2379 MOboolean moMovie::Reload( bool force_kill ) {
2380  if (force_kill) {
2381  //kill moGsGraph!!
2382  //check m_pFilename and reload!!
2383 
2384  }
2385  return true;
2386 }
2387 
2388 void moMovie::EnableVideo(int enable) {
2389  if (enable) return;
2390 }
2391 
2392 void moMovie::EnableAudio(int enable) {
2393  if (enable) return;
2394 }
2395 
2397 {
2398 
2399  //MODebug2->Message("GetFrame "+IntToStr(p_i));
2400 
2401  if(m_pGraph)
2402  {
2403 
2404  //MODebug2->Message("moMovie::GetFrame > calling m_pGraph->GetState()");
2405  moStreamState state = m_pGraph->GetState();
2406  //MODebug2->Message("moMovie::GetFrame > returned m_pGraph->GetState()");
2407 
2410  if (state==MO_STREAMSTATE_PAUSED || state==MO_STREAMSTATE_STOPPED) {
2411  /*
2412 
2413  if (state==MO_STREAMSTATE_STOPPED)
2414  m_pGraph->Play();
2415 
2416  if (state==MO_STREAMSTATE_PAUSED)
2417  m_pGraph->Play();
2418  */
2419 
2420  //m_pGraph->Pause();
2421  //MODebug2->Message( "moMovie::GetFrame > Going to p_i:"+IntToStr(p_i)+" Actual real timebase position:" + IntToStr(m_pGraph->GetPosition()) );
2422  } else {
2423  if (state==MO_STREAMSTATE_PLAYING) {
2424  //MODebug2->Message( "moMovie::GetFrame MO_PLAYMODE_TIMEBASE > " + m_pGraph->StateToText(state) );
2425  m_pGraph->GetFrameBuffer(NULL);
2426  }
2427  }
2428  } else {
2429  m_pGraph->Seek( p_i );
2430  m_pGraph->Pause();
2431  }
2432 
2433 
2434  if (!m_BucketsPool.IsEmpty()) {
2435 
2436  moBucket* pbucket = NULL;
2437  MOubyte* pbuffer = NULL;
2438 
2439  pbucket = m_BucketsPool.RetreiveBucket();
2440 
2441  if (pbucket) {
2442  pbuffer = pbucket->GetBuffer();
2443  if (pbuffer) {
2444 
2446  pbucket->Lock();
2447 #ifndef OPENGLESV2
2448  //SetBuffer(pbuffer, GL_BGR_EXT );
2449  SetBuffer(pbuffer, GL_RGB );
2450 #else
2451  SetBuffer(pbuffer, GL_RGB );
2452 #endif
2453 
2454  pbucket->Unlock();
2455 
2456  pbucket->EmptyBucket();
2457  } else {
2458  /*MODebug2->Message("Empty bucket");*/
2459  }
2460  bool destroy = m_BucketsPool.DestroyRetreivedBucket();
2461  //if (destroy) MODebug2->Message("Dstroyed bucket!");
2462  }
2463  } else {
2464 
2465  /*MODebug2->Warning( moText("moMovie::GetFrame()")
2466  + moText(" m_BucketsPool is EMPTY !!!")
2467  + moText(" state:")
2468  + m_pGraph->StateToText(state) );*/
2469 
2470  }
2471 
2472  } else {
2473  MODebug2->Error( moText("moMovie::GetFrame()") + moText(" m_pGraph is NULL !!!") );
2474  }
2475 }
2476 
#define MO_TRUE
Definition: moTypes.h:370
bool HasAudio()
Definition: moTexture.cpp:2272
virtual moStreamState State()
Definition: moTexture.cpp:2174
void moBitmap
Definition: moTexture.h:44
virtual void Seek(long frame, float rate=1.0)
Definition: moTexture.cpp:2162
GLint mag_filter
Definition: moTypes.h:548
Valor de un Parámetro.
Definition: moValue.h:501
MOboolean Initialized()
Pregunta si está inicializado.
Definition: moAbstract.cpp:153
moShader * m_pShaderCopy
Definition: moTexture.h:728
Parámetros internos de una textura.
Definition: moTypes.h:543
moFile * GetFile(moText p_FileName)
MOfloat m_max_coord_t
Definition: moTexture.h:410
MOuint m_FrameStart
Definition: moTexture.h:737
moFileType GetType()
Definition: moFile.cpp:442
virtual MOboolean LoadFromBitmap(moBitmap *p_bitmap)
Guarda el bitmap con el formato elegido en memoria.
Definition: moTexture.cpp:1231
virtual void SetInterpolation(MOuint p_FrameJump, MOuint p_InterpolationTime)
Definition: moTexture.cpp:1636
static void Message(moText p_text)
Anuncia un mensaje al usuario además de guardarlo en el log de texto.
#define MOulong
Definition: moTypes.h:392
moVideoFormat GetVideoFormat()
Devuelve el formato de video.
MOboolean Refresh()
Definition: moTexture.cpp:840
void Error(moText p_text)
Anuncia y registra un error.
Definition: moAbstract.cpp:79
Tempo, beat, ritmo.
Definition: moTempo.h:44
virtual MOboolean Finish()
Definition: moTexture.cpp:1533
int Luminance
Definition: moTexture.h:416
GLint internal_format
Definition: moTypes.h:546
moText m_pFilename
Definition: moTexture.h:938
virtual MOulong GetPosition()
Definition: moTexture.cpp:2168
bool DestroyRetreivedBucket()
Definition: moBuckets.cpp:246
MOboolean m_bIsPaused
Definition: moTexture.h:703
MOboolean m_bBuildedFromFile
Definition: moTexture.h:388
MOuint SetFBOandAttachPoint(moFBO *p_fbo)
Definition: moTexture.cpp:568
virtual void GetFrame(MOuint p_i)
Definition: moTexture.cpp:1917
MOboolean Build()
Definition: moTexture.cpp:765
moValueBase & GetSubValue(MOint p_indexsubvalue=0)
Definition: moValue.h:539
moTextureFilter * m_pCopyStart
Definition: moTexture.h:718
void GetFrame(MOuint p_i)
Definition: moTexture.cpp:2028
virtual ~moTextureMemory()
Definition: moTexture.cpp:1212
void CalculateSize(MOuint p_width, MOuint p_height)
Definition: moTexture.cpp:671
MOboolean BuildFromBuffer(MOuint p_width, MOuint p_height, const GLvoid *p_buffer, GLenum p_format=GL_RGBA, GLenum p_type=GL_UNSIGNED_BYTE)
Definition: moTexture.cpp:136
virtual moPlayMode GetPlayMode()
Definition: moTexture.cpp:1935
virtual MOboolean Finish()
Definition: moTexture.cpp:2101
void GetFrame(MOuint p_i)
Definition: moTexture.cpp:2396
moTextureFilter * Get(MOuint p_idx)
virtual ~moMovie()
Definition: moTexture.cpp:2077
MOuint m_FramePrevious
Definition: moTexture.h:709
#define MO_UNDEFINED
Definition: moTypes.h:379
virtual ~moTextureAnimated()
Definition: moTexture.cpp:1574
moDefineDynamicArray(moTextureArray) moTexture
Definition: moTexture.cpp:39
virtual MOboolean Finish()
Definition: moTexture.cpp:1966
LIBMOLDEO_API moText0 FloatToStr(double a)
Definition: moText.cpp:1134
moRenderManager * GetRenderMan()
virtual void SetVolume(float volume)
Definition: moTexture.cpp:2255
moResourceManager * m_pResourceManager
Definition: moTexture.h:394
virtual MOboolean BuildFromMemory()
Construye la textura opengl desde el bitmap en memoria.
Definition: moTexture.cpp:1456
#define MOboolean
Definition: moTypes.h:385
MOuint m_buffer_height
Definition: moTexture.h:422
MOboolean IsTextureNonPowerOf2Disabled() const
moVideoGraph * m_pGraph
Definition: moTexture.h:941
MOboolean Load(moParam *p_param)
Definition: moTexture.cpp:2362
MOuint GetDataWidth() const
Definition: moTexture.cpp:577
MOfloat m_fFramesPerSecond
Definition: moTexture.h:706
moText0 & Left(MOuint)
Definition: moText.cpp:484
bool Unlock()
Libera el acceso al buffer interno.
Definition: moBuckets.cpp:49
const moTexParam MODefTex2DParams
Parámetros internos predeterminados de una textura.
Definition: moTypes.h:562
virtual ~moTexture()
Definition: moTexture.cpp:80
textura múltiple
Definition: moTexture.h:55
MOubyte * GetBits()
Definition: moTexture.cpp:1442
MOuint _format
Definition: moTexture.h:522
MOboolean BuildEmpty(MOuint p_width, MOuint p_height)
Definition: moTexture.cpp:113
void ReleaseReference()
Definition: moTexture.cpp:1520
bool IsEmpty()
Definition: moBuckets.cpp:139
moTextureFilterIndex * GetTextureFilterIndex()
MOboolean LoadMovieFile(moText p_filename)
Definition: moTexture.cpp:2304
virtual void SetContrast(float contrast)
Definition: moTexture.cpp:2233
MOboolean IsRemote()
Definition: moFile.cpp:458
bool Lock()
Paraliza el acceso al buffer interno.
Definition: moBuckets.cpp:45
MOuint m_FrameJump
Definition: moTexture.h:732
GLint wrap_t
Definition: moTypes.h:550
virtual MOboolean Init()
Inicializa el objeto.
Definition: moAbstract.cpp:141
MOuint GetHeight() const
Definition: moTexture.h:261
MOboolean MipMapTexture(GLint p_min_filter)
virtual void SetSaturation(float saturation)
Definition: moTexture.cpp:2249
moText GetExtension()
Get absolute path and filename "/D/PP/myFileName.txt".
Definition: moFile.cpp:543
const moTextFilterParam & GetTextFilterParam()
MOuint m_glid
Definition: moTexture.h:401
MOboolean CheckErrors(moText p_location)
moFileManager * m_pFileMan
Definition: moTexture.h:392
void Apply(MOuint p_i, MOfloat p_fade, const moTextFilterParam &p_params)
virtual void SetBalance(float balance)
Definition: moTexture.cpp:2262
virtual void Continue()
Definition: moTexture.cpp:2128
moGLManager * GetGLMan()
virtual void SetVolume(float volume)=0
Fija el nivel de volumen.
MOuint m_buffer_width
Definition: moTexture.h:421
MOboolean Exists()
Definition: moFile.cpp:436
moShaderManager * GetShaderMan()
#define MOfloat
Definition: moTypes.h:403
MOint ScreenHeight() const
void FlipBufferVert(MOubyte *pBuffer, MOint p_depth)
Definition: moTexture.cpp:595
moText GetFileName()
Definition: moFile.cpp:477
virtual void Pause()
Definition: moTexture.cpp:2120
MOint lastframe
Definition: moTexture.h:937
moDWord Histogram[256]
Definition: moTexture.h:419
Definition: moFBO.h:60
void SetTextureCount(MOuint p_tex_count)
Definition: moTexture.cpp:2022
moShader * m_pShaderInterpolate
Definition: moTexture.h:729
void AddFrame(moTexture *p_texture)
Definition: moTexture.cpp:2050
moText GetName() const
Definition: moTexture.h:245
moText CreateThumbnail(moText p_bufferformat, int w, int h, moText newfilename=moText(""))
Definition: moTexture.cpp:856
MOboolean m_bInterpolating
Definition: moTexture.h:715
clase de para manejar textos
Definition: moText.h:75
void SetFBOAttachPoint(MOuint p_fbo_attach_point)
Definition: moTexture.h:203
MOuint GetDataHeight() const
Definition: moTexture.cpp:583
virtual MOboolean ActivateInterpolation(MOboolean activate=true)
Definition: moTexture.cpp:1741
MOuint m_buffer_bytespp
Definition: moTexture.h:423
MOubyte * m_pBufferData
Definition: moTexture.h:420
#define MOlong
Definition: moTypes.h:391
virtual MOulong GetPosition()=0
La posición del stream en cuadros.
Grafo de reproducción de video.
Definition: moVideoGraph.h:584
moDWord Histogram[256]
Histogram.
Definition: moTexture.h:537
MOint ScreenWidth() const
void Unload(moBitmap *p_bitmap)
Definition: moTexture.cpp:1450
void EnableAudio(int)
Definition: moTexture.cpp:2392
bool HasVideo()
Definition: moTexture.cpp:2268
MOuint m_StartTime
Definition: moTexture.h:736
moFBO * m_fbo
Definition: moTexture.h:396
int Contrast
Definition: moTexture.h:417
void SetFBO(moFBO *p_fbo)
Definition: moTexture.h:191
void Log(moText p_text)
Escribe un mensaje en el archivo de registro (log)
Definition: moAbstract.cpp:123
moText m_BufferFormat
Definition: moTexture.h:527
virtual MOboolean NeedsInterpolation()
Definition: moTexture.cpp:1762
virtual void SetFrameCount(MOuint p_nframes)
Definition: moTexture.h:624
moText0 moText
Definition: moText.h:291
MOuint AddTexture(MOuint p_width, MOuint p_height, const moTexParam &p_param, MOuint p_glid, MOuint &p_attach_point)
Definition: moFBO.cpp:174
virtual MOulong GetFramesLength()=0
La cantidad de frames, el largo del stream.
moMemory * hmem
Definition: moTexture.h:520
moStreamState
Definition: moVideoGraph.h:140
MOboolean SupportedFile(moText p_filename)
Definition: moTexture.cpp:351
virtual moStreamState GetState()
Estado de la reproducción.
GStreamer Graph Class.
Definition: moGsGraph.h:151
virtual void SetSaturation(float saturation)=0
moText0 & Right(MOuint)
Definition: moText.cpp:491
#define MOint
Definition: moTypes.h:388
virtual bool BuildLiveVideoGraph(moText filename, moBucketsPool *pBucketsPool)=0
Grafo de reproducción de video en modo vivo, asyncronicamente reproducido en función del clock...
const char * message
MOboolean SupportedFile(moText p_filename)
Definition: moTexture.cpp:1973
virtual MOboolean Finish()
Definition: moTexture.cpp:101
MOboolean GetBuffer(GLvoid *p_buffer, GLenum p_format=GL_RGBA, GLenum p_type=GL_UNSIGNED_BYTE)
Definition: moTexture.cpp:426
moFileManager * GetFileMan()
void SetName(moText p_name)
Definition: moTexture.h:250
virtual MOint Interpolate()
Definition: moTexture.cpp:1801
virtual void Stop()
Definition: moTexture.cpp:2146
Clase Base para Objetos Moldeo ( moEffect, moIODevice, moResource, moConsole )
static MOuint NextPowerOf2(MOuint p_seed)
Definition: moTexture.cpp:758
MOboolean ValidTexture(MOuint p_i)
Definition: moTexture.cpp:2056
MOint frameprevious
Definition: moTexture.h:936
moBitmap * LoadFromMemory()
Definition: moTexture.cpp:1383
clase base para el manejo de una textura
Definition: moTexture.h:78
moText GetCompletePath()
Get inmediate folder name: return "PP" for "PP/myFileName.txt".
Definition: moFile.cpp:538
Administrador de recursos.
virtual void SetPlayMode(moPlayMode playmode)
Definition: moTexture.cpp:1931
MOuint m_fbo_attach_point
Definition: moTexture.h:397
MOfloat m_InterpolationPosition
Definition: moTexture.h:739
void EmptyBucket()
Libera el espacio de memoria.
Definition: moBuckets.cpp:66
const MOlong PI
Definition: moMath.cpp:44
MOuint m_InterpolationTime
Definition: moTexture.h:733
virtual MOuint GetActualFrame()
Definition: moTexture.cpp:1925
bool CalculateLuminanceAndConstrast(int x0=0, int y0=0, int x1=0, int y1=0)
Definition: moTexture.cpp:468
virtual void Stop()=0
Detener la reproducción del video.
GLint wrap_s
Definition: moTypes.h:549
MOubyte * GetData()
Definition: moFile.cpp:463
void SetFrame(MOuint p_i, moTexture *p_texture)
Definition: moTexture.cpp:2037
moText m_name
Definition: moTexture.h:402
virtual MOboolean IsInterpolating()
Definition: moTexture.cpp:1731
MOuint m_ActualFrame
Definition: moTexture.h:711
TEXTURA BASE.
Definition: moTexture.h:54
Clase que implementa un administrador de shaders.
MOuint m_width
Definition: moTexture.h:405
virtual void Play()=0
Reproducir el video.
static moDebug * MODebug2
Clase de impresión de errores para depuración.
Definition: moAbstract.h:225
virtual void SetContrast(float contrast)=0
virtual bool BuildLiveQTVideoGraph(moText filename, moBucketsPool *pBucketsPool)=0
moTexture & operator=(const moTexture &p_src_tex)
Definition: moTexture.cpp:640
moDataManager * GetDataMan()
MOboolean m_bBitmapInMemory
Definition: moTexture.h:528
moText Text()
Definition: moValue.cpp:539
MOboolean Load(moText p_FileName, MOboolean bWaitForDownload=false)
moTextureFilter * m_pCopyEnd
Definition: moTexture.h:719
moGLManager * m_gl
Definition: moTexture.h:393
MOuint GetWidth() const
Definition: moTexture.h:256
MOboolean BuildFromFile(moText p_filename)
Definition: moTexture.cpp:142
MOboolean m_bIsPlaying
Definition: moTexture.h:702
MOuint m_FrameNext
Definition: moTexture.h:708
moTexParam GetTexParam() const
Definition: moTexture.h:307
virtual void SetHue(float hue)=0
moTextureType m_type
Definition: moTexture.h:399
Espacio en memoria para compartir datos entre objetos.
Definition: moBuckets.h:53
void Push(moText p_text)
Apila el mensaje dentro de la pila de mensajes.
Definition: moAbstract.h:115
virtual void SetHue(float hue)
Definition: moTexture.cpp:2241
moValue & GetValue(MOint i=-1)
Definition: moParam.cpp:1204
MOuint LoadFilters(moParam *p_param)
MOboolean Load(moParam *p_param)
Definition: moTexture.cpp:375
bool IsEOS()
Definition: moTexture.cpp:2276
MOboolean Load(moParam *p_param)
Definition: moTexture.cpp:1980
MOint Luminance
average luminance
Definition: moTexture.h:531
moFile * m_pFile
Definition: moTexture.h:390
virtual void Play()
Definition: moTexture.cpp:2112
virtual void SetFramesPerSecond(MOfloat p_fps)
Definition: moTexture.h:636
#define RenderMan()
MOint m_components
Definition: moTexture.h:408
bool IsPowerOfTwo(int iValue)
Definition: moMath.h:297
moBitmapFormat fif
Definition: moTexture.h:521
MOuint GetGLId() const
Definition: moTexture.h:224
MOboolean SupportedFile(moText p_filename)
Definition: moTexture.cpp:2285
virtual void SetBrightness(float brightness)
Definition: moTexture.cpp:2225
moTextureFilter * m_pInterpolator
Definition: moTexture.h:720
virtual bool IsPaused()
Definition: moTexture.cpp:2213
GLenum target
Definition: moTypes.h:545
GLint min_filter
Definition: moTypes.h:547
void SetParam()
Definition: moTexture.cpp:662
moFileStatus GetStatus()
Definition: moFile.cpp:453
moText GetDataPath()
virtual bool IsPlaying()
Definition: moTexture.cpp:2202
virtual bool IsEOS()=0
#define MOuint
Definition: moTypes.h:387
void CopyFromTex(moTexture *p_src_tex, MOboolean p_copy_glid, MOboolean p_copy_moid, MOboolean p_copy_type, MOboolean p_copy_name)
Definition: moTexture.cpp:617
LIBMOLDEO_API moText0 IntToStr(int a)
Definition: moText.cpp:1070
MOboolean m_bInterpolation
Definition: moTexture.h:714
moTextureArray m_textures_array
Definition: moTexture.h:848
MOubyte * GetBuffer()
Devuelve el puntero al buffer de datos.
Definition: moBuckets.cpp:58
MOboolean Reload(bool force_kill=true)
Definition: moTexture.cpp:2379
moBucket * RetreiveBucket()
Definition: moBuckets.cpp:207
virtual bool InitGraph()=0
Inicialización del grafo.
void EnableVideo(int)
Definition: moTexture.cpp:2388
virtual void Play()
Definition: moTexture.cpp:1620
MOuint m_FrameRate
Definition: moVideoGraph.h:209
MOint reference_counter
Definition: moTexture.h:516
virtual MOboolean Finish()
Definition: moTexture.cpp:1600
MOuint m_height
Definition: moTexture.h:406
virtual MOboolean BuildFromBitmap(moBitmap *p_bitmap, moText p_bufferformat="JPG")
Guarda el bitmap con el formato elegido en memoria, luego construye la textura opengl.
Definition: moTexture.cpp:1476
virtual void SetBalance(float balance)=0
Fija el balance entre canal izquierdo y derecho en caso de haberlos.
MOuint GetSubValueCount()
Definition: moValue.h:545
MOboolean RectTexture(GLenum p_target) const
virtual MObyte * GetFrameBuffer(MOlong *size)=0
Puntero al frame buffer.
MOint m_moid
Definition: moTexture.h:400
moBucketsPool m_BucketsPool
Definition: moTexture.h:939
una textura asociada a una animación de cuadros
Definition: moTexture.h:553
static void FreeImageErrorHandler(FREE_IMAGE_FORMAT fif, const char *message)
Definition: moTexture.cpp:847
virtual bool IsPlaying()
Definition: moTexture.cpp:1630
MOboolean m_bInitialized
Valor de inicialización.
Definition: moAbstract.h:223
virtual void Seek(MOuint frame, float rate=1.0)=0
Busca y posiciona.
MOdouble ang
Definition: moTempo.h:81
moPlayMode m_PlayMode
Definition: moTexture.h:701
bool ResetBufferData(bool force_creation=false, int bytes_per_pixel=0)
Definition: moTexture.cpp:721
virtual void Stop()
Definition: moTexture.cpp:1625
void Message(moText p_text)
Anuncia un mensaje al usuario además de guardarlo en el log de texto.
Definition: moAbstract.cpp:114
MOuint m_bytespp
Definition: moTexture.h:407
MOfloat m_max_coord_s
Definition: moTexture.h:409
MOlong m_SizeInMemory
Definition: moTexture.h:525
MOint Contrast
average contrast
Definition: moTexture.h:534
#define MOubyte
Definition: moTypes.h:399
virtual void Pause()=0
Pausa la reproducción del video.
moDataManager * m_pDataMan
Definition: moTexture.h:391
virtual MOboolean IsInterpolationActive()
Definition: moTexture.cpp:1736
MOboolean SetBuffer(const GLvoid *p_buffer, GLenum p_format=GL_RGBA, GLenum p_type=GL_UNSIGNED_BYTE)
Definition: moTexture.cpp:388
MOulong moGetTicks()
Devuelve en milisegundos el valor del reloj de Moldeo.
Definition: moTimer.cpp:138
moTexParam m_param
Definition: moTexture.h:404