~haggai-eran/nux/rtl-rebased

« back to all changes in this revision

Viewing changes to NuxImage/ImageSurface.cpp

  • Committer: Jay Taoko
  • Date: 2011-10-21 22:06:35 UTC
  • mto: This revision was merged to the branch mainline in revision 509.
  • Revision ID: jay.taoko@canonical.com-20111021220635-1tdvncs47hdlfbz1
* Removed custom Nux types: t_u32, t_s32, t_bool, ...

Show diffs side-by-side

added added

removed removed

Lines of Context:
174
174
    delete [] RawData_;
175
175
  }
176
176
 
177
 
  ImageSurface::ImageSurface(BitmapFormat format, t_u32 width, t_u32 height)
 
177
  ImageSurface::ImageSurface(BitmapFormat format, unsigned int width, unsigned int height)
178
178
    :   width_(0)
179
179
    ,   height_(0)
180
180
    ,   format_(BITFMT_UNKNOWN)
218
218
    return *this;
219
219
  }
220
220
 
221
 
  t_s32 ImageSurface::GetPitch() const
 
221
  int ImageSurface::GetPitch() const
222
222
  {
223
223
    return m_Pitch;
224
224
  }
225
225
 
226
 
  t_s32 ImageSurface::GetBlockHeight() const
 
226
  int ImageSurface::GetBlockHeight() const
227
227
  {
228
 
    t_u32 block = GPixelFormats[format_].BlockSizeY;
229
 
    t_u32 HeightInBlocks = Align(GetHeight(), block) / block;
 
228
    unsigned int block = GPixelFormats[format_].BlockSizeY;
 
229
    unsigned int HeightInBlocks = Align(GetHeight(), block) / block;
230
230
    return HeightInBlocks;
231
231
  }
232
232
 
235
235
    return format_;
236
236
  }
237
237
 
238
 
  t_s32 ImageSurface::GetAlignment() const
 
238
  int ImageSurface::GetAlignment() const
239
239
  {
240
240
    return Alignment_;
241
241
  }
242
242
 
243
 
  void ImageSurface::Allocate(BitmapFormat format, t_s32 width, t_s32 height)
 
243
  void ImageSurface::Allocate(BitmapFormat format, int width, int height)
244
244
  {
245
245
    nuxAssert(format < BITFMT_END_GFX_FORMATS);
246
246
    nuxAssert(width >= 0);
292
292
      // For DXT, width and height are rounded up to a multiple of 4 in order
293
293
      // to create 4x4 blocks of pixels; And in this context, byte alignment
294
294
      // is 1 ie. data is densely packed.
295
 
      t_u32 block = GPixelFormats[format].BlockSizeX;
296
 
      t_u32 shift = Log2(GPixelFormats[format].BlockSizeX);
 
295
      unsigned int block = GPixelFormats[format].BlockSizeX;
 
296
      unsigned int shift = Log2(GPixelFormats[format].BlockSizeX);
297
297
      m_Pitch = Align((bpe_ * ((width_ + (block - 1)) >> shift)), Alignment_);
298
298
 
299
299
      block = GPixelFormats[format].BlockSizeY;
302
302
    }
303
303
    else
