PrevUpHomeNext

Current GL context

Errors
Capabilities
Clip control
Viewport operations
Buffer selection
Buffer masking
Buffer clearing
Rasterization
Drawing
Computing
Depth test
Stencil test
Scissor test
Logic operations
Pixel operations
Blending operations
Synchronization
Hints
Limit queries
Numeric queries
String queries
Object binding
Object DSA
Helper classes

This section describes classes and functions wrapping operations on the current OpenGL context, which are not related to any explicitly allocated object or resource, i.e. operations like enabling and disabling various OpenGL capabilities and changing the state values of the current context.

Context

#include <oglplus/context.hpp>

Context is a stateless class wrapping all current GL context operations. The actual functionality is implemented by subclasses in the context namespace, but the library end-users should rarely need to use them directly.

class Context
 : public context::Errors
 , public context::Capabilities
 , public context::ClipControlState
 , public context::ViewportState
 , public context::ViewportOps
 , public context::BufferSelection
 , public context::BufferMaskingState
 , public context::BufferClearingState
 , public context::BufferClearingOps
 , public context::RasterizationState
 , public context::RasterizationOps
 , public context::DrawingState
 , public context::DrawingOps
 , public context::ComputingOps
 , public context::DepthTest
 , public context::StencilTest
 , public context::ScissorTest
 , public context::LogicOpState
 , public context::PixelState
 , public context::PixelOps
 , public context::BlendingOps
 , public context::BlendingState
 , public context::Synchronization
 , public context::Hints
 , public context::LimitQueries
 , public context::NumericQueries
 , public context::StringQueries
 , public context::ObjectBinding
 , public context::ObjectDSA
{ };

Examples of usage

Context gl; 1

std::cout << "Vendor: " << gl.Vendor() << std::endl;
std::cout << "Version: " << gl.Version() << std::endl;
std::cout << "Major version: " << gl.MajorVersion() << std::endl;
std::cout << "Minor version: " << gl.MinorVersion() << std::endl;
std::cout << "GLSL Version: " << gl.ShadingLanguageVersion() << std::endl;
std::cout << "Renderer: " << gl.Renderer() << std::endl;
std::cout << "Extensions:" << std::endl;

for(auto r=gl.Extensions(); !r.Empty(); r.Next())
{
	std::cout << '\t' << r.Front() << std::endl;
}

std::cout << "Limits:" << std::endl;

for(auto r=EnumValueRange<LimitQuery>(); !r.Empty(); r.Next())
{
	auto ev = r.Front();
	std::cout << EnumValueName(ev).c_str() << ": ";
	try { std::cout << gl.FloatLimit(ev); }
	catch(...){ std::cout << "N/A"; }
	std::cout << std::endl;
}


gl.ClearColor(0.3f, 0.3f, 0.3f, 0.0f);
gl.ClearDepth(1.0f);
gl.Disable(Capability::DepthTest);
gl.Enable(Capability::Blend);
gl.BlendFunc(BlendFunction::SrcAlpha, BlendFunction::OneMinusSrcAlpha);

gl.LineWidth(1.5f);

gl.Viewport(800, 600);

gl.Clear().ColorBuffer().DepthBuffer().StencilBuffer();

Program prog;
VertexArray vao;

/* ... */

gl.Use(prog);
gl.Bind(vao);

gl.DrawArrays(PrimitiveType::TriangleStrip, 0, n);

gl.DrawElements(PrimitiveType::TriangleStrip, m, DataType::UnsignedInt);

1

Stateless wrapper for the current GL context operations.

#include <oglplus/context/errors.hpp>

namespace context {

class Errors
{
public:
	static ErrorCode GetError(void); 1
};

} // namespace context

1

Returns the currently set ErrorCode. See glGetError.

#include <oglplus/context/capabilities.hpp>

namespace context {

class Capabilities
{
public:
	static void Enable(Capability capability); 1
	static void Enable(Functionality functionality, GLuint number); 2

	static void Disable(Capability capability); 3
	static void Disable(Functionality functionality, GLuint number); 4

	static Boolean IsEnabled(Capability capability); 5
	static Boolean IsEnabled(Functionality functionality, GLuint number); 6

#if GL_VERSION_3_0
	static void Enable(Capability capability, GLuint index); 7
	static void Disable(Capability capability, GLuint index); 8
	static Boolean IsEnabled(Capability capability, GLuint index); 9
#endif
};

} // namespace context

1

Enables the specified capability. See glEnable.

2

Enables the specified functionality. See glEnable.

3

Disables the specified capability. See glDisable.

4

Disables the specified functionality. See glDisable.

5

Checks is the specified capability is enabled. See glIsEnabled.

6

Checks is the specified functionality is enabled. See glIsEnabled.

7

Enables the specified capability on an indexed target. See glEnablei.

8

Disables the specified capability on an indexed target. See glDisablei.

9

Checks if the specified capability is enabled on an indexed target. See glIsEnabledi.

#include <oglplus/context/clip_control.hpp>

Parameters
namespace context {

struct ClipControlParams
{
	ClipControlParams(void)
	noexcept;

	ClipControlParams(ClipOrigin origin, ClipDepthMode depth)
	noexcept;

	ClipOrigin Origin(void) const
	noexcept;

	ClipDepthMode DepthMode(void) const
	noexcept;
};
State
class ClipControlState
{
public:
#if GL_VERSION_4_5 || GL_ARB_clip_control
	static void ClipControl(ClipOrigin origin, ClipDepthMode depth); 1

	static ClipOrigin ClipOrigin(void); 2

	static ClipDepthMode ClipDepthMode(void); 3

	static
	void ClipControl(const context::ClipControlParams& params); 4

	static context::ClipControlParams ClipControl(void); 5
#endif

};

} // namespace context

1

Sets the clipping mode. See glClipControl.

2

Queries the current clip origin setting. See glGet, GL_CLIP_ORIGIN.

3

Queries the current clip depth mode setting. See glGet, GL_CLIP_DEPTH_MODE.

4

Sets the clipping control parameters.

5

Returns the clipping control parameters.

#include <oglplus/context/viewport.hpp>

Helper classes
namespace context {

struct ViewportPosition 1
{
	GLfloat X(void) const
	noexcept;

