frame_buffer.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 The ClanLib Team
4**
5** This software is provided 'as-is', without any express or implied
6** warranty. In no event will the authors be held liable for any damages
7** arising from the use of this software.
8**
9** Permission is granted to anyone to use this software for any purpose,
10** including commercial applications, and to alter it and redistribute it
11** freely, subject to the following restrictions:
12**
13** 1. The origin of this software must not be misrepresented; you must not
14** claim that you wrote the original software. If you use this software
15** in a product, an acknowledgment in the product documentation would be
16** appreciated but is not required.
17** 2. Altered source versions must be plainly marked as such, and must not be
18** misrepresented as being the original software.
19** 3. This notice may not be removed or altered from any source distribution.
20**
21** Note: Some of the libraries ClanLib may link to may have additional
22** requirements or restrictions.
23**
24** File Author(s):
25**
26** Magnus Norddahl
27** Harry Storbacka
28*/
29
30#pragma once
31
32#include <memory>
33
34namespace clan
35{
38
39 class Size;
40 class Rect;
41 class Texture1D;
42 class Texture1DArray;
43 class Texture2D;
44 class Texture2DArray;
45 class Texture3D;
46 class TextureCube;
47 class RenderBuffer;
48 class GraphicContext;
50 class FrameBuffer_Impl;
51
62
65 {
68 };
69
72 {
73 public:
76
83
85 bool is_null() const { return !impl; }
86 explicit operator bool() const { return bool(impl); }
87
89 void throw_if_null() const;
90
95
99 Size get_size() const;
100
105
107 bool operator==(const FrameBuffer &other) const;
108
113 void attach_color(int attachment_index, const RenderBuffer &render_buffer);
114
120 void attach_color(int attachment_index, const Texture1D &texture, int level = 0);
121
128 void attach_color(int attachment_index, const Texture1DArray &texture, int array_index = -1, int level = 0);
129
135 void attach_color(int attachment_index, const Texture2D &texture, int level = 0);
136
143 void attach_color(int attachment_index, const Texture2DArray &texture, int array_index = -1, int level = 0);
144
151 void attach_color(int attachment_index, const Texture3D &texture, int depth, int level = 0);
152
160 void attach_color(int attachment_index, const TextureCube &texture, TextureSubtype subtype, int level = 0);
161
168 void detach_color(int attachment_index);
169
170 void attach_stencil(const RenderBuffer &render_buffer);
171 void attach_stencil(const Texture2D &texture, int level = 0);
172 void attach_stencil(const TextureCube &texture, TextureSubtype subtype, int level = 0);
174
175 void attach_depth(const RenderBuffer &render_buffer);
176 void attach_depth(const Texture2D &texture, int level = 0);
177 void attach_depth(const TextureCube &texture, TextureSubtype subtype, int level = 0);
179
180 void attach_depth_stencil(const RenderBuffer &render_buffer);
181 void attach_depth_stencil(const Texture2D &texture, int level = 0);
182 void attach_depth_stencil(const TextureCube &texture, TextureSubtype subtype, int level = 0);
184
191
196 float get_pixel_ratio() const;
197
198 private:
199 std::shared_ptr<FrameBuffer_Impl> impl;
200 };
201
203}
Interface for implementing a FrameBuffer target.
Definition frame_buffer_provider.h:46
void attach_depth(const TextureCube &texture, TextureSubtype subtype, int level=0)
void attach_stencil(const TextureCube &texture, TextureSubtype subtype, int level=0)
FrameBuffer(GraphicContext &context)
Constructs a FrameBuffer.
void attach_color(int attachment_index, const Texture3D &texture, int depth, int level=0)
Attach color buffer.
FrameBufferProvider * get_provider() const
Get Provider.
void attach_depth(const Texture2D &texture, int level=0)
void attach_depth_stencil(const Texture2D &texture, int level=0)
FrameBufferBindTarget get_bind_target() const
Get the bind target of the framebuffer.
void attach_color(int attachment_index, const Texture1DArray &texture, int array_index=-1, int level=0)
Attach color buffer.
void attach_color(int attachment_index, const Texture1D &texture, int level=0)
Attach color buffer.
void attach_stencil(const Texture2D &texture, int level=0)
float get_pixel_ratio() const
Size get_size() const
Get the minumum size of all the frame buffer attachments.
void attach_color(int attachment_index, const Texture2D &texture, int level=0)
Attach color buffer.
bool is_null() const
Returns true if this object is invalid.
Definition frame_buffer.h:85
void attach_depth(const RenderBuffer &render_buffer)
void throw_if_null() const
Throw an exception if this object is invalid.
void detach_depth_stencil()
void attach_color(int attachment_index, const Texture2DArray &texture, int array_index=-1, int level=0)
Attach color buffer.
void attach_stencil(const RenderBuffer &render_buffer)
void detach_color(int attachment_index)
Detach color buffer.
void attach_color(int attachment_index, const TextureCube &texture, TextureSubtype subtype, int level=0)
Attach color buffer.
bool operator==(const FrameBuffer &other) const
Equality operator.
void set_bind_target(FrameBufferBindTarget target)
Set the bind target of the framebuffer to either drawn to or read from.
void attach_depth_stencil(const TextureCube &texture, TextureSubtype subtype, int level=0)
void attach_color(int attachment_index, const RenderBuffer &render_buffer)
Attach color buffer.
void attach_depth_stencil(const RenderBuffer &render_buffer)
FrameBuffer()
Constructs a null instance.
Interface to drawing graphics.
Definition graphic_context.h:257
2D (left,top,right,bottom) rectangle structure - Integer
Definition rect.h:446
Render-buffer object class.
Definition render_buffer.h:47
2D (width,height) size structure - Integer
Definition size.h:176
1D texture array object class.
Definition texture_1d_array.h:41
1D texture object class.
Definition texture_1d.h:41
2D texture array object class.
Definition texture_2d_array.h:43
2D texture object class.
Definition texture_2d.h:41
3D texture object class.
Definition texture_3d.h:41
2D texture cube object class.
Definition texture_cube.h:52
FrameBufferBindTarget
Framebuffer bind target.
Definition frame_buffer.h:65
TextureSubtype
Texture Subtype.
Definition frame_buffer.h:54
@ draw
Definition frame_buffer.h:66
@ read
Definition frame_buffer.h:67
@ cube_map_positive_x
Definition frame_buffer.h:55
@ cube_map_negative_y
Definition frame_buffer.h:58
@ cube_map_negative_z
Definition frame_buffer.h:60
@ cube_map_negative_x
Definition frame_buffer.h:56
@ cube_map_positive_y
Definition frame_buffer.h:57
@ cube_map_positive_z
Definition frame_buffer.h:59
Definition clanapp.h:36