304
304
    {
305
 
      t_u32 block = GPixelFormats[format].BlockSizeX;
306
 
      t_u32 shift = Log2(GPixelFormats[format].BlockSizeX);
 
305
      unsigned int block = GPixelFormats[format].BlockSizeX;
 
306
      unsigned int shift = Log2(GPixelFormats[format].BlockSizeX);
307
307
      m_Pitch = Align((bpe_ * ((width_ + (block - 1)) >> shift)),  Alignment_);
308
308
 
309
309
      block = GPixelFormats[format].BlockSizeY;
319
319
// Avoiding 16 Common OpenGL Pitfalls
320
320
// http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/
321
321
// 7. Watch Your Pixel Store Alignment
322
 
  t_s32 ImageSurface::GetLevelPitch(BitmapFormat format, t_s32 width,
323
 
                                     t_s32 height, t_s32 miplevel)
324
 
  {
325
 
    t_s32 levelwidth = ImageSurface::GetLevelDim(format, width, miplevel);
326
 
 
327
 
    t_s32 bpe = GPixelFormats[format].BlockBytes;
328
 
    t_s32 memalignment = GPixelFormats[format].RowMemoryAlignment;
329
 
    t_s32 block = GPixelFormats[format].BlockSizeX;
330
 
    t_s32 shift = Log2(GPixelFormats[format].BlockSizeX);
331
 
    t_s32 pitch = Align((bpe * ((levelwidth + (block - 1)) >> shift)), memalignment);
332
 
 
333
 
    return pitch;
334
 
  }
335
 
 
336
 
  t_s32 ImageSurface::GetLevelPitchNoMemAlignment(BitmapFormat format, t_s32 width, t_s32 height, t_s32 miplevel)
337
 
  {
338
 
    t_s32 levelwidth = ImageSurface::GetLevelDim(format, width, miplevel);
339
 
 
340
 
    t_s32 bpe = GPixelFormats[format].BlockBytes;
341
 
    t_s32 block = GPixelFormats[format].BlockSizeX;
342
 
    t_s32 shift = Log2(GPixelFormats[format].BlockSizeX);
343
 
    t_s32 pitch = Align((bpe * ((levelwidth + (block - 1)) >> shift)), 1);
344
 
 
345
 
    return pitch;
346
 
  }
347
 
 
348
 
  t_s32 ImageSurface::GetLevelSize(BitmapFormat format, t_s32 width, t_s32 height, t_s32 miplevel)
349
 
  {
350
 
    t_s32 pitch = ImageSurface::GetLevelPitch(format, width, height, miplevel);
351
 
    t_s32 levelheight = ImageSurface::GetLevelDim(format, height, miplevel);
352
 
 
353
 
    t_s32 block = GPixelFormats[format].BlockSizeY;
354
 
    t_s32 HeightInBlocks = Align(levelheight, block) / block;
355
 
 
356
 
    t_s32 size = pitch * HeightInBlocks;
 
322
  int ImageSurface::GetLevelPitch(BitmapFormat format, int width,
 
323
                                     int height, int miplevel)
 
324
  {
 
325
    int levelwidth = ImageSurface::GetLevelDim(format, width, miplevel);
 
326
 
 
327
    int bpe = GPixelFormats[format].BlockBytes;
 
328
    int memalignment = GPixelFormats[format].RowMemoryAlignment;
 
329
    int block = GPixelFormats[format].BlockSizeX;
 
330
    int shift = Log2(GPixelFormats[format].BlockSizeX);
 
331
    int pitch = Align((bpe * ((levelwidth + (block - 1)) >> shift)), memalignment);
 
332
 
 
333
    return pitch;
 
334
  }
 
335
 
 
336
  int ImageSurface::GetLevelPitchNoMemAlignment(BitmapFormat format, int width, int height, int miplevel)
 
337
  {
 
338
    int levelwidth = ImageSurface::GetLevelDim(format, width, miplevel);
 
339
 
 
340
    int bpe = GPixelFormats[format].BlockBytes;
 
341
    int block = GPixelFormats[format].BlockSizeX;
 
342
    int shift = Log2(GPixelFormats[format].BlockSizeX);
 
343
    int pitch = Align((bpe * ((levelwidth + (block - 1)) >> shift)), 1);
 
344
 
 
345
    return pitch;
 
346
  }
 
347
 
 
348
  int ImageSurface::GetLevelSize(BitmapFormat format, int width, int height, int miplevel)
 
349
  {
 
350
    int pitch = ImageSurface::GetLevelPitch(format, width, height, miplevel);
 
351
    int levelheight = ImageSurface::GetLevelDim(format, height, miplevel);
 
352
 
 
353
    int block = GPixelFormats[format].BlockSizeY;
 
354
    int HeightInBlocks = Align(levelheight, block) / block;
 
355
 
 
356
    int size = pitch * HeightInBlocks;
357
357
    return size;
358
358
  }
359
359
 
360
 
  t_s32 ImageSurface::GetLevelSize(BitmapFormat format, t_s32 width, t_s32 height, t_s32 depth, t_s32 miplevel)
 
360
  int ImageSurface::GetLevelSize(BitmapFormat format, int width, int height, int depth, int miplevel)
361
361
  {
362
 
    t_s32 pitch = ImageSurface::GetLevelPitch(format, width, height, miplevel);
363
 
    t_s32 levelheight = ImageSurface::GetLevelDim(format, height, miplevel);
364
 
    t_s32 leveldepth = ImageSurface::GetLevelDim(format, depth, miplevel);
365
 
 
366
 
    t_s32 block = GPixelFormats[format].BlockSizeY;
367
 
    t_s32 HeightInBlocks = Align(levelheight, block) / block;
368
 
 
369
 
    t_s32 size = pitch * HeightInBlocks;
 
362
    int pitch = ImageSurface::GetLevelPitch(format, width, height, miplevel);
 
363
    int levelheight = ImageSurface::GetLevelDim(format, height, miplevel);
 
364
    int leveldepth = ImageSurface::GetLevelDim(format, depth, miplevel);
 
365
 
 
366
    int block = GPixelFormats[format].BlockSizeY;
 
367
    int HeightInBlocks = Align(levelheight, block) / block;
 
368
 
 
369
    int size = pitch * HeightInBlocks;
370
370
    return leveldepth * size;
371
371
  }
372
372
 
373
 
  t_s32 ImageSurface::GetLevelWidth(BitmapFormat format, t_s32 width, t_s32 miplevel)
374
 
  {
375
 
    // return 1 if the mip level does not exist.
376
 
    return Max<t_s32> (1, width >> miplevel);
377
 
  }
378
 
 
379
 
  t_s32 ImageSurface::GetLevelHeight(BitmapFormat format, t_s32 height, t_s32 miplevel)
380
 
  {
381
 
    // return 1 if the mip level does not exist.
382
 
    return Max<t_s32> (1, height >> miplevel);
383
 
  }
384
 
 
385
 
  t_s32 ImageSurface::GetLevelDim(BitmapFormat format, t_s32 length, t_s32 miplevel)
386
 
  {
387
 
    // return 1 if the mip level does not exist.
388
 
    return Max<t_s32> (1, length >> miplevel);
389
 
  }
390
 
 
391
 
  t_s32 ImageSurface::GetNumMipLevel(BitmapFormat format, t_s32 width, t_s32 height)
392
 
  {
393
 
    t_s32 NumTotalMipLevel    = 1 + floorf(Log2(Max(width, height)));
 
373
  int ImageSurface::GetLevelWidth(BitmapFormat format, int width, int miplevel)
 
374
  {
 
375
    // return 1 if the mip level does not exist.
 
376
    return Max<int> (1, width >> miplevel);
 
377
  }
 
378
 
 
379
  int ImageSurface::GetLevelHeight(BitmapFormat format, int height, int miplevel)
 
380
  {
 
381
    // return 1 if the mip level does not exist.
 
382
    return Max<int> (1, height >> miplevel);
 
383
  }
 
384
 
 
385
  int ImageSurface::GetLevelDim(BitmapFormat format, int length, int miplevel)
 
386
  {
 
387
    // return 1 if the mip level does not exist.
 
388
    return Max<int> (1, length >> miplevel);
 
389
  }
 
390
 
 
391
  int ImageSurface::GetNumMipLevel(BitmapFormat format, int width, int height)
 
392
  {
 
393
    int NumTotalMipLevel    = 1 + floorf(Log2(Max(width, height)));
394
394
    return NumTotalMipLevel;
395
395
  }
396
396
 
397
 
  t_s32 ImageSurface::GetMemAlignment(BitmapFormat format)
 
397
  int ImageSurface::GetMemAlignment(BitmapFormat format)
398
398
  {
399
399
    return GPixelFormats[format].RowMemoryAlignment;
400
400
  }
401
401
 
402
 
  t_s32 ImageSurface::GetLevelBlockWidth(BitmapFormat format, t_s32 width, t_s32 miplevel)
 
402
  int ImageSurface::GetLevelBlockWidth(BitmapFormat format, int width, int miplevel)
403
403
  {
404
 
    t_s32 block = GPixelFormats[format].BlockSizeX;
405
 
    t_s32 WidthInBlocks = Align(GetLevelDim(format, width, miplevel), block) / block;
 
404
    int block = GPixelFormats[format].BlockSizeX;
 
405
    int WidthInBlocks = Align(GetLevelDim(format, width, miplevel), block) / block;
406
406
    return WidthInBlocks;
407
407
  }
408
408
 
409
 
  t_s32 ImageSurface::GetLevelBlockHeight(BitmapFormat format, t_s32 height, t_s32 miplevel)
 
409
  int ImageSurface::GetLevelBlockHeight(BitmapFormat format, int height, int miplevel)
410
410
  {
411
 
    t_s32 block = GPixelFormats[format].BlockSizeY;
412
 
    t_s32 HeightInBlocks = Align(GetLevelDim(format, height, miplevel), block) / block;
 
411
    int block = GPixelFormats[format].BlockSizeY;
 
412
    int HeightInBlocks = Align(GetLevelDim(format, height, miplevel), block) / block;
413
413
    return HeightInBlocks;
414
414
  }
415
415
 
421
421
    return false;
422
422
  }
423
423
 
424
 
  void ImageSurface::Write32b(t_s32 i, t_s32 j, t_u32 value)
 
424
  void ImageSurface::Write32b(int i, int j, unsigned int value)
425
425
  {
426
426
    nuxAssert(i < width_);
427
427
    nuxAssert(j < height_);
436
436
    RawData_[j *m_Pitch + i *bpe_ + 3] = (t_u8) ((value & 0xff000000) >> 24);
437
437
  }
438
438
 
439
 
  void ImageSurface::Write24b(t_s32 i, t_s32 j, t_u32 value)
 
439
  void ImageSurface::Write24b(int i, int j, unsigned int value)
440
440
  {
441
441
    nuxAssert(i < width_);
442
442
    nuxAssert(j < height_);
450
450
    RawData_[j *m_Pitch + i *bpe_ + 2] = (t_u8) ((value & 0xff0000) >> 16);
451
451
  }
452
452
 
453
 
  void ImageSurface::Write16b(t_s32 i, t_s32 j, t_u16 value)
 
453
  void ImageSurface::Write16b(int i, int j, unsigned short value)
454
454
  {
455
455
    nuxAssert(i < width_);
456
456
    nuxAssert(j < height_);
463
463
    RawData_[j *m_Pitch + i *bpe_ + 1] = (t_u8) ((value & 0xff00) >> 8);
464
464
  }
465
465
 
466
 
  void ImageSurface::Write8b(t_s32 i, t_s32 j, t_u8 value)
 
466
  void ImageSurface::Write8b(int i, int j, t_u8 value)
467
467
  {
468
468
    nuxAssert(i < width_);
469
469
    nuxAssert(j < height_);
475
475
    RawData_[j *m_Pitch + i *bpe_ + 0] = (t_u8) (value & 0xff);
476
476
  }
477
477
 
478
 
  void ImageSurface::Write(t_s32 i, t_s32 j, t_u8 r, t_u8 g, t_u8 b, t_u8 a)
 
478
  void ImageSurface::Write(int i, int j, t_u8 r, t_u8 g, t_u8 b, t_u8 a)
479
479
  {
480
480
    nuxAssert(i < width_);
481
481
    nuxAssert(j < height_);
499
499
    RawData_[j *m_Pitch + i *bpe_ + 3] = a;
500
500
  }
501
501
 
502
 
  t_u32 ImageSurface::Read(t_s32 i, t_s32 j)
 
502
  unsigned int ImageSurface::Read(int i, int j)
503
503
  {
504
504
    nuxAssert(i < width_);
505
505
    nuxAssert(j < height_);
510
510
 
511
511
    if (bpe_ == 4)
512
512
    {
513
 
      return  ((t_u32) RawData_[j * m_Pitch + i * bpe_ + 3] << 24)   |
514
 
              ((t_u32) RawData_[j * m_Pitch + i * bpe_ + 2] << 16)   |
515
 
              ((t_u32) RawData_[j * m_Pitch + i * bpe_ + 1] << 8)    |
516
 
              ((t_u32) RawData_[j * m_Pitch + i * bpe_ + 0] << 0);
 
513
      return  ((unsigned int) RawData_[j * m_Pitch + i * bpe_ + 3] << 24)   |
 
514
              ((unsigned int) RawData_[j * m_Pitch + i * bpe_ + 2] << 16)   |
 
515
              ((unsigned int) RawData_[j * m_Pitch + i * bpe_ + 1] << 8)    |
 
516
              ((unsigned int) RawData_[j * m_Pitch + i * bpe_ + 0] << 0);
517
517
    }
518
518
 
519
519
    if (bpe_ == 3)
520
520
    {
521
 
      return  ((t_u32) RawData_[j * m_Pitch + i * bpe_ + 2] << 16)   |
522
 
              ((t_u32) RawData_[j * m_Pitch + i * bpe_ + 1] << 8)    |
523
 
              ((t_u32) RawData_[j * m_Pitch + i * bpe_ + 0] << 0);
 
521
      return  ((unsigned int) RawData_[j * m_Pitch + i * bpe_ + 2] << 16)   |
 
522
              ((unsigned int) RawData_[j * m_Pitch + i * bpe_ + 1] << 8)    |
 
523
              ((unsigned int) RawData_[j * m_Pitch + i * bpe_ + 0] << 0);
524
524
    }
525
525
 
526
526
    if (bpe_ == 2)
527
527
    {
528
 
      return  ((t_u32) RawData_[j * m_Pitch + i * bpe_ + 1] << 8)    |
529
 
              ((t_u32) RawData_[j * m_Pitch + i * bpe_ + 0] << 0);
 
528
      return  ((unsigned int) RawData_[j * m_Pitch + i * bpe_ + 1] << 8)    |
 
529
              ((unsigned int) RawData_[j * m_Pitch + i * bpe_ + 0] << 0);
530
530
    }
531
531
 
532
532
    if (bpe_ == 1)
533
533
    {
534
 
      return  (t_u32) RawData_[j * m_Pitch + i * bpe_ + 0];
 
534
      return  (unsigned int) RawData_[j * m_Pitch + i * bpe_ + 0];
535
535
    }
536
536
 
537
537
    return 0x0000000;
554
554
    if ((format_ == BITFMT_DXT1) || (format_ == BITFMT_DXT2)  || (format_ == BITFMT_DXT3)  || (format_ == BITFMT_DXT4) || (format_ == BITFMT_DXT5))
555
555
      return;
556
556
 
557
 
    t_s32 i, j, k;
 
557
    int i, j, k;
558
558
    t_u8 *flip_data;
559
559
 
560
560
    if (RawData_ == 0)
583
583
  void ImageSurface::FlipVertical()
584
584
  {
585
585
 
586
 
    t_s32 i, j, k;
 
586
    int i, j, k;
587
587
    t_u8 *flip_data;
588
588
 
589
589
    if (RawData_ == 0)
619
619
 
620
620
  void ImageSurface::FlipDXTVertical()
621
621
  {
622
 
    //void(CDDSImage::*flipblocks)(DXTColBlock*, t_u32);
623
 
    t_s32 xblocks = (width_ + 3) / 4;
624
 
    t_s32 yblocks = (height_ + 3) / 4;
625
 
    t_s32 blocksize;
626
 
    t_s32 linesize;
 
622
    //void(CDDSImage::*flipblocks)(DXTColBlock*, unsigned int);
 
623
    int xblocks = (width_ + 3) / 4;
 
624
    int yblocks = (height_ + 3) / 4;
 
625
    int blocksize;
 
626
    int linesize;
627
627
 
628
628
    switch(format_)
629
629
    {
656
656
    DXTColBlock *top;
657
657
    DXTColBlock *bottom;
658
658
 
659
 
    for (t_s32 j = 0; j < (yblocks >> 1); j++)
 
659
    for (int j = 0; j < (yblocks >> 1); j++)
660
660
    {
661
661
      top = (DXTColBlock *) ((unsigned char *) RawData_ + j * linesize);
662
662
      bottom = (DXTColBlock *) ((unsigned char *) RawData_ + (((yblocks - j) - 1) * linesize));
692
692
    }
693
693
  }
694
694
 
695
 
  void ImageSurface::SwapBlocks(void *byte1, void *byte2, t_s32 size)
 
695
  void ImageSurface::SwapBlocks(void *byte1, void *byte2, int size)
696
696
  {
697
697
    unsigned char *tmp = new unsigned char[size];
698
698
 
703
703
    delete [] tmp;
704
704
  }
705
705
 
706
 
  void ImageSurface::FlipBlocksDXT1(DXTColBlock *line, t_s32 numBlocks)
 
706
  void ImageSurface::FlipBlocksDXT1(DXTColBlock *line, int numBlocks)
707
707
  {
708
708
    DXTColBlock *curblock = line;
709
709
 
710
 
    for (t_s32 i = 0; i < numBlocks; i++)
 
710
    for (int i = 0; i < numBlocks; i++)
711
711
    {
712
712
      SwapBlocks(&curblock->row[0], &curblock->row[3], sizeof(unsigned char));
713
713
      SwapBlocks(&curblock->row[1], &curblock->row[2], sizeof(unsigned char));
716
716
    }
717
717
  }
718
718
 
719
 
  void ImageSurface::FlipBlocksDXT3(DXTColBlock *line, t_s32 numBlocks)
 
719
  void ImageSurface::FlipBlocksDXT3(DXTColBlock *line, int numBlocks)
720
720
  {
721
721
    DXTColBlock *curblock = line;
722
722
    DXT3AlphaBlock *alphablock;
723
723
 
724
 
    for (t_s32 i = 0; i < numBlocks; i++)
 
724
    for (int i = 0; i < numBlocks; i++)
725
725
    {
726
726
      alphablock = (DXT3AlphaBlock *) curblock;
727
727
 
737
737
    }
738
738
  }
739
739
 
740
 
  void ImageSurface::FlipBlocksDXT5(DXTColBlock *line, t_s32 numBlocks)
 
740
  void ImageSurface::FlipBlocksDXT5(DXTColBlock *line, int numBlocks)
741
741
  {
742
742
    DXTColBlock *curblock = line;
743
743
    DXT5AlphaBlock *alphablock;
744
744
 
745
 
    for (t_s32 i = 0; i < numBlocks; i++)
 
745
    for (int i = 0; i < numBlocks; i++)
746
746
    {
747
747
      alphablock = (DXT5AlphaBlock *) curblock;
748
748
 
841
841
    return RawData_;
842
842
  }
843
843
 
844
 
  t_s32 ImageSurface::GetSize() const
 
844
  int ImageSurface::GetSize() const
845
845
  {
846
846
    if ((format_ == BITFMT_DXT1) ||
847
847
         (format_ == BITFMT_DXT2) ||
862
862
    if (width_ == 0 || height_ == 0)
863
863
      return Color(0.f, 0.f, 0.f, 0.f);
864
864
 
865
 
    t_float r, g, b, a;
 
865
    float r, g, b, a;
866
866
    r = g = b = a = 0;
867
867
 
868
868
    if (bpe_ == 8)
871
871
      {
872
872
        for (int i = 0; i < width_; i++)
873
873
        {
874
 
          t_u32 v = Read(i, j);
 
874
          unsigned int v = Read(i, j);
875
875
          r += (v & 0x000000FF);
876
876
          g += (v & 0x0000FF00) >> 1;
877
877
          b += (v & 0x00FF0000) >> 2;
880
880
      }
881
881
    }
882
882
 
883
 
    t_u32 num_pixels = width_ * height_;
 
883
    unsigned int num_pixels = width_ * height_;
884
884
    return Color(r / num_pixels, g / num_pixels, b / num_pixels, a / num_pixels);
885
885
  }
886
886
 
887
887
 
888
888
  ///////////////////////////////////////////////////////////////////
889
 
  NTextureData::NTextureData(BitmapFormat f, t_s32 width, t_s32 height, t_s32 NumMipmap)
 
889
  NTextureData::NTextureData(BitmapFormat f, int width, int height, int NumMipmap)
890
890
    :   m_NumMipmap(0)
891
891
  {
892
892
    Allocate(f, width, height, NumMipmap);
899
899
 
900
900
  void NTextureData::ClearData()
901
901
  {
902
 
    for (t_s32 i = 0; i < (t_s32) m_MipSurfaceArray.size(); i++)
 
902
    for (int i = 0; i < (int) m_MipSurfaceArray.size(); i++)
903
903
      delete m_MipSurfaceArray[i];
904
904
 
905
905
    m_MipSurfaceArray.clear();
908
908
  //! Copy constructor
909
909
  NTextureData::NTextureData(const NTextureData &object)
910
910
  {
911
 
    for (t_s32 i = 0; i < object.GetNumMipmap(); i++)
 
911
    for (int i = 0; i < object.GetNumMipmap(); i++)
912
912
      m_MipSurfaceArray.push_back(new ImageSurface(object.GetSurface(i)));
913
913
  }
914
914
 
919
919
    m_NumMipmap = copy.m_NumMipmap;
920
920
    m_TotalMemorySize = copy.m_TotalMemorySize;
921
921
 
922
 
    for (t_s32 i = 0; i < copy.GetNumMipmap(); i++)
 
922
    for (int i = 0; i < copy.GetNumMipmap(); i++)
923
923
      m_MipSurfaceArray.push_back(new ImageSurface(copy.GetSurface(i)));
924
924
 
925
925
    return *this;
926
926
  }
927
927
 
928
 
  void NTextureData::Allocate(BitmapFormat format, t_s32 width, t_s32 height, t_s32 NumMipmapRequested)
 
928
  void NTextureData::Allocate(BitmapFormat format, int width, int height, int NumMipmapRequested)
929
929
  {
930
930
    nuxAssertMsg(width >= 0, "[NTextureData::Allocate] Error: Negative texture width.");
931
931
    nuxAssertMsg(height >= 0, "[NTextureData::Allocate] Error: Negative texture height.");
932
932
    nuxAssert(NumMipmapRequested >= 0);
933
933
 
934
 
    t_s32 NumTotalMipLevel    = 1 + (t_s32) Floor(Log2(Max(width, height)));
 
934
    int NumTotalMipLevel    = 1 + (int) Floor(Log2(Max(width, height)));
935
935
    m_NumMipmap = NumMipmapRequested;
936
936
 
937
937
    if (NumMipmapRequested == 0)
943
943
    m_TotalMemorySize = 0;
944
944
    ClearData();
945
945
 
946
 
    for (t_s32 i = 0; i < m_NumMipmap; i++)
 
946
    for (int i = 0; i < m_NumMipmap; i++)
947
947
    {
948
 
      t_s32 w = width >> i;
949
 
      t_s32 h = height >> i;
 
948
      int w = width >> i;
 
949
      int h = height >> i;
950
950
      m_MipSurfaceArray.push_back(new ImageSurface(format, w, h));
951
951
      m_TotalMemorySize += m_MipSurfaceArray[i]->GetSize();
952
952
    }
953
953
  }
954
954
 
955
 
  void NTextureData::AllocateCheckBoardTexture(t_s32 width, t_s32 height, t_s32 NumMipmap, Color color0, Color color1, t_s32 TileWidth, t_s32 TileHeight)
 
955
  void NTextureData::AllocateCheckBoardTexture(int width, int height, int NumMipmap, Color color0, Color color1, int TileWidth, int TileHeight)
956
956
  {
957
957
    Allocate(BITFMT_R8G8B8A8, width, height, NumMipmap);
958
958
 
959
 
    for (t_s32 i = 0; i < m_NumMipmap; i++)
 
959
    for (int i = 0; i < m_NumMipmap; i++)
960
960
    {
961
 
      t_s32 w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), i);
962
 
      t_s32 h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), i);
 
961
      int w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), i);
 
962
      int h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), i);
963
963
      MakeCheckBoardImage(*m_MipSurfaceArray[i], w, h, color0, color1, TileWidth, TileHeight);
964
964
    }
965
965
  }