	GLfloat Y(void) const
	noexcept;
};

struct ViewportSize 2
{
	GLfloat Width(void) const
	noexcept;

	GLfloat Height(void) const
	noexcept;
};

struct ViewportExtents 3
{
	GLfloat X(void) const
	noexcept;

	GLfloat Y(void) const
	noexcept;

	GLfloat Width(void) const
	noexcept;

	GLfloat Height(void) const
	noexcept;
};

struct BoundsRange 4
{
	GLfloat Min(void) const
	noexcept;

	GLfloat Max(void) const
	noexcept;
};

struct ViewportDepthRange 5
{
	GLfloat Near(void) const
	noexcept;

	GLfloat Far(void) const
	noexcept;
};

1

Helper structure storing position in a 2D viewport.

2

Helper structure storing the dimensions of a 2D viewport.

3

Helper structure storing the extents of a 2D viewport.

4

Helper structure storing the min/max bounds range.

5

Helper structure storing the near/far depth range.

State
class ViewportState
{
public:
	static void Viewport(GLint x, GLint y, SizeType w, SizeType h); 1
	static void Viewport(SizeType w, SizeType h); 2
	static void Viewport(const context::ViewportExtents& vp);

	static context::ViewportExtents Viewport(void); 3

	static void DepthRange(GLclampf near, GLclampf far); 4
	static void DepthRange(const context::ViewportDepthRange&);

	static context::ViewportDepthRange DepthRange(void); 5

#if GL_VERSION_4_1 || GL_ARB_viewport_array
	static void Viewport(
		ViewportIndex viewport,
		const GLfloat* extents
	); 6
	static void Viewport(
		ViewportIndex viewport,
		GLfloat x,
		GLfloat y,
		GLfloat width,
		GLfloat height
	); 7
	static void Viewport(
		ViewportIndex viewport,
		const context::ViewportExtents&
	);

	static void ViewportArray(
		GLuint first,
		SizeType count,
		const GLfloat* extents
	); 8

	static context::ViewportExtents Viewport(ViewportIndex viewport); 9

	static void DepthRange(
		ViewportIndex viewport,
		GLclampd near,
		GLclampd far
	); 10
	static void DepthRange(
		ViewportIndex viewport,
		const context::ViewportDepthRange&
	);

	static void DepthRangeArray(GLuint first, SizeType count, const GLclampd *v); 11

	static context::ViewportDepthRange DepthRange(ViewportIndex viewport); 12
#endif
};

1

Sets the extents of the current viewport. See glViewport.

2

Sets the size of the current viewport starting at (0,0). See glViewport.

3

Returns the extents of the current viewport. See glGet, GL_VIEWPORT.

4

Sets the near / far depth range values of the default viewport. See glDepthRangeIndexed.

5

Returns the depth range values of the current viewport. See glGet, GL_DEPTH_RANGE.

6

Sets the extents of the specified viewport. See glViewportIndexedfv.

7

Sets the extents of the specified viewport. See glViewportIndexedf.

8

Sets extents of the viewports specified by first and count. See glViewportIndexedfv.

9

Returns the extents of the specified viewport. See glGet, GL_VIEWPORT.

10

Sets the near / far depth range values of the default viewport. See glDepthRangeIndexed.

11

Sets depth ranges of viewports specified by first and count. See glDepthRangeArray.

12

Returns the depth range of the specified viewport. See glGet, GL_DEPTH_RANGE.

Operations
class ViewportOps
{
public:
	static ViewportSize MaxViewportDims(void); 1


#if GL_VERSION_4_1 || GL_ARB_viewport_array
	static GLuint MaxViewports(void); 2

	static BoundsRange ViewportBoundsRange(void); 3
#endif

};

} // namespace context

1

Returns the implementation-dependent maximum viewport dimensions. See glGet, GL_MAX_VIEWPORT_DIMS.

2

Returns the number of available viewports. See glGet, GL_MAX_VIEWPORTS.

3

Returns the implementation-dependent viewport bounds range. See glGet, GL_VIEWPORT_BOUNDS_RANGE.

#include <oglplus/context/buffer_selection.hpp>

namespace context {

class BufferSelection
{
public:
	typedef OneOf<
		oglplus::ColorBuffer,
		oglplus::FramebufferColorAttachment
	> ColorBuffer; 1

	static void DrawBuffer(ColorBuffer buffer); 2
	static void DrawBuffers(const EnumArray<ColorBuffer>& buffers); 3
	static void DrawBuffers(SizeType count, const ColorBuffer* buffers);

	static void ReadBuffer(ColorBuffer buffer); 4
};

} // namespace context

1

Color buffer specification type.

2

Sets the destination color buffer for draw operations. See glDrawBuffer.

3

Sets the destination color buffers for draw operations. See glDrawBuffers.

4

Sets the source color buffer for read operations. See glReadBuffer.

#include <oglplus/context/buffer_masking.hpp>

State
namespace context {

class BufferMaskingState
{
public:
	static void ColorMask(
		Boolean r,
		Boolean g,
		Boolean b,
		Boolean a
	); 1
	static void ColorMask(const context::RGBAMask&);
	static context::RGBAMask ColorWriteMask(void); 2

#if GL_VERSION_3_0
	static void ColorMask(
		DrawBufferIndex buffer,
		Boolean r,
		Boolean g,
		Boolean b,
		Boolean a
	); 3
	static void ColorMask(DrawBufferIndex buffer, const context::RGBAMask&);
	static context::RGBAMask ColorWriteMask(DrawBufferIndex buffer); 4
#endif

	static void DepthMask(Boolean mask); 5
	static Boolean DepthWriteMask(void); 6

	static void StencilMask(GLuint mask); 7
	static void StencilMaskSeparate(Face face, GLuint mask); 8
	static void StencilMaskSeparateSingle(SingleFace face, GLuint mask);

	static GLuint StencilWriteMask(bool backface = false); 9
	static GLuint StencilWriteMask(Face face);
	static GLuint StencilWriteMaskSingle(SingleFace face);
};

} // namespace context

1

Sets the color mask for the default color buffer. See glColorMask.

2

Returns the value of color buffer write mask. See glGet, GL_COLOR_WRITEMASK.

3

