frame_buffer.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 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 
31 #pragma once
32 
33 #include "../api_display.h"
34 #include <memory>
35 
36 namespace clan
37 {
40 
41 class Size;
42 class Rect;
43 class Texture1D;
44 class Texture1DArray;
45 class Texture2D;
46 class Texture2DArray;
47 class Texture3D;
48 class TextureCube;
49 class RenderBuffer;
50 class GraphicContext;
51 class FrameBufferProvider;
52 class FrameBuffer_Impl;
53 
56 {
63 };
64 
67 {
70 };
71 
73 class CL_API_DISPLAY FrameBuffer
74 {
77 public:
79  FrameBuffer();
80 
86  FrameBuffer(GraphicContext &context);
87 
91 public:
93  bool is_null() const { return !impl; }
94 
96  void throw_if_null() const;
97 
101  FrameBufferProvider *get_provider() const;
102 
106  Size get_size() const;
107 
111  FrameBufferBindTarget get_bind_target() const;
112 
116 public:
118  bool operator==(const FrameBuffer &other) const;
119 
124  void attach_color(int attachment_index, const RenderBuffer &render_buffer);
125 
131  void attach_color(int attachment_index, const Texture1D &texture, int level = 0);
132 
139  void attach_color(int attachment_index, const Texture1DArray &texture, int array_index = -1, int level = 0);
140 
146  void attach_color(int attachment_index, const Texture2D &texture, int level = 0);
147 
154  void attach_color(int attachment_index, const Texture2DArray &texture, int array_index = -1, int level = 0);
155 
162  void attach_color(int attachment_index, const Texture3D &texture, int depth, int level = 0);
163 
171  void attach_color(int attachment_index, const TextureCube &texture, TextureSubtype subtype, int level = 0);
172 
179  void detach_color(int attachment_index);
180 
181  void attach_stencil(const RenderBuffer &render_buffer);
182  void attach_stencil(const Texture2D &texture, int level = 0);
183  void attach_stencil(const TextureCube &texture, TextureSubtype subtype, int level = 0);
184  void detach_stencil();
185 
186  void attach_depth(const RenderBuffer &render_buffer);
187  void attach_depth(const Texture2D &texture, int level = 0);
188  void attach_depth(const TextureCube &texture, TextureSubtype subtype, int level = 0);
189  void detach_depth();
190 
191  void attach_depth_stencil(const RenderBuffer &render_buffer);
192  void attach_depth_stencil(const Texture2D &texture, int level = 0);
193  void attach_depth_stencil(const TextureCube &texture, TextureSubtype subtype, int level = 0);
194  void detach_depth_stencil();
195 
201  void set_bind_target(FrameBufferBindTarget target);
202 
206 private:
207  std::shared_ptr<FrameBuffer_Impl> impl;
209 };
210 
211 }
212 
3D texture object class.
Definition: texture_3d.h:42
Definition: frame_buffer.h:57
Frame-buffer object class.
Definition: frame_buffer.h:73
1D texture array object class.
Definition: texture_1d_array.h:42
2D texture cube object class.
Definition: texture_cube.h:53
Definition: frame_buffer.h:61
bool is_null() const
Returns true if this object is invalid.
Definition: frame_buffer.h:93
2D texture object class.
Definition: texture_2d.h:42
Definition: frame_buffer.h:69
Definition: frame_buffer.h:62
FrameBufferBindTarget
Framebuffer bind target.
Definition: frame_buffer.h:66
Definition: frame_buffer.h:59
Interface to drawing graphics.
Definition: graphic_context.h:257
TextureSubtype
Texture Subtype.
Definition: frame_buffer.h:55
Definition: frame_buffer.h:68
2D (width,height) size structure - Integer
Definition: size.h:157
Interface for implementing a FrameBuffer target.
Definition: frame_buffer_provider.h:46
Definition: frame_buffer.h:60
1D texture object class.
Definition: texture_1d.h:42
2D texture array object class.
Definition: texture_2d_array.h:44
Render-buffer object class.
Definition: render_buffer.h:48
Definition: frame_buffer.h:58