OGLplus defines a wrapper for boolean values represented in OpenGL, OpenAL, etc. by integer types with wider than one-bit range.
Instances of this type are implicitly constructible from and convertible
to bool
values and also explicitly constructible from
values of the underlying type (like GLint
, ALint
,
EGLBoolean
, etc.) Instances of Boolean
can be in three states: true
, false
and indeterminate, (i.e. both
the operator bool
and operator !
can return false
for some instances).
template <typename B, typename T, T TrueValue, T FalseValue> struct WeakBoolImpl { public: operator bool (void) const noexcept; bool operator ! (void) const; noexcept; }; template <typename B, typename T, T TrueValue, T FalseValue> struct BoolImpl { public: BoolImpl(void) noexcept; BoolImpl(bool bool_value) noexcept; BoolImpl(T value, std::nothrow_t); noexcept; explicit BoolImpl(T value); operator bool (void) const noexcept; bool operator ! (void) const; noexcept; WeakBoolImpl<T, TrueValue, FalseValue> operator ~ (void) const noexcept; };
Returns |
|
Returns |
|
Creates a false boolean value. |
|
Constructs a boolean from a value in the underlying type. This version
does not throw if the |
|
Constructs a boolean from a value in the underlying type. This constructor
throws a |
|
Returns |
|
Returns |
typedef BoolImpl<GLboolean, GLint, GL_TRUE, GL_FALSE> Boolean;
Context gl; if(gl.IsEnabled(Capability::DepthTest)) { /* ... */ } if(!gl.IsEnabled(Capability::StencilTest)) { /* ... */ } if(~gl.IsEnabled(Capability::DepthTest)) { /* ... */ } if(!~gl.IsEnabled(Capability::StencilTest)) { /* ... */ }