966
966
 
967
 
  void NTextureData::AllocateColorTexture(t_s32 width, t_s32 height, t_s32 NumMipmap, Color color0)
 
967
  void NTextureData::AllocateColorTexture(int width, int height, int NumMipmap, Color color0)
968
968
  {
969
969
    Allocate(BITFMT_R8G8B8A8, width, height, NumMipmap);
970
970
 
971
 
    for (t_s32 i = 0; i < m_NumMipmap; i++)
 
971
    for (int i = 0; i < m_NumMipmap; i++)
972
972
    {
973
 
      t_s32 w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), i);
974
 
      t_s32 h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), i);
 
973
      int w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), i);
 
974
      int h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), i);
975
975
      MakeCheckBoardImage(*m_MipSurfaceArray[i], w, h, color0, color0);
976
976
    }
977
977
  }
978
978
 
979
 
  t_s32 NTextureData::GetNumMipmap() const
 
979
  int NTextureData::GetNumMipmap() const
980
980
  {
981
981
    return m_MipSurfaceArray.size();
982
982
  }
983
983
 
984
 
  bool NTextureData::SetSurface(t_s32 MipLevel, const ImageSurface &targetsurface)
 
984
  bool NTextureData::SetSurface(int MipLevel, const ImageSurface &targetsurface)
