Skip to content

Commit

Permalink
Change some use of #define to constexpr
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed Oct 26, 2024
1 parent a050b63 commit 28bfdbb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions DirectXTex/DirectXTex.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace DirectX

size_t __cdecl BytesPerBlock(_In_ DXGI_FORMAT fmt) noexcept;

enum FORMAT_TYPE
enum FORMAT_TYPE : uint32_t
{
FORMAT_TYPE_TYPELESS,
FORMAT_TYPE_FLOAT,
Expand Down Expand Up @@ -136,7 +136,7 @@ namespace DirectX

//---------------------------------------------------------------------------------
// Texture metadata
enum TEX_DIMENSION
enum TEX_DIMENSION : uint32_t
// Subset here matches D3D10_RESOURCE_DIMENSION and D3D11_RESOURCE_DIMENSION
{
TEX_DIMENSION_TEXTURE1D = 2,
Expand All @@ -155,7 +155,7 @@ namespace DirectX
TEX_MISC2_ALPHA_MODE_MASK = 0x7L,
};

enum TEX_ALPHA_MODE
enum TEX_ALPHA_MODE : uint32_t
// Matches DDS_ALPHA_MODE, encoded in MISC_FLAGS2
{
TEX_ALPHA_MODE_UNKNOWN = 0,
Expand Down Expand Up @@ -934,7 +934,7 @@ namespace DirectX
//---------------------------------------------------------------------------------
// WIC utility code
#ifdef _WIN32
enum WICCodecs
enum WICCodecs : uint32_t
{
WIC_CODEC_BMP = 1, // Windows Bitmap (.bmp)
WIC_CODEC_JPEG, // Joint Photographic Experts Group (.jpg, .jpeg)
Expand Down
12 changes: 6 additions & 6 deletions Texassemble/texassemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,18 +344,18 @@ namespace
{ nullptr, TEX_FILTER_DEFAULT }
};

#define CODEC_DDS 0xFFFF0001
#define CODEC_TGA 0xFFFF0002
#define CODEC_HDR 0xFFFF0005
constexpr uint32_t CODEC_DDS = 0xFFFF0001;
constexpr uint32_t CODEC_TGA = 0xFFFF0002;
constexpr uint32_t CODEC_HDR = 0xFFFF0005;

#ifdef USE_OPENEXR
#define CODEC_EXR 0xFFFF0006
constexpr uint32_t CODEC_EXR = 0xFFFF0008;
#endif
#ifdef USE_LIBJPEG
#define CODEC_JPEG 0xFFFF0007
constexpr uint32_t CODEC_JPEG = 0xFFFF0009;
#endif
#ifdef USE_LIBPNG
#define CODEC_PNG 0xFFFF0008
constexpr uint32_t CODEC_PNG = 0xFFFF000A;
#endif

const SValue<uint32_t> g_pExtFileTypes[] =
Expand Down
20 changes: 10 additions & 10 deletions Texconv/texconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,22 +544,22 @@ namespace
{ nullptr, 0 },
};

#define CODEC_DDS 0xFFFF0001
#define CODEC_TGA 0xFFFF0002
#define CODEC_HDP 0xFFFF0003
#define CODEC_JXR 0xFFFF0004
#define CODEC_HDR 0xFFFF0005
#define CODEC_PPM 0xFFFF0006
#define CODEC_PFM 0xFFFF0007
constexpr uint32_t CODEC_DDS = 0xFFFF0001;
constexpr uint32_t CODEC_TGA = 0xFFFF0002;
constexpr uint32_t CODEC_HDP = 0xFFFF0003;
constexpr uint32_t CODEC_JXR = 0xFFFF0004;
constexpr uint32_t CODEC_HDR = 0xFFFF0005;
constexpr uint32_t CODEC_PPM = 0xFFFF0006;
constexpr uint32_t CODEC_PFM = 0xFFFF0007;

#ifdef USE_OPENEXR
#define CODEC_EXR 0xFFFF0008
constexpr uint32_t CODEC_EXR = 0xFFFF0008;
#endif
#ifdef USE_LIBJPEG
#define CODEC_JPEG 0xFFFF0009
constexpr uint32_t CODEC_JPEG = 0xFFFF0009;
#endif
#ifdef USE_LIBPNG
#define CODEC_PNG 0xFFFF000A
constexpr uint32_t CODEC_PNG = 0xFFFF000A;
#endif

const SValue<uint32_t> g_pSaveFileTypes[] = // valid formats to write to
Expand Down
14 changes: 7 additions & 7 deletions Texdiag/texdiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,18 +379,18 @@ namespace
{ nullptr, TEX_FILTER_DEFAULT }
};

#define CODEC_DDS 0xFFFF0001
#define CODEC_TGA 0xFFFF0002
#define CODEC_HDR 0xFFFF0005
constexpr uint32_t CODEC_DDS = 0xFFFF0001;
constexpr uint32_t CODEC_TGA = 0xFFFF0002;
constexpr uint32_t CODEC_HDR = 0xFFFF0005;

#ifdef USE_OPENEXR
#define CODEC_EXR 0xFFFF0006
constexpr uint32_t CODEC_EXR = 0xFFFF0008;
#endif
#ifdef USE_LIBJPEG
#define CODEC_JPEG 0xFFFF0007
constexpr uint32_t CODEC_JPEG = 0xFFFF0009;
#endif
#ifdef USE_LIBPNG
#define CODEC_PNG 0xFFFF0008
constexpr uint32_t CODEC_PNG = 0xFFFF000A;
#endif

const SValue<uint32_t> g_pDumpFileTypes[] =
Expand Down Expand Up @@ -1388,7 +1388,7 @@ namespace
//--------------------------------------------------------------------------------------
#define SIGN_EXTEND(x,nb) ((((x)&(1<<((nb)-1)))?((~0)^((1<<(nb))-1)):0)|(x))

#define NUM_PIXELS_PER_BLOCK 16
constexpr size_t NUM_PIXELS_PER_BLOCK = 16;

void Print565(uint16_t rgb)
{
Expand Down

0 comments on commit 28bfdbb

Please sign in to comment.