Skip to content

Commit

Permalink
Minor changes in TypeNames.cpp/.h, Format.h, and Color.h source files.
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBanana committed Oct 4, 2023
1 parent 57e5af4 commit ff66aa9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
3 changes: 1 addition & 2 deletions include/LLGL/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ enum class Format
\see ImageView::format
\see MutableImageView::format
\see GetMemoryFootprint
\todo Maybe replace \c DataType and \c ImageFormat by LLGL::Format.
\todo Maybe find better name to not confuse this enum with LLGL::Format.
*/
enum class ImageFormat
{
Expand Down Expand Up @@ -264,7 +264,6 @@ enum class ImageFormat
\remarks The counterpart of this enumeration for GPU side operations is LLGL::Format.
\see ImageView::dataType
\see MutableImageView::dataType
\todo Maybe replace \c DataType and \c ImageFormat by LLGL::Format.
*/
enum class DataType
{
Expand Down
8 changes: 4 additions & 4 deletions include/LLGL/Utils/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ template <typename Dst, typename Src>
inline Dst CastColorValue(const Src& value)
{
/* Use double as intermediate type, if either source or destination type is double */
using T = typename std::conditional
using TReal = typename std::conditional
<
(std::is_same<Src, double>::value || std::is_same<Dst, double>::value),
double,
Expand All @@ -61,11 +61,11 @@ inline Dst CastColorValue(const Src& value)
::type;

/* Get data type ranges */
const auto srcRange = static_cast<T>(MaxColorValue<Src>());
const auto dstRange = static_cast<T>(MaxColorValue<Dst>());
const TReal srcRange = static_cast<TReal>(MaxColorValue<Src>());
const TReal dstRange = static_cast<TReal>(MaxColorValue<Dst>());

/* Transform input value into new range */
return static_cast<Dst>(static_cast<T>(value) * dstRange / srcRange);
return static_cast<Dst>(static_cast<TReal>(value) * dstRange / srcRange);
}

//! Specialized template which merely passes the input value as output.
Expand Down
16 changes: 8 additions & 8 deletions include/LLGL/Utils/TypeNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,49 +35,49 @@ namespace LLGL
\brief Returns a string representation for the spcified ShaderType value, or null if the input type is invalid.
\remarks Return value examples are \c "vertex", \c "tessellation control".
*/
LLGL_EXPORT const char* ToString(const ShaderType t);
LLGL_EXPORT const char* ToString(const ShaderType val);

/**
\brief Returns a string representation for the specified ErrorType value, or null if the input type is invalid.
\remarks Return value examples are \c "invalid argument", \c "unsupported feature".
*/
LLGL_EXPORT const char* ToString(const ErrorType t);
LLGL_EXPORT const char* ToString(const ErrorType val);

/**
\brief Returns a string representation for the specified WarningType value, or null if the input type is invalid.
\remarks Return value examples are \c "improper argument", \c "pointless operation".
*/
LLGL_EXPORT const char* ToString(const WarningType t);
LLGL_EXPORT const char* ToString(const WarningType val);

/**
\brief Returns a string representation for the specified ShadingLanguage value, or null if the input type is invalid.
\remarks Return value examples are \c "GLSL 450", \c "HLSL 2.0c".
*/
LLGL_EXPORT const char* ToString(const ShadingLanguage t);
LLGL_EXPORT const char* ToString(const ShadingLanguage val);

/**
\brief Returns a string representation for the specified Format value, or null if the input type is invalid.
\remarks Return value examples are \c "R8UNorm", \c "RGBA16Float", \c "D24UNormS8UInt", \c "RGB DXT1".
*/
LLGL_EXPORT const char* ToString(const Format t);
LLGL_EXPORT const char* ToString(const Format val);

/**
\brief Returns a string representation for the specified TextureType value, or null if the input type is invalid.
\remarks Return value examples are \c "Texture1D", \c "Texture2DArray".
*/
LLGL_EXPORT const char* ToString(const TextureType t);
LLGL_EXPORT const char* ToString(const TextureType val);

/**
\brief Returns a string representation for the specified BlendOp value, or null if the input type is invalid.
\remarks Return value examples are \c "Zero", \c "SrcAlpha".
*/
LLGL_EXPORT const char* ToString(const BlendOp t);
LLGL_EXPORT const char* ToString(const BlendOp val);

/**
\brief Returns a string representation for the specified ResourceType value, or null if the input type is invalid.
\remarks Return value examples are \c "buffer", \c "texture".
*/
LLGL_EXPORT const char* ToString(const ResourceType t);
LLGL_EXPORT const char* ToString(const ResourceType val);

/** @} */

Expand Down
43 changes: 25 additions & 18 deletions sources/Core/TypeNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ namespace LLGL
{


LLGL_EXPORT const char* ToString(const ShaderType t)
LLGL_EXPORT const char* ToString(const ShaderType val)
{
using T = ShaderType;

switch (t)
switch (val)
{
case T::Undefined: return "<undefined>";
case T::Undefined: return "undefined";
case T::Vertex: return "vertex";
case T::TessControl: return "tessellation control";
case T::TessEvaluation: return "tessellation evaluation";
Expand All @@ -30,11 +30,11 @@ LLGL_EXPORT const char* ToString(const ShaderType t)
return nullptr;
}

LLGL_EXPORT const char* ToString(const ErrorType t)
LLGL_EXPORT const char* ToString(const ErrorType val)
{
using T = ErrorType;

switch (t)
switch (val)
{
case T::InvalidArgument: return "invalid argument";
case T::InvalidState: return "invalid state";
Expand All @@ -45,11 +45,11 @@ LLGL_EXPORT const char* ToString(const ErrorType t)
return nullptr;
}

LLGL_EXPORT const char* ToString(const WarningType t)
LLGL_EXPORT const char* ToString(const WarningType val)
{
using T = WarningType;

switch (t)
switch (val)
{
case T::ImproperArgument: return "improper argument";
case T::ImproperState: return "improper state";
Expand All @@ -60,11 +60,11 @@ LLGL_EXPORT const char* ToString(const WarningType t)
return nullptr;
}

LLGL_EXPORT const char* ToString(const ShadingLanguage t)
LLGL_EXPORT const char* ToString(const ShadingLanguage val)
{
using T = ShadingLanguage;

switch (t)
switch (val)
{
case T::GLSL: return "GLSL";
case T::GLSL_110: return "GLSL 110";
Expand Down Expand Up @@ -96,11 +96,18 @@ LLGL_EXPORT const char* ToString(const ShadingLanguage t)
case T::HLSL_4_1: return "HLSL 4.1";
case T::HLSL_5_0: return "HLSL 5.0";
case T::HLSL_5_1: return "HLSL 5.1";
case T::HLSL_6_0: return "HLSL 6.0";
case T::HLSL_6_1: return "HLSL 6.1";
case T::HLSL_6_2: return "HLSL 6.2";
case T::HLSL_6_3: return "HLSL 6.3";
case T::HLSL_6_4: return "HLSL 6.4";

case T::Metal: return "Metal";
case T::Metal_1_0: return "Metal 1.0";
case T::Metal_1_1: return "Metal 1.1";
case T::Metal_1_2: return "Metal 1.2";
case T::Metal_2_0: return "Metal 2.0";
case T::Metal_2_1: return "Metal 2.1";

case T::SPIRV: return "SPIR-V";
case T::SPIRV_100: return "SPIR-V 1.00";
Expand All @@ -111,13 +118,13 @@ LLGL_EXPORT const char* ToString(const ShadingLanguage t)
return nullptr;
}

LLGL_EXPORT const char* ToString(const Format t)
LLGL_EXPORT const char* ToString(const Format val)
{
using T = Format;

switch (t)
switch (val)
{
case T::Undefined: return "<undefined>";
case T::Undefined: return "Undefined";

/* --- Alpha channel color formats --- */
case T::A8UNorm: return "A8UNorm";
Expand Down Expand Up @@ -231,10 +238,10 @@ LLGL_EXPORT const char* ToString(const Format t)
return nullptr;
}

LLGL_EXPORT const char* ToString(const TextureType t)
LLGL_EXPORT const char* ToString(const TextureType val)
{
using T = TextureType;
switch (t)
switch (val)
{
case T::Texture1D: return "Texture1D";
case T::Texture2D: return "Texture2D";
Expand All @@ -249,10 +256,10 @@ LLGL_EXPORT const char* ToString(const TextureType t)
return nullptr;
}

LLGL_EXPORT const char* ToString(const BlendOp t)
LLGL_EXPORT const char* ToString(const BlendOp val)
{
using T = BlendOp;
switch (t)
switch (val)
{
case T::Zero: return "Zero";
case T::One: return "One";
Expand All @@ -275,10 +282,10 @@ LLGL_EXPORT const char* ToString(const BlendOp t)
return nullptr;
}

LLGL_EXPORT const char* ToString(const ResourceType t)
LLGL_EXPORT const char* ToString(const ResourceType val)
{
using T = ResourceType;
switch (t)
switch (val)
{
case T::Undefined: return "undefined";
case T::Buffer: return "buffer";
Expand Down

0 comments on commit ff66aa9

Please sign in to comment.