Sets the color mask for the specified color buffer. See glColorMaski.

4

Returns the value of color buffer write mask. See glGet, GL_COLOR_WRITEMASK.

5

Sets the depth buffer mask. See glDepthMask.

6

Returns the value of depth buffer write mask. See glGet, GL_DEPTH_WRITEMASK.

7

Sets the stencil buffer mask; See glStencilMask.

8

Sets the stencil mask separately for front and back faces. See glStencilMaskSeparate.

9

Returns the value of stencil buffer write mask. See glGet, GL_STENCIL_WRITEMASK and GL_STENCIL_BACK_WRITEMASK.

#include <oglplus/context/buffer_clearing.hpp>

Helper classes
typedef BufferSelectBit ClearBit;

namespace context {

class ClrBits 1
{
public:
	ClrBits ColorBuffer(void); 2
	ClrBits DepthBuffer(void); 3
	ClrBits StencilBuffer(void); 4

	~ClrBits(void); 5
};

1

Helper class used by __context_BufferClearing::Clear(). Instances of this class cause the write buffers to be cleared depending on which member functions were called during the life-time of the instance. The actual call to glClear is done in the destructor.

2

Calling this member function causes the color buffer to be marked for clearing. See GL_COLOR_BUFFER_BIT.

3

Calling this member function causes the depth buffer to be marked for clearing. See GL_DEPTH_BUFFER_BIT.

4

Calling this member function causes the stencil buffer to be marked for clearing. See GL_STENCIL_BUFFER_BIT.

5

The destructor does the actual clearing of the buffers. See glClear.

The BufferClearing class is a wrapper for the operations, which are used to clear the draw buffers.

State
class BufferClearingState
{
public:
	static void ClearColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a); 1
	static void ClearColor(const context::RGBAValue&);
	static context::RGBAValue ColorClearValue(void); 2

	static void ClearDepth(GLclampd d); 3
	static GLfloat DepthClearValue(void); 4

	static void ClearStencil(GLint s); 5
	static GLint ClearStencilValue(void);  6
};

1

Sets the clear color components. See glClearColor.

2

Returns the value used for clearing of the color buffer. See glGen, GL_COLOR_CLEAR_VALUE.

3

Sets the clear depth value. See glClearDepth.

4

Returns the value used for clearing of the depth buffer. See glGen, GL_DEPTH_CLEAR_VALUE.

5

Sets the clear stencil buffer value. See glClearStencil.

6

Returns the value used for clearing of the depth buffer. See glGen, GL_STENCIL_CLEAR_VALUE.

Operations
class BufferClearingOps
{
public:
	static void Clear(Bitfield<ClearBit> bits); 1
	static ClrBits Clear(void); 2

	static void ClearColorBuffer(GLint draw_buffer, const GLint* value); 3
	static void ClearColorBuffer(GLint draw_buffer, const GLuint* value);
	static void ClearColorBuffer(GLint draw_buffer, const GLfloat* value);

	static void ClearColorBuffer(ColorBuffer buffer, GLint draw_buffer, const GLint* value); 4
	static void ClearColorBuffer(ColorBuffer buffer, GLint draw_buffer, const GLuint* value);
	static void ClearColorBuffer(ColorBuffer buffer, GLint draw_buffer, const GLfloat* value);

	static void ClearDepthBuffer(GLfloat value); 5
	static void ClearStencilBuffer(GLint value); 6
	static void ClearStencilBuffer(GLfloat depth_value, GLint stencil_value); 7
};

} // namespace context

1

Clears buffers specified by the bits parameter.

2

Clears buffers specified by calling functions of the returned object This function returns an object that allows to specify which buffers to clear by calling its ColorBuffer, DepthBuffer and StencilBuffer member functions.

3

Clears the color draw buffer of the currently bound framebuffer with the specified value. See glClearBuffer, GL_GL_COLOR.

4

Clears the specified color draw buffer of the currently bound framebuffer with the specified value.

5

Clears the depth buffer of the currently bound framebuffer with the specified value. See glClearBuffer, GL_GL_DEPTH.

6

Clears the stencil buffer of the currently bound framebuffer with the specified value. See glClearBuffer, GL_GL_STENCIL.

7

Clears the depth and the stencil buffer of the currently bound framebuffer with the specified values. See glClearBuffer, GL_GL_DEPTH_STENCIL.

#include <oglplus/context/rasterization.hpp>

Helper classes
namespace context {

class PolygonModes
{
public:
	PolygonModes(void)
	noexcept;

	PolygonModes(PolygonMode mode)
	noexcept;

	PolygonModes(PolygonMode front, PolygonMode back)
	noexcept;

	PolygonMode Front(void) const
	noexcept;

	PolygonMode Back(void) const
	noexcept;
};

struct PolygonOffsPara
{
	PolygonOffsPara(void)
	noexcept;

	PolygonOffsPara(GLfloat factor, GLfloat units)
	noexcept;

	GLfloat Factor(void) const
	noexcept;

	GLfloat Units(void) const
	noexcept;
};
State
class RasterizationState
{
public:
	static void FrontFace(FaceOrientation orientation); 1
	static FaceOrientation FrontFace(void);

	static void CullFace(Face mode); 2
	static Face CullFaceMode(void);

#if GL_VERSION_3_0
	static void PolygonMode(Face face, PolygonMode mode); 3
	static void PolygonMode(PolygonMode mode); 4
	static void PolygonMode(const context::PolygonModes&);

	static PolygonMode PolygonModeFront(void); 5
	static PolygonMode PolygonModeBack(void);
	static context::PolygonModes PolygonMode(void);
#endif

	static void PolygonOffset(GLfloat factor, GLfloat units); 6
	static void PolygonOffset(const context::PolygonOffsPara&);

	static GLfloat PolygonOffsetFactor(void); 7
	static GLfloat PolygonOffsetUnits(void); 8
	static context::PolygonOffsPara PolygonOffset(void);

	static void LineWidth(GLfloat width); 9

	static GLfloat LineWidth(void); 10

#if GL_VERSION_3_0
	static void PointSize(GLfloat size); 11

	static GLfloat PointSize(void); 12

	static void PointFadeThresholdSize(GLfloat size); 13

