frame_buffer.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2016 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 
34 namespace 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 
54  {
61  };
62 
65  {
68  };
69 
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 
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);
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 
191 
196  float get_pixel_ratio() const;
197 
198  private:
199  std::shared_ptr<FrameBuffer_Impl> impl;
200  };
201 
203 }
3D texture object class.
Definition: texture_3d.h:40
Definition: frame_buffer.h:55
Definition: clanapp.h:35
FrameBuffer()
Constructs a null instance.
Frame-buffer object class.
Definition: frame_buffer.h:71
FrameBufferProvider * get_provider() const
Get Provider.
1D texture array object class.
Definition: texture_1d_array.h:40
void attach_stencil(const RenderBuffer &render_buffer)
bool is_null() const
Returns true if this object is invalid.
Definition: frame_buffer.h:85
2D texture cube object class.
Definition: texture_cube.h:51
Definition: frame_buffer.h:59
void detach_color(int attachment_index)
Detach color buffer.
bool operator==(const FrameBuffer &other) const
Equality operator.
2D texture object class.
Definition: texture_2d.h:40
Definition: frame_buffer.h:67
void throw_if_null() const
Throw an exception if this object is invalid.
void detach_depth_stencil()
void attach_depth(const RenderBuffer &render_buffer)
Definition: frame_buffer.h:60
float get_pixel_ratio() const
FrameBufferBindTarget
Framebuffer bind target.
Definition: frame_buffer.h:64
Definition: frame_buffer.h:57
Interface to drawing graphics.
Definition: graphic_context.h:256
TextureSubtype
Texture Subtype.
Definition: frame_buffer.h:53
void set_bind_target(FrameBufferBindTarget target)
Set the bind target of the framebuffer to either drawn to or read from.
Size get_size() const
Get the minumum size of all the frame buffer attachments.
Definition: frame_buffer.h:66
2D (width,height) size structure - Integer
Definition: size.h:170
Interface for implementing a FrameBuffer target.
Definition: frame_buffer_provider.h:45
Definition: frame_buffer.h:58
FrameBufferBindTarget get_bind_target() const
Get the bind target of the framebuffer.
1D texture object class.
Definition: texture_1d.h:40
2D texture array object class.
Definition: texture_2d_array.h:42
Render-buffer object class.
Definition: render_buffer.h:46
Definition: frame_buffer.h:56
void attach_depth_stencil(const RenderBuffer &render_buffer)
void attach_color(int attachment_index, const RenderBuffer &render_buffer)
Attach color buffer.