PrevUpHomeNext

Framebuffers

#include <oglplus/framebuffer.hpp>

Common framebuffer operations

template <>
class ObjCommonOps<tag::Framebuffer>
 : public FramebufferName
{
public:
	typedef FramebufferTarget Target; 1

	static FramebufferName Binding(FramebufferTarget target); 2
	static void Bind(FramebufferTarget target, FramebufferName framebuffer); 3

	void Bind(FramebufferTarget target) const; 4
};

1

Framebuffer bind target.

2

Returns the framebuffer currently bound to the specified target. See glGetIntegerv.

3

Binds the specified framebuffer to the specified target. See glBindFramebuffer.

4

Binds this framebuffer to the specified target. See glBindFramebuffer.

Operations with explicit selector

template <>
class ObjectOps<tag::ExplicitSel, tag::Framebuffer>
 : public ObjZeroOps<tag::ExplicitSel, tag::Framebuffer> 1
{
public:
	struct Property
	{
		typedef OneOf<
			FramebufferBuffer,
			FramebufferAttachment,
			FramebufferColorAttachment
		> Buffer; 2

		typedef OneOf<
			FramebufferAttachment,
			FramebufferColorAttachment
		> Attachment; 3

		typedef FramebufferStatus Status;
	};

	static FramebufferStatus Status(FramebufferTarget target); 4
	static bool IsComplete(FramebufferTarget target); 5
	static void Complete(FramebufferTarget target); 6

	static void AttachRenderbuffer(
		FramebufferTarget target,
		Property::Attachment attachment,
		RenderbufferName renderbuffer
	); 7
	static void AttachColorRenderbuffer(
		FramebufferTarget target,
		FramebufferColorAttachmentNumber attachment_no,
		RenderbufferName renderbuffer
	); 8

#if GL_VERSION_3_2
	static void AttachTexture(
		FramebufferTarget target,
		Property::Attachment attachment,
		TextureName texture,
		GLint level
	); 9
	static void AttachColorTexture(
		FramebufferTarget target,
		FramebufferColorAttachmentNumber attachment_no,
		TextureName texture,
		GLint level
	); 10
#endif

	static void AttachTexture1D(
		FramebufferTarget target,
		Property::Attachment attachment,
		TextureTarget textarget,
		TextureName texture,
		GLint level
	); 11
	static void AttachTexture2D(
		FramebufferTarget target,
		Property::Attachment attachment,
		TextureTarget textarget,
		TextureName texture,
		GLint level
	);
	static void AttachTexture3D(
		FramebufferTarget target,
		Property::Attachment attachment,
		TextureTarget textarget,
		TextureName texture,
		GLint level,
		GLint layer
	);

	static void AttachTextureLayer(
		FramebufferTarget target,
		Property::Attachment attachment,
		TextureName texture,
		GLint level,
		GLint layer
	); 12

1

Indirectly inherits from ObjCommonOps<tag::Framebuffer>.

2

Enumerations specifying framebuffer output buffer.

3

Enumerations specifying framebuffer attachments.

4

Returns the status of the framebuffer currently bound to the specified target. See glCheckFramebufferStatus.

5

Returns true if the framebuffer currently bound to the specified target is complete. See glCheckFramebufferStatus.

6

Throws an IncompleteFramebuffer exception if the framebuffer currently bound to the specified target is not complete.

7

Attaches a renderbuffer object as an attachment to the framebuffer currently bound to the specified target. See glFramebufferRenderbuffer.

8

Attaches a renderbuffer object as a color attachment with index specified by attachment_no to the framebuffer currently bound to the specified target.

9

Attaches the specified texture level as an attachment to the framebuffer currently bound to the specified target. See glFramebufferTexture.

10

Attaches the specified texture level as a color attachment with index specified by attachment_no to the framebuffer currently bound to the specified target.

11

Attaches the level (or level's layer) of a 1D, 2D or 3D texture with type specified by textarget, as an attachment of the framebuffer currently bound to the specified target. See glFramebufferTexture1D, glFramebufferTexture2D, glFramebufferTexture3D.

12

Attaches the level (or level's layer) of a 1D, 2D or 3D texture as an attachment of the framebuffer currently bound to the specified target. See glFramebufferTextureLayer.

#if GL_VERSION_4_3 || GL_ARB_invalidate_subdata
	static void Invalidate(
		FramebufferTarget target,
		const EnumArray<Property::Buffer>& buffers
	); 1
	static void Invalidate(
		FramebufferTarget target,
		SizeType count,
		const Property::Buffer* buffers
	);

	static void Invalidate(
		FramebufferTarget target,
		const EnumArray<Property::Buffer>& buffers,
		GLint x,
		GLint y,
		SizeType width,
		SizeType height
	); 2
	static void Invalidate(
		FramebufferTarget target,
		SizeType count,
		const Property::Buffer* buffers,
		GLint x,
		GLint y,
		SizeType width,
		SizeType height
	);
#endif
};

1

Invalidates the specified attachments or buffers of the framebuffer currently bound to the specified target. See glInvalidateFramebuffer.

2

Invalidates parts (specified by x, y, width and height) of attachments or buffers of the framebuffer currently bound to the specified target. See glInvalidateSubFramebuffer.

Definition

typedef ObjectOps<tag::ExplicitSel, tag::Framebuffer>
	FramebufferOps;

typedef Object<FramebufferOps> Framebuffer;

typedef ObjectZero<ObjZeroOps<tag::ExplicitSel, tag::Framebuffer>>
	DefaultFramebuffer;

Syntax sugar operators

struct FramebufferComplete { }; 1
struct FramebufferTargetAndAttch { };  2

FramebufferTargetAndAttch operator | (
	FramebufferTarget target,
	FramebufferOps::Property::Attachment attachment
); 3
FramebufferTargetAndAttch operator << (
	FramebufferTarget target,
	FramebufferOps::Property::Attachment attachment
);

FramebufferTarget operator << (
	FramebufferOps fbo,
	FramebufferTarget target
); 4
FramebufferTarget operator << (
	DefaultFramebuffer dfb,
	FramebufferTarget target
);

#if GL_VERSION_3_2
FramebufferTarget operator << (
	FramebufferTargetAndAttch taa,
	TextureName tex
); 5
#endif

// AttachRenderbuffer
FramebufferTarget operator << (
	FramebufferTargetAndAttch taa,
	RenderbufferName rbo
); 6

FramebufferTarget operator << (
	FramebufferTarget target,
	FramebufferComplete
); 7

1

Helper class used with syntax-sugar operators. Selects the Complete member function.

2

Helper class used with syntax-sugar operators. Stores a framebuffer target and attachment.

3

These two operators both tie a framebuffer target and attachment into a single object for use with subsequent operators.

4

Equivalent to fbo.Bind(target).

5

Attaches tex to the attachment of a framebuffer bound to a target specified by taa.

6

Attaches rbo to the attachment of a framebuffer bound to a target specified by taa.

7

Equivalent to FramebufferOps::Complete(target).

Target

#include <oglplus/framebuffer_target.hpp>

enum class FramebufferTarget : GLenum
{
	Draw = GL_DRAW_FRAMEBUFFER,
	Read = GL_READ_FRAMEBUFFER,
	Both = GL_FRAMEBUFFER
};

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

StrCRef EnumValueName(FramebufferTarget);

Target to class

#if !OGLPLUS_NO_ENUM_VALUE_CLASSES
namespace enums {

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

	Transform<FramebufferTarget::Draw>
		Draw;
	Transform<FramebufferTarget::Read>
		Read;
	Transform<FramebufferTarget::Both>
		Both;
};

} // namespace enums
#endif

1

Specialization of EnumToClass for the FramebufferTarget enumeration.

Buffer

#include <oglplus/framebuffer_attachment.hpp>

enum class FramebufferBuffer : GLenum
{
	Color        = GL_COLOR,
	Depth        = GL_DEPTH,
	Stencil      = GL_STENCIL,
	DepthStencil = GL_DEPTH_STENCIL
};

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

StrCRef EnumValueName(FramebufferBuffer);

Attachment

#include <oglplus/framebuffer_attachment.hpp>

enum class FramebufferAttachment : GLenum
{
	Color        = GL_COLOR_ATTACHMENT0,
	Color1       = GL_COLOR_ATTACHMENT1,
	Color2       = GL_COLOR_ATTACHMENT2,
	Color3       = GL_COLOR_ATTACHMENT3,
	Color4       = GL_COLOR_ATTACHMENT4,
	Color5       = GL_COLOR_ATTACHMENT5,
	Color6       = GL_COLOR_ATTACHMENT6,
	Color7       = GL_COLOR_ATTACHMENT7,
	Color8       = GL_COLOR_ATTACHMENT8,
	Color9       = GL_COLOR_ATTACHMENT9,
	Color10      = GL_COLOR_ATTACHMENT10,
	Color11      = GL_COLOR_ATTACHMENT11,
	Color12      = GL_COLOR_ATTACHMENT12,
	Color13      = GL_COLOR_ATTACHMENT13,
	Color14      = GL_COLOR_ATTACHMENT14,
	Color15      = GL_COLOR_ATTACHMENT15,
	Depth        = GL_DEPTH_ATTACHMENT,
	Stencil      = GL_STENCIL_ATTACHMENT,
	DepthStencil = GL_DEPTH_STENCIL_ATTACHMENT
};

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

StrCRef EnumValueName(FramebufferAttachment);

Color attachment

#include <oglplus/framebuffer_attachment.hpp>

enum class FramebufferColorAttachment : GLenum
{
	_0  = GL_COLOR_ATTACHMENT0,
	_1  = GL_COLOR_ATTACHMENT1,
	_2  = GL_COLOR_ATTACHMENT2,
	_3  = GL_COLOR_ATTACHMENT3,
	_4  = GL_COLOR_ATTACHMENT4,
	_5  = GL_COLOR_ATTACHMENT5,
	_6  = GL_COLOR_ATTACHMENT6,
	_7  = GL_COLOR_ATTACHMENT7,
	_8  = GL_COLOR_ATTACHMENT8,
	_9  = GL_COLOR_ATTACHMENT9,
	_10 = GL_COLOR_ATTACHMENT10,
	_11 = GL_COLOR_ATTACHMENT11,
	_12 = GL_COLOR_ATTACHMENT12,
	_13 = GL_COLOR_ATTACHMENT13,
	_14 = GL_COLOR_ATTACHMENT14,
	_15 = GL_COLOR_ATTACHMENT15
};

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

StrCRef EnumValueName(FramebufferColorAttachment);

Color attachment number

#include <oglplus/framebuffer_attachment.hpp>

class FramebufferColorAttachmentNumber
 : public LimitedCount<GL_MAX_COLOR_ATTACHMENTS>
{
public:
	FramebufferColorAttachmentNumber(GLuint number); 1
};

1

Throws LimitError if number is greater than the implementation-dependent maximum number of framebuffer color attachments. See GL_MAX_COLOR_ATTACHMENTS.

Status

#include <oglplus/framebuffer_status.hpp>

enum class FramebufferStatus : GLenum
{
	Complete                    = GL_FRAMEBUFFER_COMPLETE,
	Undefined                   = GL_FRAMEBUFFER_UNDEFINED,
	IncompleteAttachment        = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT,
	IncompleteMissingAttachment = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT,
	Unsupported                 = GL_FRAMEBUFFER_UNSUPPORTED,
	IncompleteMultisample       = GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE,
	IncompleteLayerTargets      = GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS
};

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

StrCRef EnumValueName(FramebufferStatus);

PrevUpHomeNext