	static GLfloat PointFadeThresholdSize(void); 14
#endif

1

Sets the polygon facing mode. See glFrontFace.

2

Sets the face culling mode. See glCullFace.

3

Sets the polygon rasterization mode. See glPolygonMode.

4

Sets the polygon rasterization mode. See glPolygonMode.

5

Returns the face culling mode. See glGet, GL_POLYGON_MODE.

6

Sets the polygon depth offset. See glPolygonOffset.

7

Returns the current polygon offset factor. See glGet, GL_POLYGON_OFFSET_FACTOR.

8

Returns the current polygon offset units. See glGet, GL_POLYGON_OFFSET_UNITS.

9

Sets the line current width. See glLineWidth.

10

Returns the line width. See glGet, GL_LINE_WIDTH.

11

Sets the point size. See glPointSize.

12

Returns the current point size. See glGet, GL_POINT_SIZE.

13

Sets the point fade threshold size. See glPointParameter, GL_POINT_FADE_THRESHOLD_SIZE.

14

Returns the current point fade threshold size. See glGet, GL_POINT_FADE_THRESHOLD_SIZE.

Ops
class RasterizationOps
{
public:
	static GLint SampleBuffers(void); 1

	static GLint Samples(void); 2

#if GL_VERSION_3_2
	static Vec2f SamplePosition(GLuint index); 3
#endif
};

} // namespace context

1

Returns the number of sample buffers. See glGet, GL_SAMPLE_BUFFERS.

2

Returns the number of multisampling samples. See glGet, GL_SAMPLES.

3

Returns the position of the specified multisampling sample. See glGet, GL_SAMPLE_POSITION.

#include <oglplus/context/drawing.hpp>

State
namespace context {

class DrawingState
{
public:
#if GL_VERSION_3_1
	static void PrimitiveRestartIndex(GLuint index); 1
	static GLuint PrimitiveRestartIndex(void);
#endif

#if GL_ARB_tessellation_shader || GL_VERSION_4_0
	static void PatchParameter(
		PatchParameter parameter,
		GLint value
	); 2
#endif
};

1

Sets the primitive restart index. See glPrimitiveRestartIndex.

2

Sets a patch parameter value. See glPatchParameter.

Operations
class DrawingOps
{
public:
	static void DrawArrays(
		PrimitiveType primitive,
		GLint first,
		SizeType count
	); 1

#if GL_VERSION_3_1
	static void DrawArraysInstanced(
		PrimitiveType primitive,
		GLint first,
		SizeType count,
		SizeType inst_count
	); 2
#endif

#if GL_VERSION_4_2
	static void DrawArraysInstancedBaseInstance(
		PrimitiveType primitive,
		GLint first,
		SizeType count,
		SizeType inst_count,
		SizeType base_instance
	); 3
#endif

#if GL_VERSION_4_0 || GL_ARB_draw_indirect
	static void DrawArraysIndirect(
		PrimitiveType primitive,
		const void* indirect = nullptr
	); 4
#endif

#if GL_VERSION_3_0
	static void MultiDrawArrays(
		PrimitiveType primitive,
		const GLint* first,
		const GLsizei* count,
		SizeType primcount
	); 5
#endif

#if GL_VERSION_4_3 || GL_ARB_multi_draw_indirect
	static void MultiDrawArraysIndirect(
		PrimitiveType primitive,
		SizeType draw_count,
		SizeType stride = 0,
		const void* indirect = nullptr
	); 6
#endif

	static void DrawElements(
		PrimitiveType primitive,
		SizeType count,
		DataType data_type
	); 7

	template <typename T>
	static
	void DrawElements(
		PrimitiveType primitive,
		SizeType count,
		const T* indices
	);

	static void DrawElementsInstanced(
		PrimitiveType primitive,
		SizeType count,
		DataType data_type,
		SizeType instance_count
	); 8

1

Draws a range of primitives of the specified type from the bound array buffers. See glDrawArrays.

2

Draws multiple instances of a range of elements. See glDrawArraysInstanced.

3

Draws multiple instances of a range of elements with offset applied to instanced attributes. See glDrawArraysInstancedBaseInstance.

4

Draws primitives from an indirect buffer. See glDrawArraysIndirect.

5

Draws multiple primcount ranges of primitives from the bound array buffers. See glMultiDrawArrays.

6

See glMultiDrawArraysIndirect.

7

See glDrawElements.

8

See glDrawElementsInstanced.

	template <typename T>
	static
	void DrawElementsInstanced(
		PrimitiveType primitive,
		SizeType count,
		const T* indices,
		SizeType instance_count
	);

#if GL_VERSION_4_2
	static void DrawElementsInstancedBaseInstance(
		PrimitiveType primitive,
		SizeType count,
		DataType data_type,
		SizeType inst_count,
		GLuint base_instance
	); 1

	template <typename T>
	static
	void DrawElementsInstancedBaseInstance(
		PrimitiveType primitive,
		SizeType count,
		const T* indices,
		SizeType inst_count,
		GLuint base_instance
	);
#endif

	static void MultiDrawElements(
		PrimitiveType primitive,
		const GLsizei* count,
		DataType data_type,
		SizeType draw_count
	); 2

	template <typename T>
	static
	void MultiDrawElements(
		PrimitiveType primitive,
		const GLsizei* count,
		T* const * indices,
		SizeType draw_count
	);

	static void DrawRangeElements(
		PrimitiveType primitive,
		GLuint start,
		GLuint end,
		SizeType count,
		DataType data_type
	);  3

	template <typename T>
	static
	void DrawRangeElements(
		PrimitiveType primitive,
		GLuint start,
		GLuint end,
		SizeType count,
		const T* indices
	);

#if GL_VERSION_4_0 || GL_ARB_draw_indirect
	static void DrawElementsIndirect(
		PrimitiveType primitive,
		DataType data_type,
		const void* indirect = nullptr
	); 4
#endif

#if GL_VERSION_4_3
	static void MultiDrawElementsIndirect(
		PrimitiveType primitive,
		DataType data_type,
		SizeType draw_count,
		SizeType stride = 0,
		const void* indirect = nullptr
	); 5
#endif

#if GL_VERSION_3_2 || GL_ARB_draw_elements_base_vertex
	static void DrawElementsBaseVertex(
		PrimitiveType primitive,
		SizeType count,
		DataType data_type,
		GLint base_vertex
	); 6

