PrevUpHomeNext

Capabilities

#include <oglplus/capability.hpp>

Capability

This enumeration lists GL capabilities i.e. features that can be enabled, disabled or queried by the Enable, Disable and IsEnabled member functions of the Context class.

enum class Capability : GLenum
{
	PrimitiveRestart        = GL_PRIMITIVE_RESTART,
	DepthTest               = GL_DEPTH_TEST,
	StencilTest             = GL_STENCIL_TEST,
	ScissorTest             = GL_SCISSOR_TEST,
	CullFace                = GL_CULL_FACE,
	RasterizerDiscard       = GL_RASTERIZER_DISCARD,
	PolygonOffsetPoint      = GL_POLYGON_OFFSET_POINT,
	PolygonOffsetLine       = GL_POLYGON_OFFSET_LINE,
	PolygonOffsetFill       = GL_POLYGON_OFFSET_FILL,
	Blend                   = GL_BLEND,
	ColorLogicOp            = GL_COLOR_LOGIC_OP,
	Dither                  = GL_DITHER,
	Multisample             = GL_MULTISAMPLE,
	SampleShading           = GL_SAMPLE_SHADING,
	LineSmooth              = GL_LINE_SMOOTH,
	PolygonSmooth           = GL_POLYGON_SMOOTH,
	ProgramPointSize        = GL_PROGRAM_POINT_SIZE,
	TextureCubeMapSeamless  = GL_TEXTURE_CUBE_MAP_SEAMLESS,
	SampleAlphaToCoverage   = GL_SAMPLE_ALPHA_TO_COVERAGE,
	SampleAlphaToOne        = GL_SAMPLE_ALPHA_TO_ONE,
	SampleCoverage          = GL_SAMPLE_COVERAGE,
	SampleMask              = GL_SAMPLE_MASK,
	FramebufferSRGB         = GL_FRAMEBUFFER_SRGB,
	DebugOutputSynchronous  = GL_DEBUG_OUTPUT_SYNCHRONOUS,
	StreamRasterization     = GL_STREAM_RASTERIZATION_AMD,
	BlendAdvancedCoherent   = GL_BLEND_ADVANCED_COHERENT_KHR,
	FragmentCoverageToColor = GL_FRAGMENT_COVERAGE_TO_COLOR_NV
};

template <>
Range<Capability> EnumValueRange<Capability>(void);

StrCRef EnumValueName(Capability);

For example:

Context gl;

gl.Enable(Capability::DepthTest);
gl.Disable(Capability::CullFace);

gl.Enable(Functionality::ClipDistance, 0);
gl.Disable(Functionality::ClipDistance, 1);

Capability to class

#if !OGLPLUS_NO_ENUM_VALUE_CLASSES
namespace enums {

template <typename Base, template<Capability> class Transform>
class EnumToClass<Base, Capability, Transform> 1
 : public Base
{
public:
	EnumToClass(void);
	EnumToClass(Base&& base);

	Transform<Capability::PrimitiveRestart>
		PrimitiveRestart;
	Transform<Capability::DepthTest>
		DepthTest;
	Transform<Capability::StencilTest>
		StencilTest;
	Transform<Capability::ScissorTest>
		ScissorTest;
	Transform<Capability::CullFace>
		CullFace;
	Transform<Capability::RasterizerDiscard>
		RasterizerDiscard;
	Transform<Capability::PolygonOffsetPoint>
		PolygonOffsetPoint;
	Transform<Capability::PolygonOffsetLine>
		PolygonOffsetLine;
	Transform<Capability::PolygonOffsetFill>
		PolygonOffsetFill;
	Transform<Capability::Blend>
		Blend;
	Transform<Capability::ColorLogicOp>
		ColorLogicOp;
	Transform<Capability::Dither>
		Dither;
	Transform<Capability::Multisample>
		Multisample;
	Transform<Capability::SampleShading>
		SampleShading;
	Transform<Capability::LineSmooth>
		LineSmooth;
	Transform<Capability::PolygonSmooth>
		PolygonSmooth;
	Transform<Capability::ProgramPointSize>
		ProgramPointSize;
	Transform<Capability::TextureCubeMapSeamless>
		TextureCubeMapSeamless;
	Transform<Capability::SampleAlphaToCoverage>
		SampleAlphaToCoverage;
	Transform<Capability::SampleAlphaToOne>
		SampleAlphaToOne;
	Transform<Capability::SampleCoverage>
		SampleCoverage;
	Transform<Capability::SampleMask>
		SampleMask;
	Transform<Capability::FramebufferSRGB>
		FramebufferSRGB;
	Transform<Capability::DebugOutputSynchronous>
		DebugOutputSynchronous;
	Transform<Capability::StreamRasterization>
		StreamRasterization;
	Transform<Capability::BlendAdvancedCoherent>
		BlendAdvancedCoherent;
	Transform<Capability::FragmentCoverageToColor>
		FragmentCoverageToColor;
};

} // namespace enums
#endif

1

Specialization of EnumToClass for the Capability enumeration.

Functionality

Functionalities are similar to capabilities in that they can be enabled, disabled or queried by the Enable, Disable and IsEnabled member functions of the Context class.

The difference between them is that functionalities have multiple 0-based-indexed 'slots' that can be enabled or disabled. One example of a Functionality is ClipDistance where the i-th 'slot' enables the i-th clipping plane.

enum class Functionality : GLenum
{
	ClipDistance = GL_CLIP_DISTANCE0
};

template <>
Range<Functionality> EnumValueRange<Functionality>(void);

StrCRef EnumValueName(Functionality);

Syntax sugar

The Capability and Functionality enumerations have several syntax-sugar operators allowing less verbose use.

void operator << (Capability capability, bool enable); 1
void operator + (Capability capability); 2
void operator - (Capability capability); 3

struct FunctionalityAndNumber { }; 4

FunctionalityAndNumber operator | (Functionality func, GLuint number); 5

void operator << (FunctionalityAndNumber func_and_num, bool enable); 6
void operator + (FunctionalityAndNumber func_and_num); 7
void operator - (FunctionalityAndNumber func_and_num); 8

1

Enables or disables the specified capability.

2

Enables the specified capability.

3

Disables the specified capability.

4

An opaque helper type used by the Functionality operators below.

5

Creates an instance of FunctionalityAndNumber.

6

Enables or disables the specified functionality.

7

Enables the specified functionality.

8

Disables the specified functionality.

For example:

Capability::DepthTest << true; 1
Capability::StencilTest << false; 2

+Capability::CullFace; 3
-Capability::Blend; 4

for(int i=0; i<4; ++i)
{
	(Functionality::ClipDistance | i) << true; 5
}

1

Enables depth test.

2

Disables stencil test.

3

Enables face culling.

4

Disables blending.

5

Enables the ith clipping plane.


PrevUpHomeNext