985
985
  {
986
986
    nuxAssert(MipLevel >= 0);
987
987
    nuxAssert(MipLevel < m_NumMipmap);
1002
1002
  }
1003
1003
 
1004
1004
///////////////////////////////////////////////////////////////////
1005
 
  NCubemapData::NCubemapData(BitmapFormat format, t_s32 width, t_s32 height, t_s32 NumMipmap)
 
1005
  NCubemapData::NCubemapData(BitmapFormat format, int width, int height, int NumMipmap)
1006
1006
    :   m_NumMipmap(0)
1007
1007
  {
1008
1008
    Allocate(format, width, height, NumMipmap);
1015
1015
 
1016
1016
  void NCubemapData::ClearData()
1017
1017
  {
1018
 
    t_s32 n = (t_s32) m_MipSurfaceArray[0].size();
 
1018
    int n = (int) m_MipSurfaceArray[0].size();
1019
1019
 
1020
 
    for (t_s32 i = 0; i < n; i++)
 
1020
    for (int i = 0; i < n; i++)
1021
1021
    {
1022
1022
      delete m_MipSurfaceArray[0][i];
1023
1023
      delete m_MipSurfaceArray[1][i];
1038
1038
//! Copy constructor
1039
1039
  NCubemapData::NCubemapData(const NCubemapData &object)
1040
1040
  {
1041
 
    for (t_s32 face = 0; face < 6; face++)
1042
 
      for (t_s32 i = 0; i < object.GetNumMipmap(); i++)
 
1041
    for (int face = 0; face < 6; face++)
 
1042
      for (int i = 0; i < object.GetNumMipmap(); i++)
1043
1043
        m_MipSurfaceArray[face].push_back(new ImageSurface(object.GetSurface(face, i)));
1044
1044
  }
1045
1045
 
1050
1050
    m_NumMipmap = copy.m_NumMipmap;
1051
1051
    m_TotalMemorySize = copy.m_TotalMemorySize;
1052
1052
 
1053
 
    for (t_s32 face = 0; face < 6; face++)
1054
 
      for (t_s32 i = 0; i < copy.GetNumMipmap(); i++)
 
1053
    for (int face = 0; face < 6; face++)
 
1054
      for (int i = 0; i < copy.GetNumMipmap(); i++)
1055
1055
        m_MipSurfaceArray[face].push_back(new ImageSurface(copy.GetSurface(face, i)));
1056
1056
 
1057
1057
    return *this;
1058
1058
  }
1059
1059
 
1060
 
  void NCubemapData::Allocate(BitmapFormat format, t_s32 width, t_s32 height, t_s32 NumMipmapRequested)
 
1060
  void NCubemapData::Allocate(BitmapFormat format, int width, int height, int NumMipmapRequested)
1061
1061
  {
1062
1062
    nuxAssertMsg(width >= 0, "[NCubemapData::Allocate] Error: Negative texture width.");
1063
1063
    nuxAssertMsg(height >= 0, "[NCubemapData::Allocate] Error: Negative texture height.");
1065
1065
 
1066
1066
    ClearData();
1067
1067
 
1068
 
    t_s32 NumTotalMipLevel    = 1 + (t_s32) Floor(Log2(Max(width, height)));
 
1068
    int NumTotalMipLevel    = 1 + (int) Floor(Log2(Max(width, height)));
1069
1069
    m_NumMipmap = NumMipmapRequested;
1070
1070
 
1071
1071
    if (NumMipmapRequested == 0)
1076
1076
 
1077
1077
    m_TotalMemorySize = 0;
1078
1078
 
1079
 
    for (t_s32 face = 0; face < 6; face++)
 
1079
    for (int face = 0; face < 6; face++)
1080
1080
    {
1081
 
      for (t_s32 i = 0; i < m_NumMipmap; i++)
 
1081
      for (int i = 0; i < m_NumMipmap; i++)
1082
1082
      {
1083
 
        t_s32 w = width >> i;
1084
 
        t_s32 h = height >> i;
 
1083
        int w = width >> i;
 
1084
        int h = height >> i;
1085
1085
        m_MipSurfaceArray[face].push_back(new ImageSurface(format, w, h));
1086
1086
        m_TotalMemorySize += m_MipSurfaceArray[face][i]->GetSize();
1087
1087
      }
1088
1088
    }
1089
1089
  }
1090
1090
 
1091
 
  void NCubemapData::AllocateCheckBoardTexture(t_s32 width, t_s32 height, t_s32 NumMipmap, Color color0, Color color1, t_s32 TileWidth, t_s32 TileHeight)
 
1091
  void NCubemapData::AllocateCheckBoardTexture(int width, int height, int NumMipmap, Color color0, Color color1, int TileWidth, int TileHeight)
1092
1092
  {
1093
1093
    Allocate(BITFMT_R8G8B8A8, width, height, NumMipmap);
1094
1094
 
1095
 
    for (t_s32 face = 0; face < 6; face++)
 
1095
    for (int face = 0; face < 6; face++)
1096
1096
    {
1097
 
      for (t_s32 i = 0; i < m_NumMipmap; i++)
 
1097
      for (int i = 0; i < m_NumMipmap; i++)
1098
1098
      {
1099
 
        t_s32 w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), i);
1100
 
        t_s32 h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), i);
 
1099
        int w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), i);
 