	template <typename T>
	static
	void DrawElementsBaseVertex(
		PrimitiveType primitive,
		SizeType count,
		const T* indices,
		GLint base_vertex
	);

	static void DrawRangeElementsBaseVertex(
		PrimitiveType primitive,
		GLuint start,
		GLuint end,
		SizeType count,
		DataType data_type,
		GLint base_vertex
	); 7

	template <typename T>
	static
	void DrawRangeElementsBaseVertex(
		PrimitiveType primitive,
		GLuint start,
		GLuint end,
		SizeType count,
		const T* indices,
		GLint base_vertex
	);

	static void DrawElementsInstancedBaseVertex(
		PrimitiveType primitive,
		SizeType count,
		DataType data_type,
		SizeType inst_count,
		GLint base_vertex
	); 8

	template <typename T>
	static
	void DrawElementsInstancedBaseVertex(
		PrimitiveType primitive,
		SizeType count,
		const T* indices,
		SizeType inst_count,
		GLint base_vertex
	);

	static void MultiDrawElementsBaseVertex(
		PrimitiveType primitive,
		const GLsizei* count,
		DataType data_type,
		SizeType draw_count,
		const GLint* base_vertex
	); 9

	template <typename T>
	static
	void MultiDrawElementsBaseVertex(
		PrimitiveType primitive,
		const GLsizei* count,
		T* const * indices,
		SizeType draw_count,
		const GLint* base_vertex
	);
#endif

#if GL_VERSION_4_2
	static void DrawElementsInstancedBaseVertexBaseInstance(
		PrimitiveType primitive,
		SizeType count,
		DataType data_type,
		SizeType inst_count,
		GLint base_vertex,
		GLuint base_instance
	); 10

	template <typename T>
	static
	void DrawElementsInstancedBaseVertexBaseInstance(
		PrimitiveType primitive,
		SizeType count,
		const T* indices,
		SizeType inst_count,
		GLint base_vertex,
		GLuint base_instance
	);
#endif

#if GL_VERSION_4_0 || GL_ARB_transform_feedback2
	static void DrawTransformFeedback(
		PrimitiveType primitive,
		TransformFeedbackName xfb
	); 11
#endif

#if GL_NV_draw_texture
	static void DrawTexture(
		TextureName texture,
		SamplerName sampler,
		GLfloat x0,
		GLfloat y0,
		GLfloat x1,
		GLfloat y1,
		GLfloat z,
		GLfloat s0,
		GLfloat t0,
		GLfloat s1,
		GLfloat t1
	); 12
#endif
};

} // namespace context

#include <oglplus/context/computing.hpp>

namespace context {

class ComputingOps
{
public:
#if GL_VERSION_4_3
	static void DispatchCompute(
		GLuint num_groups_x,
		GLuint num_groups_y,
		GLuint num_groups_z
	); 1

	static void DispatchComputeIndirect(GLintptr indirect); 2
#endif
};

} // namespace context

1

Launches the specified number of compute work groups. See glDispatchCompute.

2

Launches indirectly several compute work groups. See glDispatchComputeIndirect.

#include <oglplus/context/depth_test.hpp>

namespace context {

class DepthTest
{
public:
	static void DepthFunc(CompareFunction function); 1
	static CompareFunction DepthFunc(void); 2
};

} // namespace context

1

Sets the depth comparison function. See glDepthFunc.

2

Returns the currently set depth comparison function. See glGet, GL_DEPTH_FUNC.

#include <oglplus/context/stencil_test.hpp>

Stencil function arguments
namespace context {

struct StencilFuncArgs
{
	StencilFuncArgs(void)
	noexcept;

	StencilFuncArgs(
		CompareFunction func,
		GLint refv = GLint(0),
		GLuint mask = ~GLuint(0)
	) noexcept;

	CompareFunction Func(void) const
	noexcept;

	GLint Ref(void) const
	noexcept;

	GLuint ValueMask(void) const
	noexcept;

	friend
	bool operator == (const StencilFuncArgs& a, const StencilFuncArgs& b)
	noexcept;

	friend
	bool operator != (const StencilFuncArgs& a, const StencilFuncArgs& b)
	noexcept;
};
Stencil operations
struct StencilOperations
{
	StencilOperations(void)
	noexcept;

	StencilOperations(
		StencilOperation sfail,
		StencilOperation dfail,
		StencilOperation dpass
	) noexcept;

	StencilOperation StencilFail(void) const
	noexcept;

	StencilOperation DepthFail(void) const
	noexcept;

	StencilOperation DepthPass(void) const
	noexcept;

	friend
	bool operator == (const StencilOperations& a, const StencilOperations& b)
	noexcept;

	friend
	bool operator != (const StencilOperations& a, const StencilOperations& b)
	noexcept;
};
State and operations
class StencilTest
{
public:
	static void StencilFunc(
		CompareFunction function,
		GLint ref = GLint(0),
		GLuint mask = ~GLuint(0)
	); 1
	static void StencilFunc(const StencilFuncArgs& fa);


	static void StencilFuncSeparate(
		Face face,
		CompareFunction function,
		GLint ref = GLint(0),
		GLuint mask = ~GLuint(0)
	); 2
	static void StencilFuncSeparate(
		Face face,
		const StencilFuncArgs& fa
	);
	static void StencilFuncSeparateSingle(
		SingleFace face,
		CompareFunction function,
		GLint ref = GLint(0),
		GLuint mask = ~GLuint(0)
	);
	static void StencilFuncSeparateSingle(
		SingleFace face,
		const StencilFuncArgs& fa
	);

	static void StencilOp(
		StencilOperation sfail,
		StencilOperation dfail,
		StencilOperation dpass
	); 3

	static void StencilOpSeparate(
		Face face,
		StencilOperation sfail,
		StencilOperation dfail,
		StencilOperation dpass
	); 4
	static void StencilOpSeparateSingle(
		SingleFace face,
		StencilOperation sfail,
		StencilOperation dfail,
		StencilOperation dpass
	);

	static CompareFunction StencilFunc(bool backface = false); 5
	static CompareFunction StencilFunc(Face face);

