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.


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


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.


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.

For example:

Context gl;

Bitfield<ContextProfileBit> cpm = gl.ProfileMask(); 1

for(auto r=EnumValueRange<ContextProfileBit>(); !r.Empty(); r.Next()) 2
	auto bit = r.Front(); 3

	std::cout << EnumValueName(bit).c_str() << ": "; 4

	std::cout << (cpm.Has(bit)?"true":"false") << std::endl; 5


Query the profile mask for the current GL context.


Get a range enumerating all individual bits in the ContextProfileBit enumeration.


For each individual bit in the enumeration.


Prints the bit's name.


Print whether the bit is set in the mask.

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
	template <std::size_t N>
	EnumArray(const Enum (&enums)[N]);
	EnumArray(const std::vector<Enum>& enums);
	EnumArray(size_t count, const Enum* enums);


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
	OneOf(Enum)...; 1


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

For example:

typedef OneOf<
> Attachment;

Attachment a1 = FramebufferAttachment::Depth;
Attachment a2 = FramebufferColorAttachment::_0;


Specializations of the EnumToClass template for various enumerations can be used to create classes which have member variables with the same names as are the names of the values in the enumeration. The type of the member variables is defined by the Transform template which takes values of the specified Enumeration as an argument.

namespace enums {

template <
	typename Base,
	typename Enumeration,
	template <Enumeration> class Transform
> class EnumToClass
	EnumToClass(const EnumToClass&);

	/* ... */

} // namespace enums

For example for a SomeEnum enumeration:

enum class SomeEnum

with the following transformation template:

template <SomeEnum Value>
class SomeEnumTransform
	SomeEnumTransform(void); 1


One of these constructors must be implemented.

the following instantiation of EnumToClass

typedef EnumToClass<Base, SomeEnum, SomeEnumTransform> EnumToClassSomeEnumTransform;

results in a class which is equivalent to:

class EnumToClassSomeEnumTransform
 : public Base
	SomeEnumTransform<SomeEnum::ValueA> ValueA;
	SomeEnumTransform<SomeEnum::ValueB> ValueB;
	SomeEnumTransform<SomeEnum::ValueC> ValueC;
	SomeEnumTransform<SomeEnum::ValueD> ValueD;