1100
        int h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), i);
1101
1101
        MakeCheckBoardImage(*m_MipSurfaceArray[face][i], w, h, color0, color1, TileWidth, TileHeight);
1102
1102
      }
1103
1103
    }
1104
1104
  }
1105
1105
 
1106
 
  void NCubemapData::AllocateColorTexture(t_s32 width, t_s32 height, t_s32 NumMipmap, Color color0)
 
1106
  void NCubemapData::AllocateColorTexture(int width, int height, int NumMipmap, Color color0)
1107
1107
  {
1108
1108
    Allocate(BITFMT_R8G8B8A8, width, height, NumMipmap);
1109
1109
 
1110
 
    for (t_s32 face = 0; face < 6; face++)
 
1110
    for (int face = 0; face < 6; face++)
1111
1111
    {
1112
 
      for (t_s32 i = 0; i < m_NumMipmap; i++)
 
1112
      for (int i = 0; i < m_NumMipmap; i++)
1113
1113
      {
1114
 
        t_s32 w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), i);
1115
 
        t_s32 h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), i);
 
1114
        int w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), i);
 
1115
        int h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), i);
1116
1116
        MakeCheckBoardImage(*m_MipSurfaceArray[face][i], w, h, color0, color0);
1117
1117
      }
1118
1118
    }