	static GLuint StencilValueMask(bool backface = false); 6
	static GLuint StencilValueMask(Face face);

	static GLuint StencilRef(bool backface = false); 7
	static GLuint StencilRef(Face face);

	static StencilFuncArgs StencilFuncArgs(Face face); 8
	static StencilFuncArgs StencilFuncArgsSingle(SingleFace face);

	static StencilOperation StencilFail(bool backface = false); 9
	static StencilOperation StencilFail(Face face);

	static StencilOperation StencilPassDepthFail(bool backface = false); 10
	static StencilOperation StencilPassDepthFail(Face face);

	static StencilOperation StencilPassDepthPass(bool backface = false); 11
	static StencilOperation StencilPassDepthPass(Face face)

	static StencilOperations StencilOps(bool backface = false);
	static StencilOperations StencilOps(Face face);
	static StencilOperations StencilOpsSingle(SingleFace face);
};

} // namespace context

1

Sets the stencil function, reference value and a mask. See glStencilFunc.

2

Sets the stencil function separately for front and back face. See glStencilFuncSeparate.

3

Sets the stencil operations. See glStencilOp.

4

Sets the stencil operations separately for front and back face. See glStencilOpSeparate.

5

Returns the currently set stencil function. See glGet, GL_STENCIL_FUNC, GL_STENCIL_BACK_FUNC.

6

Returns the currently set value of stencil mask. See glGet, GL_STENCIL_VALUE_MASK, GL_STENCIL_BACK_VALUE_MASK.

7

Returns the currently set stencil reference value. See glGet, GL_STENCIL_REF, GL_STENCIL_BACK_REF.

8

Returns the currently set stencil function arguments.

9

Returns the stencil-fail action. See glGet, GL_STENCIL_FAIL, GL_STENCIL_BACK_FAIL.

10

Returns the stencil-pass depth-fail action. See glGet, GL_STENCIL_PASS_DEPTH_FAIL, GL_STENCIL_BACK_PASS_DEPTH_FAIL.

11

Returns the stencil-pass depth-fail action. See glGet, GL_STENCIL_PASS_DEPTH_PASS, GL_STENCIL_BACK_PASS_DEPTH_PASS.

#include <oglplus/context/scissor_test.hpp>

namespace context {

struct ScissorRectangle
{
	GLint X(void) const
	noexcept;

	GLint Y(void) const
	noexcept;

	GLint Left(void) const
	noexcept;

	GLint Bottom(void) const
	noexcept;

	GLint Width(void) const
	noexcept;

	GLint Height(void) const
	noexcept;
};

class ScissorTest
{
public:
	static void Scissor(
		GLint left,
		GLint bottom,
		SizeType width,
		SizeType height
	); 1

#if GL_VERSION_4_1 || GL_ARB_viewport_array
	static void Scissor(
		ViewportIndex viewport,
		GLint left,
		GLint bottom,
		SizeType width,
		SizeType height
	); 2
	static void Scissor(ViewportIndex viewport, GLint* v);

	static void ScissorArray(GLuint first, SizeType count, GLint* v); 3

	static context::ScissorRectangle ScissorBox(ViewportIndex viewport); 4
#endif
};

} // namespace context

1

Defines the scissor rectangle for the first viewport. See glScissor.

2

Defines the scissor rectangle for the specified viewport. See glScissorIndexed.

3

Defines scissor rectangles for viewports specified by first and count. See glScissorArray.

4

Returns the extents of scissor box of the specified viewport. See glGet, GL_SCISSOR_BOX.

#include <oglplus/context/logic_ops.hpp>

namespace context {

class LogicOpState
{
public:
#if GL_VERSION_3_0
	static void LogicOp(ColorLogicOperation op); 1

	static ColorLogicOperation LogicOpMode(void); 2
#endif
};

} // namespace context

1

Sets the color logic operation. See glLogicOp.

2

Returns the current color logic operation. See glLogicOp, GL_LOGIC_OP_MODE.

#include <oglplus/context/pixel_ops.hpp>

State
namespace context {

class PixelState
{
public:
	static void PixelStore(PixelParameter parameter, GLfloat value); 1
	static void PixelStore(PixelParameter parameter, GLint value);

	template <PixelParameter Parameter>
	static void PixelStore(<Unspecified> value); 2

	static GLfloat PixelStoreValue(
		PixelParameter parameter,
		TypeTag<float>
	); 3
	static GLint PixelStoreValue(
		PixelParameter parameter,
		TypeTag<int>
	);
	static Boolean PixelStoreValue(
		PixelParameter parameter,
		TypeTag<bool>
	);

	template <PixelParameter Parameter>
	static <Unspecified> PixelStoreValue(void); 4
};

1

Sets the value of a pixel storage parameter. See glPixelStore.

2

Sets the value of a pixel storage Parameter. value has an appropriate type to hold the value of the Parameter being set. See glPixelStore.

3

Gets the value of a pixel storage Parameter. See glGet.

4

Gets the value of a pixel storage Parameter. The return value has an appropriate type to hold the value of the Parameter being retrieved. See glGet.

Operations
class PixelOps
{
public:

	static void ReadPixels(
		GLint x,
		GLint y,
		SizeType width,
		SizeType height,
		PixelDataFormat format,
		PixelDataType type,
		void* data
	); 1

	static void BlitFramebuffer(
		GLint srcX0,
		GLint srcY0,
		GLint srcX1,
		GLint srcY1,
		GLint dstX0,
		GLint dstY0,
		GLint dstX1,
		GLint dstY1,
		Bitfield<BufferSelectBit> mask,
		BlitFilter filter
	); 2
};

} // namespace context

1

Reads a block of pixels from the current framebuffer. See glReadPixels.

2

Transfers a rectangle of pixels from the read buffer the draw buffer. See glblitFramebuffer.

#include <oglplus/context/blending.hpp>

Helper classes
namespace context {

struct BlendEquationSeparate
{
	BlendEquationSeparate(void)
	noexcept;

	BlendEquationSeparate(BlendEquation rgb, BlendEquation alpha)
	noexcept;

	BlendEquation RGB(void) const
	noexcept;

	BlendEquation Alpha(void) const
	noexcept;
};

struct BlendFunctionSeparate
{
	BlendFunctionSeparate(void)
	noexcept;

