frame_buffer.h
1 /*
2 ** UICore
3 ** Copyright (c) 1997-2015 The UICore 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 UICore 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 uicore
35 {
36  class Size;
37  class Rect;
38  class Texture1D;
39  class Texture1DArray;
40  class Texture2D;
41  class Texture2DArray;
42  class Texture3D;
43  class TextureCube;
44  class RenderBuffer;
45  class GraphicContext;
46  class FrameBufferProvider;
47  class FrameBuffer_Impl;
48  typedef std::shared_ptr<GraphicContext> GraphicContextPtr;
49  typedef std::shared_ptr<Texture1D> Texture1DPtr;
50  typedef std::shared_ptr<Texture1DArray> Texture1DArrayPtr;
51  typedef std::shared_ptr<Texture2D> Texture2DPtr;
52  typedef std::shared_ptr<Texture2DArray> Texture2DArrayPtr;
53  typedef std::shared_ptr<Texture3D> Texture3DPtr;
54  typedef std::shared_ptr<TextureCube> TextureCubePtr;
55  typedef std::shared_ptr<RenderBuffer> RenderBufferPtr;
56 
59  {
66  };
67 
70  {
73  };
74 
77  {
78  public:
82  static std::shared_ptr<FrameBuffer> create(const GraphicContextPtr &context);
83 
85  virtual Size size() const = 0;
86 
90  virtual FrameBufferBindTarget bind_target() const = 0;
91 
93  virtual void attach_color(int attachment_index, const RenderBufferPtr &render_buffer) = 0;
94  virtual void attach_color(int attachment_index, const Texture1DPtr &texture, int level = 0) = 0;
95  virtual void attach_color(int attachment_index, const Texture1DArrayPtr &texture, int array_index = -1, int level = 0) = 0;
96  virtual void attach_color(int attachment_index, const Texture2DPtr &texture, int level = 0) = 0;
97  virtual void attach_color(int attachment_index, const Texture2DArrayPtr &texture, int array_index = -1, int level = 0) = 0;
98  virtual void attach_color(int attachment_index, const Texture3DPtr &texture, int depth, int level = 0) = 0;
99  virtual void attach_color(int attachment_index, const TextureCubePtr &texture, TextureSubtype subtype, int level = 0) = 0;
100 
102  virtual void detach_color(int attachment_index) = 0;
103 
105  virtual void attach_stencil(const RenderBufferPtr &render_buffer) = 0;
106  virtual void attach_stencil(const Texture2DPtr &texture, int level = 0) = 0;
107  virtual void attach_stencil(const TextureCubePtr &texture, TextureSubtype subtype, int level = 0) = 0;
108  virtual void detach_stencil() = 0;
109 
111  virtual void attach_depth(const RenderBufferPtr &render_buffer) = 0;
112  virtual void attach_depth(const Texture2DPtr &texture, int level = 0) = 0;
113  virtual void attach_depth(const TextureCubePtr &texture, TextureSubtype subtype, int level = 0) = 0;
114 
116  virtual void detach_depth() = 0;
117 
118  // Attach combined depth and stencil buffer
119  virtual void attach_depth_stencil(const RenderBufferPtr &render_buffer) = 0;
120  virtual void attach_depth_stencil(const Texture2DPtr &texture, int level = 0) = 0;
121  virtual void attach_depth_stencil(const TextureCubePtr &texture, TextureSubtype subtype, int level = 0) = 0;
122 
123  // Detach combined depth and stencil buffer
124  virtual void detach_depth_stencil() = 0;
125 
129  virtual void set_bind_target(FrameBufferBindTarget target) = 0;
130  };
131 
132  typedef std::shared_ptr<FrameBuffer> FrameBufferPtr;
133 }
virtual void detach_stencil()=0
std::shared_ptr< Texture2D > Texture2DPtr
Definition: image.h:42
Definition: frame_buffer.h:64
2D (width,height) size structure - Integer
Definition: size.h:167
static std::shared_ptr< FrameBuffer > create(const GraphicContextPtr &context)
Constructs a FrameBuffer.
TextureSubtype
Texture Subtype.
Definition: frame_buffer.h:58
virtual void detach_depth_stencil()=0
virtual void attach_depth_stencil(const RenderBufferPtr &render_buffer)=0
std::shared_ptr< Texture1DArray > Texture1DArrayPtr
Definition: frame_buffer.h:50
std::shared_ptr< Texture1D > Texture1DPtr
Definition: frame_buffer.h:49
virtual Size size() const =0
Get the minumum size of all the frame buffer attachments.
virtual FrameBufferBindTarget bind_target() const =0
Get the bind target of the framebuffer.
Definition: frame_buffer.h:62
virtual void set_bind_target(FrameBufferBindTarget target)=0
Set the bind target of the framebuffer to either drawn to or read from.
Definition: frame_buffer.h:72
Definition: frame_buffer.h:60
virtual void attach_depth(const RenderBufferPtr &render_buffer)=0
Attach depth buffer.
Definition: frame_buffer.h:65
std::shared_ptr< TextureCube > TextureCubePtr
Definition: frame_buffer.h:54
Frame-buffer object class.
Definition: frame_buffer.h:76
std::shared_ptr< FrameBuffer > FrameBufferPtr
Definition: frame_buffer.h:132
Definition: frame_buffer.h:63
std::shared_ptr< RenderBuffer > RenderBufferPtr
Definition: d3d_target.h:45
Definition: frame_buffer.h:61
virtual void attach_stencil(const RenderBufferPtr &render_buffer)=0
Attach stencil buffer.
std::shared_ptr< GraphicContext > GraphicContextPtr
Definition: d3d_target.h:49
virtual void attach_color(int attachment_index, const RenderBufferPtr &render_buffer)=0
Attach color buffer.
Definition: frame_buffer.h:71
virtual void detach_depth()=0
Detach depth buffer.
virtual void detach_color(int attachment_index)=0
Detach color buffer.
FrameBufferBindTarget
Framebuffer bind target.
Definition: frame_buffer.h:69
std::shared_ptr< Texture3D > Texture3DPtr
Definition: frame_buffer.h:53
Definition: Application/application.h:35
std::shared_ptr< Texture2DArray > Texture2DArrayPtr
Definition: frame_buffer.h:52