2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <dali/public-api/dali-core.h>
19 #include <dali-test-suite-utils.h>
23 #include <mesh-builder.h>
25 void framebuffer_set_startup(void)
27 test_return_value = TET_UNDEF;
30 void framebuffer_set_cleanup(void)
32 test_return_value = TET_PASS;
35 int UtcDaliFrameBufferNew01(void)
37 TestApplication application;
39 unsigned int width(64);
40 unsigned int height(64);
41 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
43 DALI_TEST_CHECK( frameBuffer );
45 application.SendNotification();
48 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
49 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
50 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
55 int UtcDaliFrameBufferNew02(void)
57 TestApplication application;
59 unsigned int width(64);
60 unsigned int height(64);
61 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR_DEPTH );
63 DALI_TEST_CHECK( frameBuffer );
65 application.SendNotification();
68 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
69 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
70 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
75 int UtcDaliFrameBufferNew03(void)
77 TestApplication application;
79 unsigned int width(64);
80 unsigned int height(64);
81 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR_STENCIL );
83 DALI_TEST_CHECK( frameBuffer );
85 application.SendNotification();
88 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
89 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
90 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
95 int UtcDaliFrameBufferNew04(void)
97 TestApplication application;
99 unsigned int width(64);
100 unsigned int height(64);
101 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR_DEPTH_STENCIL );
103 DALI_TEST_CHECK( frameBuffer );
105 application.SendNotification();
106 application.Render();
108 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
109 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
110 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
115 int UtcDaliFrameBufferNew05(void)
117 TestApplication application;
118 FrameBuffer frameBuffer;
119 DALI_TEST_CHECK( !frameBuffer );
123 int UtcDaliFrameBufferCopyConstructor(void)
125 TestApplication application;
127 unsigned int width(64);
128 unsigned int height(64);
129 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
131 FrameBuffer frameBufferCopy( frameBuffer );
133 DALI_TEST_CHECK( frameBufferCopy );
138 int UtcDaliFrameBufferAssignmentOperator(void)
140 TestApplication application;
142 unsigned int width(64);
143 unsigned int height(64);
144 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
146 FrameBuffer frameBuffer2;
147 DALI_TEST_CHECK( !frameBuffer2 );
149 frameBuffer2 = frameBuffer;
150 DALI_TEST_CHECK( frameBuffer2 );
155 int UtcDaliFrameBufferDownCast01(void)
157 TestApplication application;
158 unsigned int width(64);
159 unsigned int height(64);
160 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
162 BaseHandle handle(frameBuffer);
163 FrameBuffer frameBuffer2 = FrameBuffer::DownCast(handle);
164 DALI_TEST_CHECK( frameBuffer2 );
169 int UtcDaliFrameBufferDownCast02(void)
171 TestApplication application;
173 Handle handle = Handle::New(); // Create a custom object
174 FrameBuffer frameBuffer = FrameBuffer::DownCast(handle);
175 DALI_TEST_CHECK( !frameBuffer );
179 int UtcDaliFrameBufferAttachColorTexture01(void)
181 TestApplication application;
183 unsigned int width(64);
184 unsigned int height(64);
185 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR_DEPTH_STENCIL );
186 Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
187 frameBuffer.AttachColorTexture( texture );
189 application.SendNotification();
190 application.Render();
192 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
193 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
194 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
199 int UtcDaliFrameBufferAttachColorTexture02(void)
201 TestApplication application;
203 unsigned int width(64);
204 unsigned int height(64);
205 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
206 Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
207 texture.GenerateMipmaps();
210 frameBuffer.AttachColorTexture( texture, 0u, 1u );
212 application.SendNotification();
213 application.Render();
215 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
216 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
217 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
222 int UtcDaliFrameBufferAttachColorTexture03(void)
224 TestApplication application;
226 unsigned int width(64);
227 unsigned int height(64);
228 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
229 Texture texture = Texture::New( TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height );
230 texture.GenerateMipmaps();
232 //Attach NEGATIVE_Y face of the cubemap
233 frameBuffer.AttachColorTexture( texture, 0u, CubeMapLayer::NEGATIVE_Y );
235 application.SendNotification();
236 application.Render();
238 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
239 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
240 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
245 int UtcDaliFrameBufferGetColorTexture01(void)
247 TestApplication application;
249 unsigned int width(64);
250 unsigned int height(64);
251 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
252 Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
253 frameBuffer.AttachColorTexture( texture );
255 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
260 int UtcDaliFrameBufferGetColorTexture02(void)
262 TestApplication application;
264 unsigned int width(64);
265 unsigned int height(64);
266 FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
267 Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
268 frameBuffer.AttachColorTexture( texture, 0u, 1u );
270 DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);