	BlendFunctionSeparate(
		BlendFunction src_rgb,
		BlendFunction src_alpha,
		BlendFunction dst_rgb,
		BlendFunction dst_alpha
	) noexcept;

	BlendFunction SrcRGB(void) const
	noexcept;

	BlendFunction SrcAlpha(void) const
	noexcept;

	BlendFunction DstRGB(void) const
	noexcept;

	BlendFunction DstAlpha(void) const
	noexcept;
};
Operations
class BlendingOps
{
public:
#if GL_KHR_blend_equation_advanced
	static void BlendBarrier(void); 1
#endif
};

1

Specifies boundaries between blending passes.

State
class BlendingState
{
public:
	static void BlendEquation(OneOf<BlendEquation, BlendEquationAdvanced> eq); 1
	static void BlendEquationSeparate(
		BlendEquation eq_rgb,
		BlendEquation eq_alpha
	); 2

	static void BlendEquationSeparate(const context::BlendEquationSeparate&);
	static context::BlendEquationSeparate BlendEquationSeparate(void);

	static BlendEquation BlendEquationRGB(void);
	static BlendEquation BlendEquationAlpha(void);

#if GL_VERSION_4_0
	static void BlendEquation(
		DrawBufferIndex buffer,
		OneOf<BlendEquation, BlendEquationAdvanced> eq
	); 3
	static void BlendEquationSeparate(
		DrawBufferIndex buffer,
		BlendEquation eq_rgb,
		BlendEquation eq_alpha
	); 4

	static void BlendEquationSeparate(
		DrawBufferIndex buffer,
		const context::BlendEquationSeparate&
	);
	static context::BlendEquationSeparate BlendEquationSeparate(DrawBufferIndex buffer);

	static BlendEquation BlendEquationRGB(DrawBufferIndex buffer);
	static BlendEquation BlendEquationAlpha(DrawBufferIndex buffer);
#endif

	static void BlendFunc(BlendFunction src, BlendFunction dst); 5
	static void BlendFuncSeparate(
		BlendFunction src_rgb,
		BlendFunction dst_rgb,
		BlendFunction src_alpha,
		BlendFunction dst_alpha
	); 6

	static void BlendFuncSeparate(const context::BlendFunctionSeparate&);
	static context::BlendFunctionSeparate BlendFuncSeparate(void);

	static BlendFunction BlendFuncSrcRGB(void);
	static BlendFunction BlendFuncSrcAlpha(void);
	static BlendFunction BlendFuncDstRGB(void);
	static BlendFunction BlendFuncDstAlpha(void);

#if GL_VERSION_4_0
	static void BlendFunc(
		DrawBufferIndex buffer,
		BlendFunction src,
		BlendFunction dst
	); 7
	static void BlendFuncSeparate(
		DrawBufferIndex buffer,
		BlendFunction src_rgb,
		BlendFunction dst_rgb,
		BlendFunction src_alpha,
		BlendFunction dst_alpha
	); 8

	static void BlendFuncSeparate(
		DrawBufferIndex buffer,
		const context::BlendFunctionSeparate&
	);
	static context::BlendFunctionSeparate BlendFuncSeparate(DrawBufferIndex buffer);

	static BlendFunction BlendFuncSrcRGB(DrawBufferIndex buffer);
	static BlendFunction BlendFuncSrcAlpha(DrawBufferIndex buffer);
	static BlendFunction BlendFuncDstRGB(DrawBufferIndex buffer);
	static BlendFunction BlendFuncDstAlpha(DrawBufferIndex buffer);
#endif

	static void BlendColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a);

	static void BlendColor(const context::RGBAValue&);
	static context::RGBAValue BlendColor(void);
};

} // namespace context

1

Sets the blending equation. See glBlendEquation.

2

Sets the blend equation separately for RGB and alpha. See glBlendEquationSeparate.

3

Sets the blend equation for a particular draw buffer See glBlendEquationi.

4

Sets the blend equation separate for RGB and alpha for the specified draw buffer. See glBlendEquationSeparatei.

5

Sets the blend function. See glBlendFunc.

6

Sets the blend function separately for RGB and alpha. See glBlendFuncSeparate.

7

Sets the blend function for a particular draw buffer. See glBlendFunci.

8

Sets the blend function separately for RGB and alpha for a particular draw buffer. See glBlendFuncSeparatei.

#include <oglplus/context/synchronization.hpp>

namespace context {

class Synchronization
{
public:
#if GL_VERSION_4_2 || GL_ARB_shader_image_load_store
	static void MemoryBarrier(Bitfield<MemoryBarrierBit> bits); 1
#endif

	static void Flush(void); 2
	static void Finish(void); 3
};

} // namespace context

1

Defines a barrier ordering memory transactions. See glMemoryBarrier.

2

Requests that all previous GL commands finish in finite time. See glFlush.

3

Forces all previous GL commands to complete before returning. See glFinish.

#include <oglplus/context/hints.hpp>

namespace context {

class Hints
{
public:
	static void Hint(HintTarget target, HintOption option); 1
	static HintOption Hint(HintTarget target); 2
};

} // namespace context

1

Sets a hint option for a hint target. See glHint.

2

Queries the currently set hint option for a hint target.

#include <oglplus/context/limit_queries.hpp>

namespace context {

class LimitQueries
{
public:
	static GLint IntLimit(LimitQuery query); 1
	static GLint IntLimit(LimitQuery query, GLuint index); 2
	static GLfloat FloatLimit(LimitQuery query); 3
#if GL_VERSION_4_1 || GL_ARB_viewport_array
	static GLfloat FloatLimit(LimitQuery query, GLuint index); 4
#endif
	template <LimitQuery Query>
	static <Unspecified> Limit(void); 5

	template <LimitQuery Query>
	static <Unspecified> Limit(GLuint index); 6

	static void RequireAtLeast(LimitQuery limit, GLint value); 7
	static void RequireAtLeast(LimitQuery limit, GLuint index, GLint value);
};

} // namespace context

1

Gets the implementation-dependent integer limit value. See glGet.

2

Gets the implementation-dependent integer indexed limit value. See glGet.

3

Gets the implementation-dependent floating-point limit value. See glGet.

4