1119
1119
  }
1120
1120
 
1121
 
  t_s32 NCubemapData::GetNumMipmap() const
 
1121
  int NCubemapData::GetNumMipmap() const
1122
1122
  {
1123
1123
    return m_MipSurfaceArray[0].size();
1124
1124
  }
1125
1125
 
1126
 
  bool NCubemapData::SetSurface(t_s32 face, t_s32 MipLevel, const ImageSurface &targetsurface)
 
1126
  bool NCubemapData::SetSurface(int face, int MipLevel, const ImageSurface &targetsurface)
1127
1127
  {
1128
1128
    nuxAssert(face >= 0);
1129
1129
    nuxAssert(face < 6);
1146
1146
  }
1147
1147
 
1148
1148
///////////////////////////////////////////////////////////////////
1149
 
  NVolumeData::NVolumeData(BitmapFormat format, t_s32 width, t_s32 height, t_s32 depth, t_s32 NumMipmap)
 
1149
  NVolumeData::NVolumeData(BitmapFormat format, int width, int height, int depth, int NumMipmap)
1150
1150
    :   m_NumMipmap(0)
1151
1151
    ,   m_Depth(0)
1152
1152
    ,   m_MipSurfaceArray(0)
1161
1161
 
1162
1162
  void NVolumeData::ClearData()
1163
1163
  {
1164
 
    for (t_s32 mip = 0; mip < GetNumMipmap(); mip++)
 
1164
    for (int mip = 0; mip < GetNumMipmap(); mip++)
1165
1165
    {
1166
 
      for (t_s32 s = 0; s < ImageSurface::GetLevelDim(GetFormat(), GetDepth(), mip); s++)
 
1166
      for (int s = 0; s < ImageSurface::GetLevelDim(GetFormat(), GetDepth(), mip); s++)
1167
1167
      {
1168
1168
        delete m_MipSurfaceArray[mip][s];
1169
1169
      }
1177
1177
//! Copy constructor
1178
1178
  NVolumeData::NVolumeData(const NVolumeData &object)
1179
1179
  {
1180
 
    for (t_s32 mip = 0; mip < object.GetNumMipmap(); mip++)
 
1180
    for (int mip = 0; mip < object.GetNumMipmap(); mip++)
1181
1181
    {
1182
 
      for (t_s32 s = 0; s < ImageSurface::GetLevelDim(object.GetFormat(), object.GetDepth(), mip); s++)
 
1182
      for (int s = 0; s < ImageSurface::GetLevelDim(object.GetFormat(), object.GetDepth(), mip); s++)
1183
1183
      {
1184
1184
        m_MipSurfaceArray[mip].push_back(new ImageSurface(object.GetSurface(mip, s)));
1185
1185
      }
1196
1196
 
1197
1197
    m_MipSurfaceArray = new std::vector<ImageSurface *>[m_NumMipmap];
1198
1198
 
1199
 
    for (t_s32 mip = 0; mip < copy.GetNumMipmap(); mip++)
 
1199
    for (int mip = 0; mip < copy.GetNumMipmap(); mip++)
1200
1200
    {
1201
 
      for (t_s32 s = 0; s < ImageSurface::GetLevelDim(copy.GetFormat(), copy.GetDepth(), mip); s++)
 
1201
      for (int s = 0; s < ImageSurface::GetLevelDim(copy.GetFormat(), copy.GetDepth(), mip); s++)
1202
1202
      {
1203
1203
        m_MipSurfaceArray[mip].push_back(new ImageSurface(copy.GetSurface(mip, s)));
1204
1204
      }
1207
1207
    return *this;
1208
1208
  }
1209
1209
 
1210
 
  void NVolumeData::Allocate(BitmapFormat format, t_s32 width, t_s32 height, t_s32 depth, t_s32 NumMipmapRequested)
 
1210
  void NVolumeData::Allocate(BitmapFormat format, int width, int height, int depth, int NumMipmapRequested)
1211
1211
  {
1212
1212
    nuxAssertMsg(depth >= 0, "[NVolumeData::Allocate] Error: Negative number of slice.");
1213
1213
    nuxAssertMsg(width >= 0, "[NVolumeData::Allocate] Error: Negative texture width.");
1216
1216
 
1217
1217
    ClearData();
1218
1218
 
1219
 
    t_s32 NumTotalMipLevel    = 1 + (t_s32) Floor(Log2(Max(width, height)));
 
1219
    int NumTotalMipLevel    = 1 + (int) Floor(Log2(Max(width, height)));
1220
1220
    m_NumMipmap = NumMipmapRequested;
1221
1221
 
1222
1222
    if (NumMipmapRequested == 0)
1230
1230
    m_MipSurfaceArray = new std::vector<ImageSurface *>[m_NumMipmap];
1231
1231
    m_TotalMemorySize = 0;
1232
1232
 
1233
 
    for (t_s32 mip = 0; mip < m_NumMipmap; mip++)
 
1233
    for (int mip = 0; mip < m_NumMipmap; mip++)
1234
1234
    {
1235
 
      for (t_s32 s = 0; s < ImageSurface::GetLevelDim(format, depth, mip); s++)
 
1235
      for (int s = 0; s < ImageSurface::GetLevelDim(format, depth, mip); s++)
1236
1236
      {
1237
 
        t_s32 w = ImageSurface::GetLevelDim(format, width, mip);
1238
 
        t_s32 h = ImageSurface::GetLevelDim(format, height, mip);
 
1237
        int w = ImageSurface::GetLevelDim(format, width, mip);
 
1238
        int h = ImageSurface::GetLevelDim(format, height, mip);
1239
1239
        m_MipSurfaceArray[mip].push_back(new ImageSurface(format, w, h));
1240
1240
        m_TotalMemorySize += m_MipSurfaceArray[mip][s]->GetSize();
1241
1241
      }
1242
1242
    }
1243
1243
  }
1244
1244
 
1245
 
  void NVolumeData::AllocateCheckBoardTexture(t_s32 width, t_s32 height, t_s32 slice, t_s32 NumMipmap, Color color0, Color color1, t_s32 TileWidth, t_s32 TileHeight)
 
1245
  void NVolumeData::AllocateCheckBoardTexture(int width, int height, int slice, int NumMipmap, Color color0, Color color1, int TileWidth, int TileHeight)
1246
1246
  {
1247
1247
    Allocate(BITFMT_R8G8B8A8, width, height, slice, NumMipmap);
1248
1248
 
1249
 
    for (t_s32 mip = 0; mip < m_NumMipmap; mip++)
 
1249
    for (int mip = 0; mip < m_NumMipmap; mip++)
1250
1250
    {
1251
 
      for (t_s32 s = 0; s < ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetDepth(), mip); s++)
 
1251
      for (int s = 0; s < ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetDepth(), mip); s++)
1252
1252
      {
1253
 
        t_s32 w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), mip);
1254
 
        t_s32 h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), mip);
 
1253
        int w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), mip);
 
