Torque3D Documentation / _generateds / gfxFormatUtils.cpp

gfxFormatUtils.cpp

Engine/source/gfx/gfxFormatUtils.cpp

More...

Public Functions

GFXCopyPixels(GFXFormat fromFormat, U32 fromWidth, U32 fromHeight, U8 * fromData, GFXFormat toFormat, U32 toWidth, U32 toHeight, U8 * toData)

Detailed Description

Public Functions

GFXCopyPixels(GFXFormat fromFormat, U32 fromWidth, U32 fromHeight, U8 * fromData, GFXFormat toFormat, U32 toWidth, U32 toHeight, U8 * toData)

 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2012 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#include "gfx/gfxFormatUtils.h"
25#include "gfx/gfxDevice.h"
26
27
28//RDTODO: complete format infos
29
30
31//-----------------------------------------------------------------------------
32
33GFXFormatInfo::Data GFXFormatInfo::smFormatInfos[ GFXFormat_COUNT ] =
34{
35   // 8 bit texture formats...
36   GFXFormatInfo::Data( 1,    false, false, false ),   // GFXFormatA8
37   GFXFormatInfo::Data( 1,    false, false, false ),   // GFXFormatL8
38   GFXFormatInfo::Data( 1,    true,  false, false ),   // GFXFormatA4L4
39
40   // 16 bit texture formats...
41   GFXFormatInfo::Data( 2,    false, false, false ),   // GFXFormatR5G6B5
42   GFXFormatInfo::Data( 2,    true,  false, false ),   // GFXFormatR5G5B5A1
43   GFXFormatInfo::Data( 2,    true,  false, false ),   // GFXFormatA8L8
44   GFXFormatInfo::Data( 2,    false, false, false ),   // GFXFormatL16
45   GFXFormatInfo::Data( 2,    false, false, false ),   // GFXFormatR16F
46   GFXFormatInfo::Data( 2,    false, false, false ),   // GFXFormatD16
47
48   // 24 bit texture formats...
49   GFXFormatInfo::Data( 3,    false, false, false ),   // GFXFormatR8G8B8
50
51   // 32 bit texture formats...
52   GFXFormatInfo::Data( 4,    true,  false, false ),   // GFXFormatR8G8B8A8
53   GFXFormatInfo::Data( 4,    false, false, false ),   // GFXFormatR8G8B8X8
54   GFXFormatInfo::Data( 4,    false, false, false ),   // GFXFormatR32F
55   GFXFormatInfo::Data( 4,    false, false, false ),   // GFXFormatR16G16
56   GFXFormatInfo::Data( 4,    false, false, true  ),   // GFXFormatR16G16F
57   GFXFormatInfo::Data( 4,    true,  false, false ),   // GFXFormatR10G10B10A2
58   GFXFormatInfo::Data( 4,    false, false, false ),   // GFXFormatD32
59   GFXFormatInfo::Data( 4,    false, false, false ),   // GFXFormatD24X8
60   GFXFormatInfo::Data( 4,    false, false, false ),   // GFXFormatD24S8
61   GFXFormatInfo::Data( 4,    false, false, false ),   // GFXFormatD24FS8
62
63   // 64 bit texture formats...
64   GFXFormatInfo::Data( 8,    true,  false, false ),   // GFXFormatR16G16B16A16
65   GFXFormatInfo::Data( 8,    true,  false, true  ),   // GFXFormatR16G16B16A16F
66
67   // 128 bit texture formats...
68   GFXFormatInfo::Data( 16,   true,  false, true  ),  // GFXFormatR32G32B32A32F
69
70   // Compressed formats...
71   GFXFormatInfo::Data( 0,    false, true,  false ),   // GFXFormatBC1
72   GFXFormatInfo::Data( 0,    true,  true,  false ),   // GFXFormatBC2
73   GFXFormatInfo::Data( 0,    true,  true,  false ),   // GFXFormatBC3
74   GFXFormatInfo::Data( 0,    false, true,  false ),   // GFXFormatBC4
75   GFXFormatInfo::Data( 0,    false, true,  false ),   // GFXFormatBC5
76};
77
78//-----------------------------------------------------------------------------
79
80void GFXCopyPixels(  GFXFormat fromFormat, U32 fromWidth, U32 fromHeight, U8* fromData,
81                     GFXFormat toFormat, U32 toWidth, U32 toHeight, U8* toData )
82{
83   if( fromFormat == toFormat
84       && fromWidth == toWidth
85       && fromHeight == toHeight )
86      dMemcpy( toData, fromData, fromWidth * fromHeight * GFXFormatInfo( fromFormat ).getBytesPerPixel() );
87   else
88   {
89      AssertFatal( false, "Not implemented" );
90   }
91}
92