1 #ifndef DALI_FRAMEBUFFER_H
2 #define DALI_FRAMEBUFFER_H
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/object/base-handle.h>
23 #include <dali/public-api/rendering/texture.h>
28 namespace Internal DALI_INTERNAL
34 * @brief FrameBuffer is a collection of textures that can be used as the destination for rendering
37 class DALI_IMPORT_API FrameBuffer : public BaseHandle
42 * @brief The initial attachments to create the FrameBuffer with.
43 * @note The color attachment is created on calling AttachColorTexture(). If a color attachment is not required, omit this call.
44 * @note With "NONE", no attachments are created initially. However color attachments can still be added as described above.
52 NONE = 0, ///< No attachments are created initially @SINCE_1_1.45
54 DEPTH = 1 << 0, ///< Depth buffer bit-mask value @SINCE_1_1.45
55 STENCIL = 1 << 1, ///< Stencil buffer bit-mask value @SINCE_1_1.45
57 // Preset bit-mask combinations:
58 DEPTH_STENCIL = DEPTH | STENCIL ///< The Framebuffer will be created with depth and stencil buffer @SINCE_1_1.45
63 * @brief Creates a new FrameBuffer object
66 * @param[in] width The width of the FrameBuffer
67 * @param[in] height The height of the FrameBuffer
68 * @param[in] attachments The attachments comprising the format of the FrameBuffer (the type is int to allow multiple bitmasks to be ORd).
69 * @return A handle to a newly allocated FrameBuffer
71 static FrameBuffer New( unsigned int width, unsigned int height, unsigned int attachments );
74 * @brief Default constructor, creates an empty handle
85 * @brief Copy constructor, creates a new handle to the same object
88 * @param[in] handle Handle to an object
90 FrameBuffer( const FrameBuffer& handle );
93 * @brief Downcast to a FrameBuffer.
96 * If not the returned handle is left uninitialized.
97 * @param[in] handle Handle to an object
98 * @return FrameBuffer handle or an uninitialized handle
100 static FrameBuffer DownCast( BaseHandle handle );
103 * @brief Assignment operator, changes this handle to point at the same object
106 * @param[in] handle Handle to an object
107 * @return Reference to the assigned object
109 FrameBuffer& operator=( const FrameBuffer& handle );
112 * @brief Attach the base LOD of a 2D texture to the framebuffer for color rendering.
113 * @note This causes a color attachment to be added.
116 * @param[in] texture The texture that will be used as output when rendering
117 * @note The texture has to have the same size than the FrameBuffer
118 * otherwise it won't be attached
120 void AttachColorTexture( Texture& texture );
123 * @brief Attach a texture to the framebuffer for color rendering.
124 * @note This causes a color attachment to be added.
127 * @param[in] texture The texture that will be used as output when rendering
128 * @param[in] mipmapLevel The mipmap of the texture to be attached
129 * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
130 * @note The specified texture mipmap has to have the same size than the FrameBuffer
131 * otherwise it won't be attached
133 void AttachColorTexture( Texture& texture, unsigned int mipmapLevel, unsigned int layer );
136 * @brief Get the color texture used as output in the FrameBuffer
139 * @returns A handle to the texture used as color output, or an uninitialized handle
141 Texture GetColorTexture();
146 * @brief The constructor.
147 * @note Not intended for application developers.
149 * @param[in] pointer A pointer to a newly allocated FrameBuffer
151 explicit DALI_INTERNAL FrameBuffer( Internal::FrameBuffer* pointer );
156 #endif // DALI_FRAMEBUFFER_H