1254
        int h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), mip);
1255
1255
        MakeCheckBoardImage(* (m_MipSurfaceArray[mip][s]), w, h, color0, color1, TileWidth, TileHeight);
1256
1256
      }
1257
1257
    }
1258
1258
  }
1259
1259
 
1260
 
  void NVolumeData::AllocateColorTexture(t_s32 width, t_s32 height, t_s32 slice, t_s32 NumMipmap, Color color0)
 
1260
  void NVolumeData::AllocateColorTexture(int width, int height, int slice, int NumMipmap, Color color0)
1261
1261
  {
1262
1262
    Allocate(BITFMT_R8G8B8A8, width, height, slice, NumMipmap);
1263
1263
 
1264
 
    for (t_s32 mip = 0; mip < m_NumMipmap; mip++)
 
1264
    for (int mip = 0; mip < m_NumMipmap; mip++)
1265
1265
    {
1266
 
      for (t_s32 s = 0; s < ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetDepth(), mip); s++)
 
1266
      for (int s = 0; s < ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetDepth(), mip); s++)
1267
1267
      {
1268
 
        t_s32 w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), mip);
1269
 
        t_s32 h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), mip);
 
1268
        int w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), mip);
 
1269
        int h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), mip);
1270
1270
        MakeCheckBoardImage(* (m_MipSurfaceArray[mip][s]), w, h, color0, color0);
1271
1271
      }
1272
1272
    }
1273
1273
  }
1274
1274
 
1275
 
  t_s32 NVolumeData::GetNumMipmap() const
 
1275
  int NVolumeData::GetNumMipmap() const
1276
1276
  {
1277
1277
    return m_NumMipmap;
1278
1278
  }
1279
1279
 
1280
 
  bool NVolumeData::SetSurface(t_s32 Slice, t_s32 MipLevel, const ImageSurface &targetsurface)
 
1280
  bool NVolumeData::SetSurface(int Slice, int MipLevel, const ImageSurface &targetsurface)
1281
1281
  {
1282
1282
    nuxAssert(Slice >= 0);
1283
1283
    nuxAssert(Slice < m_Depth);
1300
1300
  }
1301
1301
 
1302
1302
///////////////////////////////////////////////////////////////////
1303
 
  NAnimatedTextureData::NAnimatedTextureData(BitmapFormat format, t_s32 width, t_s32 height, t_s32 depth)
 
1303
  NAnimatedTextureData::NAnimatedTextureData(BitmapFormat format, int width, int height, int depth)
1304
1304
    :   m_NumMipmap(0)
1305
1305
    ,   m_Depth(0)
1306
1306
    ,   m_MipSurfaceArray(0)
1315
1315
 
1316
1316
  void NAnimatedTextureData::ClearData()
