frame_buffer.h Source File - ClanLib SDK
Description: frame_buffer.h Source File

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;
49 class FrameBufferProvider;
50 class FrameBuffer_Impl;
51
53 enum class TextureSubtype
54 {
55 cube_map_positive_x,
56 cube_map_negative_x,
57 cube_map_positive_y,
58 cube_map_negative_y,
59 cube_map_positive_z,
60 cube_map_negative_z
61 };
62
64 enum class FrameBufferBindTarget
65 {
66 draw,
67 read
68 };
69
71 class FrameBuffer
72 {
73 public:
75 FrameBuffer();
76
82 FrameBuffer(GraphicContext &context);
83
85 bool is_null() const { return !impl; }
86 explicit operator bool() const { return bool(impl); }
87
89 void throw_if_null() const;
90
94 FrameBufferProvider *get_provider() const;
95
99 Size get_size() const;
100
104 FrameBufferBindTarget get_bind_target() const;
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);
173 void detach_stencil();
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);
178 void detach_depth();
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);
183 void detach_depth_stencil();
184
190 void set_bind_target(FrameBufferBindTarget target);
191
196 float get_pixel_ratio() const;
197
198 private:
199 std::shared_ptr<FrameBuffer_Impl> impl;
200 };
201
203}
clan::FrameBufferProvider
Interface for implementing a FrameBuffer target.
Definition frame_buffer_provider.h:46
clan::FrameBuffer
Frame-buffer object class.
Definition frame_buffer.h:72
clan::FrameBuffer::attach_depth
void attach_depth(const TextureCube &texture, TextureSubtype subtype, int level=0)
clan::FrameBuffer::attach_stencil
void attach_stencil(const TextureCube &texture, TextureSubtype subtype, int level=0)
clan::FrameBuffer::FrameBuffer
FrameBuffer(GraphicContext &context)
Constructs a FrameBuffer.
clan::FrameBuffer::attach_color
void attach_color(int attachment_index, const Texture3D &texture, int depth, int level=0)
Attach color buffer.
clan::FrameBuffer::get_provider
FrameBufferProvider * get_provider() const
Get Provider.
clan::FrameBuffer::attach_depth
void attach_depth(const Texture2D &texture, int level=0)
clan::FrameBuffer::attach_depth_stencil
void attach_depth_stencil(const Texture2D &texture, int level=0)
clan::FrameBuffer::get_bind_target
FrameBufferBindTarget get_bind_target() const
Get the bind target of the framebuffer.
clan::FrameBuffer::attach_color
void attach_color(int attachment_index, const Texture1DArray &texture, int array_index=-1, int level=0)
Attach color buffer.
clan::FrameBuffer::attach_color
void attach_color(int attachment_index, const Texture1D &texture, int level=0)
Attach color buffer.
clan::FrameBuffer::attach_stencil
void attach_stencil(const Texture2D &texture, int level=0)
clan::FrameBuffer::get_pixel_ratio
float get_pixel_ratio() const
clan::FrameBuffer::get_size
Size get_size() const
Get the minumum size of all the frame buffer attachments.
clan::FrameBuffer::attach_color
void attach_color(int attachment_index, const Texture2D &texture, int level=0)
Attach color buffer.
clan::FrameBuffer::is_null
bool is_null() const
Returns true if this object is invalid.
Definition frame_buffer.h:85
clan::FrameBuffer::attach_depth
void attach_depth(const RenderBuffer &render_buffer)
clan::FrameBuffer::throw_if_null
void throw_if_null() const
Throw an exception if this object is invalid.
clan::FrameBuffer::detach_depth_stencil
void detach_depth_stencil()
clan::FrameBuffer::detach_depth
void detach_depth()
clan::FrameBuffer::attach_color
void attach_color(int attachment_index, const Texture2DArray &texture, int array_index=-1, int level=0)
Attach color buffer.
clan::FrameBuffer::attach_stencil
void attach_stencil(const RenderBuffer &render_buffer)
clan::FrameBuffer::detach_color
void detach_color(int attachment_index)
Detach color buffer.
clan::FrameBuffer::attach_color
void attach_color(int attachment_index, const TextureCube &texture, TextureSubtype subtype, int level=0)
Attach color buffer.
clan::FrameBuffer::operator==
bool operator==(const FrameBuffer &other) const
Equality operator.
clan::FrameBuffer::set_bind_target
void set_bind_target(FrameBufferBindTarget target)
Set the bind target of the framebuffer to either drawn to or read from.
clan::FrameBuffer::attach_depth_stencil
void attach_depth_stencil(const TextureCube &texture, TextureSubtype subtype, int level=0)
clan::FrameBuffer::attach_color
void attach_color(int attachment_index, const RenderBuffer &render_buffer)
Attach color buffer.
clan::FrameBuffer::attach_depth_stencil
void attach_depth_stencil(const RenderBuffer &render_buffer)
clan::FrameBuffer::detach_stencil
void detach_stencil()
clan::FrameBuffer::FrameBuffer
FrameBuffer()
Constructs a null instance.
clan::GraphicContext
Interface to drawing graphics.
Definition graphic_context.h:257
clan::RenderBuffer
Render-buffer object class.
Definition render_buffer.h:47
clan::Size
2D (width,height) size structure - Integer
Definition size.h:171
clan::Texture1DArray
1D texture array object class.
Definition texture_1d_array.h:41
clan::Texture1D
1D texture object class.
Definition texture_1d.h:41
clan::Texture2DArray
2D texture array object class.
Definition texture_2d_array.h:43
clan::Texture2D
2D texture object class.
Definition texture_2d.h:41
clan::Texture3D
3D texture object class.
Definition texture_3d.h:41
clan::TextureCube
2D texture cube object class.
Definition texture_cube.h:52
clan::FrameBufferBindTarget
FrameBufferBindTarget
Framebuffer bind target.
Definition frame_buffer.h:65
clan::TextureSubtype
TextureSubtype
Texture Subtype.
Definition frame_buffer.h:54
clan::FrameBufferBindTarget::draw
@ draw
clan::FrameBufferBindTarget::read
@ read
clan::TextureSubtype::cube_map_positive_x
@ cube_map_positive_x
clan::TextureSubtype::cube_map_negative_y
@ cube_map_negative_y
clan::TextureSubtype::cube_map_negative_z
@ cube_map_negative_z
clan::TextureSubtype::cube_map_negative_x
@ cube_map_negative_x
clan::TextureSubtype::cube_map_positive_y
@ cube_map_positive_y
clan::TextureSubtype::cube_map_positive_z
@ cube_map_positive_z
clan
Definition clanapp.h:36