Torque3D Documentation / _generateds / gfxStringEnumTranslate.cpp

gfxStringEnumTranslate.cpp

Engine/source/gfx/gfxStringEnumTranslate.cpp

More...

Public Defines

define
_STRING_VALUE_LOOKUP_FXN(table)     char * table##_lookup(   & ) { return table[]; }
define
GFX_STRING_ASSIGN_MACRO(table, indexEnum) table[indexEnum] = #indexEnum;
define
GFX_STRING_ASSIGN_MACRO_EX(table, indexEnum, typeTable) table[indexEnum] = #indexEnum; table##ValueLookup[indexEnum] = &typeTable##_lookup;
define
INIT_LOOKUPTABLE(tablearray, enumprefix, type)    (   = enumprefix##_FIRST;  < enumprefix##_COUNT; ++ ) \
      tablearray[] = (type)();
define
INIT_LOOKUPTABLE_EX(tablearray, enumprefix, type, typeTable)    (   = enumprefix##_FIRST;  < enumprefix##_COUNT; ++ ) \
   {\
      tablearray[] = (type)();\
      typeTable[] = &;\
   }
define
VALIDATE_LOOKUPTABLE(tablearray, enumprefix)    (   = enumprefix##_FIRST;  < enumprefix##_COUNT; ++ ) \
      ( ()tablearray[] ==  ) \
         ( "GFXStringEnumTranslate: Unassigned  in " #tablearray ": %i", i ); \
      else ( ()tablearray[] ==  ) \
         ( "GFXStringEnumTranslate: Unsupported  in " #tablearray ": %i", i );

Public Variables

const char *
GFXStringBlend [GFXBlend_COUNT]
const char *
GFXStringBlendOp [GFXBlendOp_COUNT]
const char *
GFXStringCmpFunc [GFXCmp_COUNT]
const char *
GFXStringCullMode [GFXCull_COUNT]
const char *
GFXStringFillMode [GFXFill_COUNT]
const char *
GFXStringPrimType [GFXPT_COUNT]
const char *
GFXStringRenderTargetFormat [GFXFormat_COUNT]
const char *
GFXStringStencilOp [GFXStencilOp_COUNT]
const char *
GFXStringTextureAddress [GFXAddress_COUNT]
const char *
GFXStringTextureFilter [GFXTextureFilter_COUNT]
const char *
GFXStringTextureFormat [GFXFormat_COUNT]
const char *
GFXStringTiledTextureFormat [GFXFormat_COUNT]

Detailed Description

Public Defines

_STRING_VALUE_LOOKUP_FXN(table)     char * table##_lookup(   & ) { return table[]; }
GFX_STRING_ASSIGN_MACRO(table, indexEnum) table[indexEnum] = #indexEnum;
GFX_STRING_ASSIGN_MACRO_EX(table, indexEnum, typeTable) table[indexEnum] = #indexEnum; table##ValueLookup[indexEnum] = &typeTable##_lookup;
INIT_LOOKUPTABLE(tablearray, enumprefix, type)    (   = enumprefix##_FIRST;  < enumprefix##_COUNT; ++ ) \
      tablearray[] = (type)();
INIT_LOOKUPTABLE_EX(tablearray, enumprefix, type, typeTable)    (   = enumprefix##_FIRST;  < enumprefix##_COUNT; ++ ) \
   {\
      tablearray[] = (type)();\
      typeTable[] = &;\
   }
VALIDATE_LOOKUPTABLE(tablearray, enumprefix)    (   = enumprefix##_FIRST;  < enumprefix##_COUNT; ++ ) \
      ( ()tablearray[] ==  ) \
         ( "GFXStringEnumTranslate: Unassigned  in " #tablearray ": %i", i ); \
      else ( ()tablearray[] ==  ) \
         ( "GFXStringEnumTranslate: Unsupported  in " #tablearray ": %i", i );

Public Variables

const char * GFXStringBlend [GFXBlend_COUNT]
const char * GFXStringBlendOp [GFXBlendOp_COUNT]
const char * GFXStringCmpFunc [GFXCmp_COUNT]
const char * GFXStringCullMode [GFXCull_COUNT]
const char * GFXStringFillMode [GFXFill_COUNT]
const char * GFXStringPrimType [GFXPT_COUNT]
const char * GFXStringRenderTargetFormat [GFXFormat_COUNT]
const char * GFXStringStencilOp [GFXStencilOp_COUNT]
const char * GFXStringTextureAddress [GFXAddress_COUNT]
const char * GFXStringTextureFilter [GFXTextureFilter_COUNT]
const char * GFXStringTextureFormat [GFXFormat_COUNT]
const char * GFXStringTiledTextureFormat [GFXFormat_COUNT]

Public Functions

_STRING_VALUE_LOOKUP_FXN(GFXStringBlend )

_STRING_VALUE_LOOKUP_FXN(GFXStringBlendOp )

_STRING_VALUE_LOOKUP_FXN(GFXStringCmpFunc )

_STRING_VALUE_LOOKUP_FXN(GFXStringCullMode )

_STRING_VALUE_LOOKUP_FXN(GFXStringStencilOp )

_STRING_VALUE_LOOKUP_FXN(GFXStringTextureAddress )

_STRING_VALUE_LOOKUP_FXN(GFXStringTextureFilter )

defaultStringValueLookup(const U32 & value)

  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 "core/strings/stringFunctions.h"
 25
 26#include "gfx/gfxStringEnumTranslate.h"
 27#include "gfx/gfxAPI.h"
 28#include "console/console.h"
 29
 30//------------------------------------------------------------------------------
 31
 32const char *GFXStringTextureFormat[GFXFormat_COUNT];
 33const char *GFXStringTiledTextureFormat[GFXFormat_COUNT];
 34const char *GFXStringRenderTargetFormat[GFXFormat_COUNT];
 35const char *GFXStringTextureFilter[GFXTextureFilter_COUNT];
 36const char *GFXStringBlend[GFXBlend_COUNT];
 37const char *GFXStringBlendOp[GFXBlendOp_COUNT];
 38const char *GFXStringStencilOp[GFXStencilOp_COUNT];
 39const char *GFXStringCmpFunc[GFXCmp_COUNT];
 40const char *GFXStringCullMode[GFXCull_COUNT];
 41const char *GFXStringPrimType[GFXPT_COUNT];
 42const char *GFXStringTextureAddress[GFXAddress_COUNT];
 43const char *GFXStringFillMode[GFXFill_COUNT];
 44
 45//------------------------------------------------------------------------------
 46
 47const char *defaultStringValueLookup( const U32 &value )
 48{
 49   static char retbuffer[256];
 50
 51   dSprintf( retbuffer, sizeof( retbuffer ), "%d", value );
 52
 53   return retbuffer;
 54}
 55
 56#define _STRING_VALUE_LOOKUP_FXN( table ) \
 57   const char * table##_lookup( const U32 &value ) { return table[value]; }
 58
 59_STRING_VALUE_LOOKUP_FXN(GFXStringTextureAddress);
 60_STRING_VALUE_LOOKUP_FXN(GFXStringTextureFilter);
 61_STRING_VALUE_LOOKUP_FXN(GFXStringBlend);
 62_STRING_VALUE_LOOKUP_FXN(GFXStringCmpFunc);
 63_STRING_VALUE_LOOKUP_FXN(GFXStringStencilOp);
 64_STRING_VALUE_LOOKUP_FXN(GFXStringCullMode);
 65_STRING_VALUE_LOOKUP_FXN(GFXStringBlendOp);
 66
 67//------------------------------------------------------------------------------
 68
 69#define INIT_LOOKUPTABLE( tablearray, enumprefix, type ) \
 70   for( S32 i = enumprefix##_FIRST; i < enumprefix##_COUNT; i++ ) \
 71      tablearray[i] = (type)(uintptr_t)GFX_UNINIT_VAL;
 72#define INIT_LOOKUPTABLE_EX( tablearray, enumprefix, type, typeTable ) \
 73   for( S32 i = enumprefix##_FIRST; i < enumprefix##_COUNT; i++ ) \
 74   {\
 75      tablearray[i] = (type)(uintptr_t)GFX_UNINIT_VAL;\
 76      typeTable[i] = &defaultStringValueLookup;\
 77   }
 78
 79#define VALIDATE_LOOKUPTABLE( tablearray, enumprefix ) \
 80   for( S32 i = enumprefix##_FIRST; i < enumprefix##_COUNT; i++ ) \
 81      if( (intptr_t)tablearray[i] == GFX_UNINIT_VAL ) \
 82         Con::warnf( "GFXStringEnumTranslate: Unassigned value in " #tablearray ": %i", i ); \
 83      else if( (intptr_t)tablearray[i] == GFX_UNSUPPORTED_VAL ) \
 84         Con::warnf( "GFXStringEnumTranslate: Unsupported value in " #tablearray ": %i", i );
 85
 86//------------------------------------------------------------------------------
 87
 88#define GFX_STRING_ASSIGN_MACRO( table, indexEnum ) table[indexEnum] = #indexEnum;
 89#define GFX_STRING_ASSIGN_MACRO_EX( table, indexEnum, typeTable ) table[indexEnum] = #indexEnum; table##ValueLookup[indexEnum] = &typeTable##_lookup;
 90
 91void GFXStringEnumTranslate::init()
 92{
 93   static bool sInitCalled = false;
 94
 95   if( sInitCalled )
 96      return;
 97
 98   sInitCalled = true;
 99
100//------------------------------------------------------------------------------
101//------------------------------------------------------------------------------
102   INIT_LOOKUPTABLE( GFXStringTextureFormat, GFXFormat, const char * );
103   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR8G8B8 );
104   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR8G8B8A8 );
105   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR8G8B8A8_SRGB);
106   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR8G8B8X8 );
107   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatB8G8R8A8 );
108   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR32F );
109   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR5G6B5 );
110   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR5G5B5A1 );
111   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR5G5B5X1 );
112   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatA4L4 );
113   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatA8L8 );
114   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatA8 );
115   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatL8 );
116   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatBC1 );
117   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatBC2 );
118   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatBC3 );
119   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatBC4 );
120   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatBC5 );
121   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD32 );
122   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD24X8 );
123   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD24S8 );
124   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD24FS8 );
125   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatD16 );
126
127   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR32G32B32A32F );
128   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR16G16B16A16F );
129   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatL16 );
130   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR16G16B16A16 );
131   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR16G16 );
132   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR16F );
133   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR16G16F );
134   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR10G10B10A2 );
135
136   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR8G8B8_SRGB );
137   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatR8G8B8A8_LINEAR_FORCE );
138   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatBC1_SRGB );
139   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatBC2_SRGB );
140   GFX_STRING_ASSIGN_MACRO( GFXStringTextureFormat, GFXFormatBC3_SRGB );
141   VALIDATE_LOOKUPTABLE( GFXStringTextureFormat, GFXFormat);
142
143//------------------------------------------------------------------------------
144//------------------------------------------------------------------------------
145   INIT_LOOKUPTABLE( GFXStringBlend, GFXBlend, const char * );
146   GFX_STRING_ASSIGN_MACRO( GFXStringBlend, GFXBlendZero );
147   GFX_STRING_ASSIGN_MACRO( GFXStringBlend, GFXBlendOne );
148   GFX_STRING_ASSIGN_MACRO( GFXStringBlend, GFXBlendSrcColor );
149   GFX_STRING_ASSIGN_MACRO( GFXStringBlend, GFXBlendInvSrcColor );
150   GFX_STRING_ASSIGN_MACRO( GFXStringBlend, GFXBlendSrcAlpha );
151   GFX_STRING_ASSIGN_MACRO( GFXStringBlend, GFXBlendInvSrcAlpha );
152   GFX_STRING_ASSIGN_MACRO( GFXStringBlend, GFXBlendDestAlpha );
153   GFX_STRING_ASSIGN_MACRO( GFXStringBlend, GFXBlendInvDestAlpha );
154   GFX_STRING_ASSIGN_MACRO( GFXStringBlend, GFXBlendDestColor );
155   GFX_STRING_ASSIGN_MACRO( GFXStringBlend, GFXBlendInvDestColor );
156   GFX_STRING_ASSIGN_MACRO( GFXStringBlend, GFXBlendSrcAlphaSat );
157   VALIDATE_LOOKUPTABLE( GFXStringBlend, GFXBlend );
158//------------------------------------------------------------------------------
159//------------------------------------------------------------------------------
160   INIT_LOOKUPTABLE( GFXStringBlendOp, GFXBlendOp, const char * );
161   GFX_STRING_ASSIGN_MACRO( GFXStringBlendOp, GFXBlendOpAdd );
162   GFX_STRING_ASSIGN_MACRO( GFXStringBlendOp, GFXBlendOpSubtract );
163   GFX_STRING_ASSIGN_MACRO( GFXStringBlendOp, GFXBlendOpRevSubtract );
164   GFX_STRING_ASSIGN_MACRO( GFXStringBlendOp, GFXBlendOpMin );
165   GFX_STRING_ASSIGN_MACRO( GFXStringBlendOp, GFXBlendOpMax );
166   VALIDATE_LOOKUPTABLE( GFXStringBlendOp, GFXBlendOp );
167//------------------------------------------------------------------------------
168//------------------------------------------------------------------------------
169   INIT_LOOKUPTABLE( GFXStringStencilOp, GFXStencilOp, const char * );
170   GFX_STRING_ASSIGN_MACRO( GFXStringStencilOp, GFXStencilOpKeep );
171   GFX_STRING_ASSIGN_MACRO( GFXStringStencilOp, GFXStencilOpZero );
172   GFX_STRING_ASSIGN_MACRO( GFXStringStencilOp, GFXStencilOpReplace );
173   GFX_STRING_ASSIGN_MACRO( GFXStringStencilOp, GFXStencilOpIncrSat );
174   GFX_STRING_ASSIGN_MACRO( GFXStringStencilOp, GFXStencilOpDecrSat );
175   GFX_STRING_ASSIGN_MACRO( GFXStringStencilOp, GFXStencilOpInvert );
176   GFX_STRING_ASSIGN_MACRO( GFXStringStencilOp, GFXStencilOpIncr );
177   GFX_STRING_ASSIGN_MACRO( GFXStringStencilOp, GFXStencilOpDecr );
178   VALIDATE_LOOKUPTABLE( GFXStringStencilOp, GFXStencilOp );
179//------------------------------------------------------------------------------
180//------------------------------------------------------------------------------
181   INIT_LOOKUPTABLE( GFXStringCmpFunc, GFXCmp, const char * );
182   GFX_STRING_ASSIGN_MACRO( GFXStringCmpFunc, GFXCmpNever );
183   GFX_STRING_ASSIGN_MACRO( GFXStringCmpFunc, GFXCmpLess );
184   GFX_STRING_ASSIGN_MACRO( GFXStringCmpFunc, GFXCmpEqual );
185   GFX_STRING_ASSIGN_MACRO( GFXStringCmpFunc, GFXCmpLessEqual );
186   GFX_STRING_ASSIGN_MACRO( GFXStringCmpFunc, GFXCmpGreater );
187   GFX_STRING_ASSIGN_MACRO( GFXStringCmpFunc, GFXCmpNotEqual );
188   GFX_STRING_ASSIGN_MACRO( GFXStringCmpFunc, GFXCmpGreaterEqual );
189   GFX_STRING_ASSIGN_MACRO( GFXStringCmpFunc, GFXCmpAlways );
190   VALIDATE_LOOKUPTABLE( GFXStringCmpFunc, GFXCmp );
191//------------------------------------------------------------------------------
192//------------------------------------------------------------------------------
193   INIT_LOOKUPTABLE( GFXStringCullMode, GFXCull, const char * );
194   GFX_STRING_ASSIGN_MACRO( GFXStringCullMode, GFXCullNone );
195   GFX_STRING_ASSIGN_MACRO( GFXStringCullMode, GFXCullCW );
196   GFX_STRING_ASSIGN_MACRO( GFXStringCullMode, GFXCullCCW );
197   VALIDATE_LOOKUPTABLE( GFXStringCullMode, GFXCull );
198//------------------------------------------------------------------------------
199//------------------------------------------------------------------------------
200   INIT_LOOKUPTABLE( GFXStringPrimType, GFXPT, const char * );
201   GFX_STRING_ASSIGN_MACRO( GFXStringPrimType, GFXPointList );
202   GFX_STRING_ASSIGN_MACRO( GFXStringPrimType, GFXLineList );
203   GFX_STRING_ASSIGN_MACRO( GFXStringPrimType, GFXLineStrip );
204   GFX_STRING_ASSIGN_MACRO( GFXStringPrimType, GFXTriangleList );
205   GFX_STRING_ASSIGN_MACRO( GFXStringPrimType, GFXTriangleStrip );
206   VALIDATE_LOOKUPTABLE( GFXStringPrimType, GFXPT );
207//------------------------------------------------------------------------------
208//------------------------------------------------------------------------------
209   INIT_LOOKUPTABLE( GFXStringTextureAddress, GFXAddress, const char * );
210   GFX_STRING_ASSIGN_MACRO( GFXStringTextureAddress, GFXAddressWrap );
211   GFX_STRING_ASSIGN_MACRO( GFXStringTextureAddress, GFXAddressMirror );
212   GFX_STRING_ASSIGN_MACRO( GFXStringTextureAddress, GFXAddressClamp );
213   GFX_STRING_ASSIGN_MACRO( GFXStringTextureAddress, GFXAddressBorder );
214   GFX_STRING_ASSIGN_MACRO( GFXStringTextureAddress, GFXAddressMirrorOnce );
215   VALIDATE_LOOKUPTABLE(GFXStringTextureAddress, GFXAddress );
216//------------------------------------------------------------------------------
217//------------------------------------------------------------------------------
218   INIT_LOOKUPTABLE( GFXStringFillMode, GFXFill, const char * );
219   GFX_STRING_ASSIGN_MACRO( GFXStringFillMode, GFXFillPoint );
220   GFX_STRING_ASSIGN_MACRO( GFXStringFillMode, GFXFillWireframe );
221   GFX_STRING_ASSIGN_MACRO( GFXStringFillMode, GFXFillSolid );
222   VALIDATE_LOOKUPTABLE( GFXStringFillMode, GFXFill );
223}
224