1317
1317
  {
1318
 
    for (t_s32 mip = 0; mip < GetNumMipmap(); mip++)
 
1318
    for (int mip = 0; mip < GetNumMipmap(); mip++)
1319
1319
    {
1320
 
      for (t_s32 s = 0; s < ImageSurface::GetLevelDim(GetFormat(), GetDepth(), mip); s++)
 
1320
      for (int s = 0; s < ImageSurface::GetLevelDim(GetFormat(), GetDepth(), mip); s++)
1321
1321
      {
1322
1322
        delete m_MipSurfaceArray[mip][s];
1323
1323
      }
1332
1332
//! Copy constructor
1333
1333
  NAnimatedTextureData::NAnimatedTextureData(const NAnimatedTextureData &object)
1334
1334
  {
1335
 
    for (t_s32 mip = 0; mip < object.GetNumMipmap(); mip++)
 
1335
    for (int mip = 0; mip < object.GetNumMipmap(); mip++)
1336
1336
    {
1337
 
      for (t_s32 s = 0; s < ImageSurface::GetLevelDim(object.GetFormat(), object.GetDepth(), mip); s++)
 
1337
      for (int s = 0; s < ImageSurface::GetLevelDim(object.GetFormat(), object.GetDepth(), mip); s++)
1338
1338
      {
1339
1339
        m_MipSurfaceArray[mip].push_back(new ImageSurface(object.GetSurface(mip, s)));
1340
1340
      }
1341
1341
    }
1342
1342
 
1343
 
    for (t_s32 frame = 0; frame < object.GetDepth(); frame++)
 
1343
    for (int frame = 0; frame < object.GetDepth(); frame++)
1344
1344
    {
1345
1345
      m_FrameTimeArray.push_back(object.GetFrameTime(frame));
1346
1346
    }
1356
1356
 
1357
1357
    m_MipSurfaceArray = new std::vector<ImageSurface *>[m_NumMipmap];
1358
1358
 
1359
 
    for (t_s32 mip = 0; mip < copy.GetNumMipmap(); mip++)
 
1359
    for (int mip = 0; mip < copy.GetNumMipmap(); mip++)
1360
1360
    {
1361
 
      for (t_s32 s = 0; s < ImageSurface::GetLevelDim(copy.GetFormat(), copy.GetDepth(), mip); s++)
 
1361
      for (int s = 0; s < ImageSurface::GetLevelDim(copy.GetFormat(), copy.GetDepth(), mip); s++)
1362
1362
      {
1363
1363
        m_MipSurfaceArray[mip].push_back(new ImageSurface(copy.GetSurface(s)));
1364
1364
      }
1365
1365
    }
1366
1366
 
1367
 
    for (t_s32 frame = 0; frame < copy.GetDepth(); frame++)
 
1367
    for (int frame = 0; frame < copy.GetDepth(); frame++)
1368
1368
    {
1369
1369
      m_FrameTimeArray.push_back(copy.GetFrameTime(frame));
1370
1370
    }
1372
1372
    return *this;
1373
1373
  }
1374
1374
 
1375
 
  void NAnimatedTextureData::Allocate(BitmapFormat format, t_s32 width, t_s32 height, t_s32 depth, t_s32 NumMipmapRequested)
 
1375
  void NAnimatedTextureData::Allocate(BitmapFormat format, int width, int height, int depth, int NumMipmapRequested)
1376
1376
  {
1377
1377
    nuxAssertMsg(depth >= 0, "[NAnimatedTextureData::Allocate] Error: Negative number of slice.");
1378
1378
    nuxAssertMsg(width >= 0, "[NAnimatedTextureData::Allocate] Error: Negative texture width.");
1381
1381
 
1382
1382
    ClearData();
1383
1383
 
1384
 
    t_s32 NumTotalMipLevel    = 1 + (t_s32) Floor(Log2(Max(width, height)));
 
1384
    int NumTotalMipLevel    = 1 + (int) Floor(Log2(Max(width, height)));
1385
1385
    m_NumMipmap = NumMipmapRequested;
1386
1386
 
1387
1387
    if (NumMipmapRequested == 0)
1395
1395
    m_MipSurfaceArray = new std::vector<ImageSurface *>[m_NumMipmap];
1396
1396
    m_TotalMemorySize = 0;
1397
1397
 
1398
 
    for (t_s32 mip = 0; mip < m_NumMipmap; mip++)
 
1398
    for (int mip = 0; mip < m_NumMipmap; mip++)
1399
1399
    {
1400
 
      for (t_s32 s = 0; s < ImageSurface::GetLevelDim(format, depth, mip); s++)
 
1400
      for (int s = 0; s < ImageSurface::GetLevelDim(format, depth, mip); s++)
1401
1401
      {
1402
 
        t_s32 w = ImageSurface::GetLevelDim(format, width, mip);
1403
 
        t_s32 h = ImageSurface::GetLevelDim(format, height, mip);
 
1402
        int w = ImageSurface::GetLevelDim(format, width, mip);
 
1403
        int h = ImageSurface::GetLevelDim(format, height, mip);
1404
1404
        m_MipSurfaceArray[mip].push_back(new ImageSurface(format, w, h));
1405
1405
        m_TotalMemorySize += m_MipSurfaceArray[mip][s]->GetSize();
1406
1406
      }
1407
1407
    }
1408
1408
  }
1409
1409
 
1410
 
  void NAnimatedTextureData::AllocateCheckBoardTexture(t_s32 width, t_s32 height, t_s32 slice, t_s32 NumMipmap, Color color0, Color color1, t_s32 TileWidth, t_s32 TileHeight)
 
1410
  void NAnimatedTextureData::AllocateCheckBoardTexture(int width, int height, int slice, int NumMipmap, Color color0, Color color1, int TileWidth, int TileHeight)
1411
1411
  {
1412
1412
    Allocate(BITFMT_R8G8B8A8, width, height, slice, NumMipmap);
1413
1413
 
1414
 
    for (t_s32 mip = 0; mip < m_NumMipmap; mip++)
 
1414
    for (int mip = 0; mip < m_NumMipmap; mip++)
1415
1415
    {
1416
 
      for (t_s32 s = 0; s < ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetDepth(), mip); s++)
 
1416
      for (int s = 0; s < ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetDepth(), mip); s++)
1417
1417
      {
1418
 
        t_s32 w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), mip);
1419
 
        t_s32 h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), mip);
 
1418
        int w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), mip);
 
1419
        int h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), mip);
1420
1420
        MakeCheckBoardImage(* (m_MipSurfaceArray[mip][s]), w, h, color0, color1, TileWidth, TileHeight);
1421
1421
      }
1422
1422
    }
1423
1423
  }
1424
1424
 
1425
 
  void NAnimatedTextureData::AllocateColorTexture(t_s32 width, t_s32 height, t_s32 slice, t_s32 NumMipmap, Color color0)
 
1425
  void NAnimatedTextureData::AllocateColorTexture(int width, int height, int slice, int NumMipmap, Color color0)
1426
1426
  {
1427
1427
    Allocate(BITFMT_R8G8B8A8, width, height, slice, NumMipmap);
1428
1428
 
1429
 
    for (t_s32 mip = 0; mip < m_NumMipmap; mip++)
 
1429
    for (int mip = 0; mip < m_NumMipmap; mip++)
1430
1430
    {
1431
 
      for (t_s32 s = 0; s < ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetDepth(), mip); s++)
 
1431
      for (int s = 0; s < ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetDepth(), mip); s++)
1432
1432
      {
1433
 
        t_s32 w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), mip);
1434
 
        t_s32 h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), mip);
 
1433
        int w = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetWidth(), mip);
 
1434
        int h = ImageSurface::GetLevelDim(BITFMT_R8G8B8A8, GetHeight(), mip);
1435
1435
        MakeCheckBoardImage(* (m_MipSurfaceArray[mip][s]), w, h, color0, color0);
1436
1436
      }
1437
1437
    }
1438
1438
  }
1439
1439
 
1440
 
  t_s32 NAnimatedTextureData::GetNumMipmap() const
 
1440
  int NAnimatedTextureData::GetNumMipmap() const
1441
1441
  {
1442
1442
    return m_NumMipmap;
1443
1443
  }
1444
1444
 
1445
 
  bool NAnimatedTextureData::SetSurface(t_s32 Slice, t_s32 MipLevel, const ImageSurface &targetsurface)
 
1445
  bool NAnimatedTextureData::SetSurface(int Slice, int MipLevel, const ImageSurface &targetsurface)
1446
1446
  {
1447
1447
    nuxAssert(Slice >= 0);
1448
1448
    nuxAssert(Slice < m_Depth);