Kaynağa Gözat

gpu: switch some types to enum classes to check C++11 support.

undefined
Sam Hocevar 10 yıl önce
ebeveyn
işleme
3c8ef15f0e
2 değiştirilmiş dosya ile 78 ekleme ve 133 silme
  1. +7
    -8
      src/gpu/renderer.cpp
  2. +71
    -125
      src/lol/gpu/renderer.h

+ 7
- 8
src/gpu/renderer.cpp Dosyayı Görüntüle

@@ -436,10 +436,10 @@ void Renderer::SetBlendEquation(BlendEquation rgb, BlendEquation alpha)
s1[i] = D3DBLENDOP_SUBTRACT; break;
case BlendEquation::ReverseSubtract:
s1[i] = D3DBLENDOP_REVSUBTRACT; break;
case BlendEquation::Max:
s1[i] = D3DBLENDOP_MAX; break;
case BlendEquation::Min:
s1[i] = D3DBLENDOP_MIN; break;
case BlendEquation::Max:
s1[i] = D3DBLENDOP_MAX; break;
}
}

@@ -459,17 +459,16 @@ void Renderer::SetBlendEquation(BlendEquation rgb, BlendEquation alpha)
s1[i] = GL_FUNC_SUBTRACT; break;
case BlendEquation::ReverseSubtract:
s1[i] = GL_FUNC_REVERSE_SUBTRACT; break;
#if defined GL_MIN && defined GL_MAX
case BlendEquation::Min:
s1[i] = GL_MIN; break;
case BlendEquation::Max:
#if defined GL_MAX
s1[i] = GL_MAX; break;
#else
s1[i] = GL_MAX_EXT; break;
#endif
case BlendEquation::Min:
#if defined GL_MIN
s1[i] = GL_MIN; break;
#else
s1[i] = GL_MIN_EXT; break;
case BlendEquation::Max:
s1[i] = GL_MAX_EXT; break;
#endif
}
}


+ 71
- 125
src/lol/gpu/renderer.h Dosyayı Görüntüle

@@ -22,160 +22,106 @@ namespace lol
class RendererData;

/* A list of bitmasks to clear a render buffer. */
struct ClearMask
enum class ClearMask : uint8_t
{
enum Value
{
/* Note: D3D9 doesn't appear to support the accumulation buffer,
* and it is a deprecated OpenGL feature. No reason to support it. */
Color = 1 << 0,
Depth = 1 << 1,
Stencil = 1 << 2,

All = 0xffffffff
}
m_value;

inline ClearMask(Value v) : m_value(v) {}
inline ClearMask(uint64_t i) : m_value((Value)i) {}
inline operator Value() { return m_value; }
/* Note: D3D9 doesn't appear to support the accumulation buffer,
* and it is a deprecated OpenGL feature. No reason to support it. */
Color = 1 << 0,
Depth = 1 << 1,
Stencil = 1 << 2,

All = 0xff,
};

static inline ClearMask operator |(ClearMask const &a, ClearMask const &b)
{
return ClearMask((uint8_t)a | (uint8_t)b);
}

static inline bool operator &(ClearMask const &a, ClearMask const &b)
{
return (bool)((uint8_t)a & (uint8_t)b);
}

/* A safe enum to indicate the blend equation. */
struct BlendEquation
enum class BlendEquation : uint8_t
{
enum Value
{
Add,
Subtract,
ReverseSubtract,
Min,
Max,
}
m_value;

inline BlendEquation() : m_value(Add) {}
inline BlendEquation(Value v) : m_value(v) {}
inline operator Value() { return m_value; }
Add,
Subtract,
ReverseSubtract,
Min,
Max,
};

/* A safe enum to indicate the blending factors. */
struct BlendFunc
enum class BlendFunc : uint8_t
{
enum Value
{
Disabled,
Zero,
One,
SrcColor,
OneMinusSrcColor,
DstColor,
OneMinusDstColor,
SrcAlpha,
OneMinusSrcAlpha,
DstAlpha,
OneMinusDstAlpha,
ConstantColor,
OneMinusConstantColor,
ConstantAlpha,
OneMinusConstantAlpha,
}
m_value;

inline BlendFunc() : m_value(Zero) {}
inline BlendFunc(Value v) : m_value(v) {}
inline operator Value() { return m_value; }
Disabled,
Zero,
One,
SrcColor,
OneMinusSrcColor,
DstColor,
OneMinusDstColor,
SrcAlpha,
OneMinusSrcAlpha,
DstAlpha,
OneMinusDstAlpha,
ConstantColor,
OneMinusConstantColor,
ConstantAlpha,
OneMinusConstantAlpha,
};

/* A safe enum to indicate the face culling mode. */
struct CullMode
enum class CullMode : uint8_t
{
enum Value
{
Disabled,
Clockwise,
CounterClockwise,
}
m_value;

inline CullMode() : m_value(Disabled) {}
inline CullMode(Value v) : m_value(v) {}
inline operator Value() { return m_value; }
Disabled,
Clockwise,
CounterClockwise,
};

/* A safe enum to indicate the polygon mode. */
struct PolygonMode
enum class PolygonMode : uint8_t
{
enum Value
{
Fill,
Line,
Point,
}
m_value;

inline PolygonMode() : m_value(Fill) {}
inline PolygonMode(Value v) : m_value(v) {}
inline operator Value() { return m_value; }
Fill,
Line,
Point,
};

/* A safe enum to indicate the depth test mode. */
struct DepthFunc
enum class DepthFunc : uint8_t
{
enum Value
{
Disabled,
Never,
Less,
Equal,
LessOrEqual,
Greater,
NotEqual,
GreaterOrEqual,
Always,
}
m_value;

inline DepthFunc() : m_value(Disabled) {}
inline DepthFunc(Value v) : m_value(v) {}
inline operator Value() { return m_value; }
Disabled,
Never,
Less,
Equal,
LessOrEqual,
Greater,
NotEqual,
GreaterOrEqual,
Always,
};

/* A safe enum to indicate the depth mask. */
struct DepthMask
enum class DepthMask : uint8_t
{
enum Value
{
Disabled,
Enabled,
}
m_value;

inline DepthMask() : m_value(Disabled) {}
inline DepthMask(Value v) : m_value(v) {}
inline operator Value() { return m_value; }
Disabled,
Enabled,
};

/* A safe enum to indicate the alpha test mode. */
struct AlphaFunc
enum class AlphaFunc : uint8_t
{
enum Value
{
Disabled,
Never,
Less,
Equal,
LessOrEqual,
Greater,
NotEqual,
GreaterOrEqual,
Always,
}
m_value;

inline AlphaFunc() : m_value(Disabled) {}
inline AlphaFunc(Value v) : m_value(v) {}
inline operator Value() { return m_value; }
Disabled,
Never,
Less,
Equal,
LessOrEqual,
Greater,
NotEqual,
GreaterOrEqual,
Always,
};

class Renderer


Yükleniyor…
İptal
Kaydet