Gets the implementation-dependent floating-point indexed limit value. See glGet.

5

Gets the implementation-dependent numeric/boolean limit value. The return value has an appropriate type to hold the value of the parameter being retrieved. See glGet.

6

Gets the implementation-dependent numeric/boolean indexed limit value. The return value has an appropriate type to hold the value of the parameter being retrieved. See glGet.

7

Raises a LimitError if value is greater than the specified limit.

#include <oglplus/context/numeric_queries.hpp>

namespace context {

class NumericQueries
{
public:
	static GLint MajorVersion(void); 1
	static GLint MinorVersion(void); 2

#if GL_VERSION_3_3 || GL_ARB_timer_query
	static GLint64 Timestamp(void); 3
#endif

#if GL_VERSION_3_2
	static Bitfield<ContextProfileBit> ProfileMask(void); 4
	static Bitfield<ContextFlagBit> Flags(void); 5
#endif

#if GL_VERSION_4_5 || GL_KHR_context_flush_control
	static ContextReleaseBehavior ReleaseBehavior(void); 6
#endif

#if GL_VERSION_4_5
	static ResetNotificationStrategy ResetNotificationStrategy(void); 7
	static GraphicsResetStatus GraphicsResetStatus(void); 8
#endif
};

} // namespace context

1

Returns the GL major version. See glGet, GL_MAJOR_VERSION.

2

Returns the GL minor version. See glGet, GL_MINOR_VERSION.

3

Queries the current GL timestamp. See glGet, GL_TIMESTAMP.

4

Returns the GL context profile mask. See glGet, GL_CONTEXT_PROFILE_MASK.

5

Returns the current context flags. See glGet, GL_CONTEXT_FLAGS.

6

Returns the current context flush control reset behavior. See glGet, GL_CONTEXT_RELEASE_BEHAVIOR.

7

Returns the currently active context reset notification strategy. See glGet, GL_RESET_NOTIFICATION_STRATEGY.

8

Returns the current GL context reset status. See glGetGraphicsResetStatus.

#include <oglplus/context/string_queries.hpp>

namespace context {

class StringQueries
{
public:
	static const GLubyte* GetString(StringQuery query); 1

	static const char* Vendor(void); 2
	static const char* Renderer(void); 3
	static const char* Version(void); 4
	static const char* ShadingLanguageVersion(void); 5

#if GL_VERSION_4_3
	static GLuint NumShadingLanguageVersions(void); 6
	static const GLubyte* ShadingLanguageVersion(GLuint index); 7
	static Range<StrCRef> ShadingLanguageVersions(void); 8
#endif

	static GLuint NumExtensions(void); 9
	static const GLubyte* Extensions(GLuint index); 10
	static Range<StrCRef> Extensions(void); 11
};

} // namespace context

1

Queries a string describing GL properties. See glGetString.

2

Returns the name of the GL implementation vendor. See glGetString, GL_VENDOR.

3

Returns the renderer name string. See glGetString, GL_RENDERER.

4

Returns the version string of the GL implementation. See glGetString, GL_VERSION.

5

Returns the shading language version string of the GL implementation. See glGetString, GL_SHADING_LANGUAGE_VERSION.

6

Queries the number of supported shading language versions. See glGet, GL_NUM_SHADING_LANGUAGE_VERSIONS.

7

Returns the name of indexth supported shading language version. See glGetString, GL_SHADING_LANGUAGE_VERSION.

8

Returns a range of supported GLSL version strings. See glGetString, GL_SHADING_LANGUAGE_VERSION.

9

Queries the number of extension strings. See glGet, GL_NUM_EXTENSIONS.

10

Returns the name of the indexth extension. See glGetString, GL_EXTENSIONS.

11

Returns a range of extension name strings. See glGetString, GL_EXTENSIONS.

#include <oglplus/context/object_binding.hpp>

namespace context {

class ObjectBinding
{
public:
	template <typename Object>
	static
	void Bind(typename Object::Target target, const Object& object); 1

	template <typename Object>
	static
	void Bind(
		typename Object::IndexedTarget target,
		GLuint index,
		const Object& object
	); 2

	template <typename Object>
	static
	void Bind(const Object& object); 3

	template <typename Object>
	static
	void Use(const Object& object); 4

	template <typename Object>
	static Reference<ObjectOps<
		tag::CurrentBound,
		ObjTag
	>> Current(void); 5

	template <typename ObjectTarget>
	static Reference<ObjectOps<
		tag::CurrentBound,
		ObjTag
	>> Current(ObjectTarget target); 6

	template <typename Object>
	static Reference<ObjectOps<
		tag::CurrentBound,
		ObjTag
	>> Bound(typename Object::Target target, const Object& object); 7
};

} // namespace context

1

Binds the specified object to the specified target. Equivalent to object.Bind(target).

2

Binds the specified object to the specified indexed target. Equivalent to object.Bind(target, index).

3

Binds the specified object to the appropriate binding point. Equivalent to object.Bind().

4

Uses (makes current) the specified object (for example a Program). Equivalent to object.Use().

5

Returns the currently bound (active) instance of the specified Object type.

6

Returns the object currently bound to the specified object target.

7

Binds an object to a binding point specified by target and returns a reference to that object.

#include <oglplus/context/object_dsa.hpp>

namespace context {

class ObjectDSA
{
public:
	// TODO
};

} // namespace context
RGBA value
namespace context {

struct RGBAValue 1
{
	RGBAValue(void)
	noexcept;

	RGBAValue(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
	noexcept;

	GLfloat Red(void) const
	noexcept;

	GLfloat Green(void) const
	noexcept;

	GLfloat Blue(void) const
	noexcept;

	GLfloat Alpha(void) const
	noexcept;
};

1

Helper structure storing the RGBA color components.

RGBA mask
struct RGBAMask 1
{
	RGBAMask(void)
	noexcept;

	RGBAMask(Boolean r, Boolean g, Boolean b, Boolean a)
	noexcept;

	Boolean Red(void) const
	noexcept;

	Boolean Green(void) const
	noexcept;

	Boolean Blue(void) const
	noexcept;

	Boolean Alpha(void) const
	noexcept;
};

} // namespace context

1

Helper structure storing the color component mask.


PrevUpHomeNext