PrevUpHomeNext

Enumerations

oglplus/enumerations.hpp

OGLplus defines many enumeration types grouping together GL constants that logically belong together. The strong typing on the enumerations also prevents in many cases errors like passing invalid constant to a GL function since the OGLplus function wrappers use appropriate enumeration types for parameters instead of the generic GLenum type.

[Note] Note

Many of the GL constant values used in the enumerations are only available in specific GL versions or with certain GL extensions. If the underlying GL constant is not defined when the enumeration definition is processed then the corresponding value is not present in the enumeration.

Functions

For (almost) all enumeration types the following functions are overloaded.

template <typename Enumeration>
Range<Enumeration> EnumValueRange(void); 1

template <typename Enumeration>
StrCRef EnumValueName(Enumeration enum_value); 2

1

Returns a Range of values in a OGLplus enum value. This template function is overloaded for the enumerated types defined by OGLplus and returns a Range which allows to traverse all values of a particular Enumeration type. The result of this function is influenced by the OGLPLUS_NO_ENUM_VALUE_RANGES preprocessor-symbol. If it is set to a nonzero value then EnumValueRange<Enum>() returns an empty range.

2

Returns the name of the GL enumerated value for an OGLplus enum value. This function is overloaded for the enumerated types defined by OGLplus and returns the GL constant name (without the "GL_" prefix) as managed const string reference. The result of this function is influenced by the OGLPLUS_NO_ENUM_VALUE_NAMES preprocessor-symbol. If it is set to a nonzero value then EnumValueName(enum_value) returns an empty string.

Enum arrays

The EnumArray template class is used by several functions as the parameter type and allows to pass an array of multiple enumerated values to be passed as an argument.

[Note] Note

The lifetime of an instance of EnumArray must not exceed the lifetime of the original array of Enums from which the EnumArray was initialized.

template <typename Enum>
class EnumArray
{
public:
	template <std::size_t N>
	EnumArray(const Enum (&enums)[N]);
	EnumArray(const std::vector<Enum>& enums);
	EnumArray(size_t count, const Enum* enums);
};

OneOf

The OneOf template class is used to merge several enumeration types into a single type. Instances of OneOf can be implicitly constructed from a value from any of the merged enumeration types. OneOf is mostly used as the parameter type in functions that can accept values from multiple different enumerations.

[Note] Note

The following definition is just a pseudo-code used for documentation purposes and differs from the actual implementation of OneOf in certain aspects. OneOf should not be used in library client code directly, the only supported operation is construction from an enumeration value.

template <typename ... Enum>
class OneOf
{
public:
	OneOf(Enum)...; 1
};

1

(Pseudocode) - OneOf has a constructor for each enumeration type passed in the template argument pack.


PrevUpHomeNext