[dali_1.1.38] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / render / renderers / render-frame-buffer.h
1 #ifndef DALI_INTERNAL_RENDER_FRAME_BUFFER_H
2 #define DALI_INTERNAL_RENDER_FRAME_BUFFER_H
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20
21 // INTERNAL INCLUDES
22 #include <dali/devel-api/rendering/frame-buffer.h>
23 #include <dali/integration-api/resource-declarations.h>
24
25 #include <dali/internal/render/gl-resources/context.h>
26 #include <dali/integration-api/gl-defines.h>
27 #include <dali/internal/render/renderers/render-sampler.h>
28
29 namespace Dali
30 {
31 namespace Internal
32 {
33 namespace Render
34 {
35 class NewTexture;
36
37 class FrameBuffer
38 {
39 public:
40
41   typedef Dali::FrameBuffer::Format Format;
42
43   /**
44    * Constructor
45    * @param[in] width The width of the FrameBuffer
46    * @param[in] height The height of the FrameBuffer
47    * @param[in] format The format of the FrameBuffer
48    */
49   FrameBuffer( unsigned int width, unsigned int height, Format format );
50
51   /**
52    * Destructor
53    */
54   ~FrameBuffer();
55
56   /**
57    * Creates a FrameBuffer object in the GPU.
58    * @param[in] context The GL context
59    */
60   void Initialize(Context& context);
61
62   /**
63    * Deletes the framebuffer object from the GPU
64    * @param[in] context The GL context
65    */
66   void Destroy( Context& context );
67
68   /**
69    * @brief Attach a texture for color rendering
70    * param[in] context The GL context
71    * @param[in] texture The texture that will be used as output when rendering
72    * @param[in] mipmapLevel The mipmap of the texture to be attached
73    * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
74    */
75   void AttachColorTexture( Context& context, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer );
76
77   /**
78    * @brief Bind the framebuffer
79    * @param[in] context The GL context
80    */
81   void Bind( Context& context );
82
83   /**
84    * @brief Get the width of the FrameBuffer
85    * @return The width of the framebuffer
86    */
87   unsigned int GetWidth() const;
88
89   /**
90    * @brief Get the height of the FrameBuffer
91    * @return The height of the framebuffer
92    */
93   unsigned int GetHeight() const;
94
95 private:
96
97   GLuint mId;
98   GLuint mDepthBuffer;
99   GLuint mStencilBuffer;
100   unsigned int mWidth;
101   unsigned int mHeight;
102 };
103
104
105 } // namespace Render
106
107 } // namespace Internal
108
109 } // namespace Dali
110
111
112 #endif //  DALI_INTERNAL_RENDER_FRAME_BUFFER_H