2 * Copyright (c) 2015 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>
27 void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
34 void material_test_startup(void)
36 test_return_value = TET_UNDEF;
39 void material_test_cleanup(void)
41 test_return_value = TET_PASS;
44 int UtcDaliMaterialNew01(void)
46 TestApplication application;
48 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
49 Material material = Material::New(shader);
51 DALI_TEST_CHECK( material );
55 int UtcDaliMaterialNew02(void)
57 TestApplication application;
59 DALI_TEST_CHECK( !material );
63 int UtcDaliMaterialCopyConstructor(void)
65 TestApplication application;
67 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
68 Image image = BufferImage::New(32, 32, Pixel::RGBA8888);
69 Material material = Material::New(shader);
70 material.AddTexture( image, "sTexture" );
72 Material materialCopy(material);
74 DALI_TEST_CHECK( materialCopy );
79 int UtcDaliMaterialAssignmentOperator(void)
81 TestApplication application;
83 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
84 Image image = BufferImage::New(32, 32, Pixel::RGBA8888);
85 Material material = Material::New(shader);
88 DALI_TEST_CHECK( !material2 );
91 DALI_TEST_CHECK( material2 );
96 int UtcDaliMaterialDownCast01(void)
98 TestApplication application;
99 Shader shader = Shader::New("vertexSrc", "fragmentSrc");
100 Material material = Material::New(shader);
102 BaseHandle handle(material);
103 Material material2 = Material::DownCast(handle);
104 DALI_TEST_CHECK( material2 );
109 int UtcDaliMaterialDownCast02(void)
111 TestApplication application;
113 Handle handle = Handle::New(); // Create a custom object
114 Material material = Material::DownCast(handle);
115 DALI_TEST_CHECK( !material );
119 int UtcDaliMaterialSetShader(void)
121 TestApplication application;
123 tet_infoline("Test SetShader(shader) ");
125 Shader shader1 = Shader::New( "vertexSrc1", "fragmentSrc1" );
126 shader1.RegisterProperty( "uFadeColor", Color::CYAN );
128 Shader shader2 = Shader::New( "vertexSrc1", "fragmentSrc1" );
129 shader2.RegisterProperty( "uFadeColor", Color::MAGENTA );
132 Material material = Material::New(shader1);
134 Geometry geometry = CreateQuadGeometry();
135 Renderer renderer = Renderer::New( geometry, material );
137 Actor actor = Actor::New();
138 actor.AddRenderer(renderer);
139 actor.SetSize(400, 400);
140 Stage::GetCurrent().Add(actor);
142 TestGlAbstraction& gl = application.GetGlAbstraction();
143 application.SendNotification();
144 application.Render(0);
145 Vector4 actualValue(Vector4::ZERO);
146 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
147 DALI_TEST_EQUALS( actualValue, Color::CYAN, TEST_LOCATION );
150 material.SetShader( shader2 );
152 application.SendNotification();
153 application.Render(0);
154 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
155 DALI_TEST_EQUALS( actualValue, Color::MAGENTA, TEST_LOCATION );
158 material.SetShader( shader1 );
160 application.SendNotification();
161 application.Render(0);
162 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
163 DALI_TEST_EQUALS( actualValue, Color::CYAN, TEST_LOCATION );
168 int UtcDaliMaterialGetShader(void)
170 TestApplication application;
172 tet_infoline("Test GetShader() ");
174 Shader shader1 = Shader::New( "vertexSrc1", "fragmentSrc1" );
175 Shader shader2 = Shader::New( "vertexSrc1", "fragmentSrc1" );
178 Material material = Material::New(shader1);
179 DALI_TEST_EQUALS( shader1, material.GetShader(), TEST_LOCATION );
182 material.SetShader( shader2 );
183 DALI_TEST_EQUALS( shader2, material.GetShader(), TEST_LOCATION );
186 material.SetShader( shader1 );
187 DALI_TEST_EQUALS( shader1, material.GetShader(), TEST_LOCATION );
192 int UtcDaliMaterialGetNumberOfTextures(void)
194 TestApplication application;
196 tet_infoline("Test GetNumberOfTextures()");
198 Image image = BufferImage::New(32, 32, Pixel::RGBA8888);
199 Material material = CreateMaterial(0.5f);
201 Geometry geometry = CreateQuadGeometry();
202 Renderer renderer = Renderer::New( geometry, material );
203 Actor actor = Actor::New();
204 actor.AddRenderer(renderer);
205 actor.SetParentOrigin( ParentOrigin::CENTER );
206 actor.SetSize(400, 400);
207 Stage::GetCurrent().Add( actor );
209 material.AddTexture( image, "sTexture0" );
210 material.AddTexture( image, "sTexture1" );
211 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 2u, TEST_LOCATION );
213 material.AddTexture( image, "sTexture2" );
214 material.AddTexture( image, "sTexture3" );
215 material.AddTexture( image, "sTexture4" );
216 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 5u, TEST_LOCATION );
218 material.RemoveTexture(3);
219 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 4u, TEST_LOCATION );
221 material.RemoveTexture(3);
222 material.RemoveTexture(0);
223 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 2u, TEST_LOCATION );
228 int UtcDaliMaterialSetFaceCullingMode(void)
230 TestApplication application;
232 tet_infoline("Test SetFaceCullingMode(cullingMode)");
233 Geometry geometry = CreateQuadGeometry();
234 Material material = CreateMaterial(0.5f);
235 Renderer renderer = Renderer::New( geometry, material );
237 Actor actor = Actor::New();
238 actor.AddRenderer(renderer);
239 actor.SetSize(400, 400);
240 Stage::GetCurrent().Add(actor);
242 TestGlAbstraction& gl = application.GetGlAbstraction();
243 TraceCallStack& cullFaceStack = gl.GetCullFaceTrace();
244 cullFaceStack.Reset();
245 gl.EnableCullFaceCallTrace(true);
247 material.SetFaceCullingMode( Material::CULL_BACK_AND_FRONT);
248 application.SendNotification();
249 application.Render();
251 // Todo: test the glCullFace(GL_FRONT_AND_BACK) is actually been called, cannot pass this test with current implementation
252 DALI_TEST_EQUALS( cullFaceStack.CountMethod( "CullFace" ), 0, TEST_LOCATION);
253 //string parameter("GL_FRONT_AND_BACK" );
254 //DALI_TEST_CHECK( cullFaceStack.TestMethodAndParams(0, "CullFace", parameter) );
259 int UtcDaliMaterialBlendingOptions01(void)
261 TestApplication application;
263 tet_infoline("Test SetBlendFunc(src, dest) ");
265 Geometry geometry = CreateQuadGeometry();
266 Material material = CreateMaterial(0.5f);
267 Renderer renderer = Renderer::New( geometry, material );
269 Actor actor = Actor::New();
270 actor.AddRenderer(renderer);
271 actor.SetSize(400, 400);
272 Stage::GetCurrent().Add(actor);
274 material.SetBlendFunc(BlendingFactor::ONE_MINUS_SRC_COLOR, BlendingFactor::SRC_ALPHA_SATURATE);
276 // Test that Set was successful:
278 BlendingFactor::Type srcFactorRgb( BlendingFactor::ZERO );
279 BlendingFactor::Type destFactorRgb( BlendingFactor::ZERO );
280 BlendingFactor::Type srcFactorAlpha( BlendingFactor::ZERO );
281 BlendingFactor::Type destFactorAlpha( BlendingFactor::ZERO );
282 material.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
284 DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_SRC_COLOR, srcFactorRgb, TEST_LOCATION );
285 DALI_TEST_EQUALS( BlendingFactor::SRC_ALPHA_SATURATE, destFactorRgb, TEST_LOCATION );
286 DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_SRC_COLOR, srcFactorAlpha, TEST_LOCATION );
287 DALI_TEST_EQUALS( BlendingFactor::SRC_ALPHA_SATURATE, destFactorAlpha, TEST_LOCATION );
290 application.SendNotification();
291 application.Render();
293 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
295 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
296 DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
297 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
298 DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
303 int UtcDaliMaterialBlendingOptions02(void)
305 TestApplication application;
307 tet_infoline("Test SetBlendFunc(srcRgb, destRgb, srcAlpha, destAlpha) ");
309 Geometry geometry = CreateQuadGeometry();
310 Material material = CreateMaterial(0.5f);
311 Renderer renderer = Renderer::New( geometry, material );
313 Actor actor = Actor::New();
314 actor.AddRenderer(renderer);
315 actor.SetSize(400, 400);
316 Stage::GetCurrent().Add(actor);
318 material.SetBlendFunc( BlendingFactor::CONSTANT_COLOR, BlendingFactor::ONE_MINUS_CONSTANT_COLOR,
319 BlendingFactor::CONSTANT_ALPHA, BlendingFactor::ONE_MINUS_CONSTANT_ALPHA );
321 // Test that Set was successful:
323 BlendingFactor::Type srcFactorRgb( BlendingFactor::ZERO );
324 BlendingFactor::Type destFactorRgb( BlendingFactor::ZERO );
325 BlendingFactor::Type srcFactorAlpha( BlendingFactor::ZERO );
326 BlendingFactor::Type destFactorAlpha( BlendingFactor::ZERO );
327 material.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
329 DALI_TEST_EQUALS( BlendingFactor::CONSTANT_COLOR, srcFactorRgb, TEST_LOCATION );
330 DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_CONSTANT_COLOR, destFactorRgb, TEST_LOCATION );
331 DALI_TEST_EQUALS( BlendingFactor::CONSTANT_ALPHA, srcFactorAlpha, TEST_LOCATION );
332 DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_CONSTANT_ALPHA, destFactorAlpha, TEST_LOCATION );
335 application.SendNotification();
336 application.Render();
338 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
339 DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
340 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
341 DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
342 DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
349 int UtcDaliMaterialBlendingOptions03(void)
351 TestApplication application;
353 tet_infoline("Test GetBlendEquation() defaults ");
355 Geometry geometry = CreateQuadGeometry();
356 Material material = CreateMaterial(0.5f);
357 Renderer renderer = Renderer::New( geometry, material );
359 Actor actor = Actor::New();
360 actor.AddRenderer(renderer);
361 actor.SetSize(400, 400);
362 Stage::GetCurrent().Add(actor);
364 // Test the defaults as documented in blending.h
366 BlendingEquation::Type equationRgb( BlendingEquation::SUBTRACT );
367 BlendingEquation::Type equationAlpha( BlendingEquation::SUBTRACT );
368 material.GetBlendEquation( equationRgb, equationAlpha );
369 DALI_TEST_EQUALS( BlendingEquation::ADD, equationRgb, TEST_LOCATION );
370 DALI_TEST_EQUALS( BlendingEquation::ADD, equationAlpha, TEST_LOCATION );
377 int UtcDaliMaterialBlendingOptions04(void)
379 TestApplication application;
381 tet_infoline("Test SetBlendEquation() ");
383 Geometry geometry = CreateQuadGeometry();
384 Material material = CreateMaterial(0.5f);
385 Renderer renderer = Renderer::New( geometry, material );
387 Actor actor = Actor::New();
388 actor.AddRenderer(renderer);
389 actor.SetSize(400, 400);
390 Stage::GetCurrent().Add(actor);
392 // Test the single blending equation setting
394 material.SetBlendEquation( BlendingEquation::REVERSE_SUBTRACT );
395 BlendingEquation::Type equationRgba( BlendingEquation::SUBTRACT );
396 material.GetBlendEquation( equationRgba, equationRgba );
397 DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationRgba, TEST_LOCATION );
400 material.SetBlendEquation( BlendingEquation::REVERSE_SUBTRACT, BlendingEquation::REVERSE_SUBTRACT );
402 // Test that Set was successful
404 BlendingEquation::Type equationRgb( BlendingEquation::SUBTRACT );
405 BlendingEquation::Type equationAlpha( BlendingEquation::SUBTRACT );
406 material.GetBlendEquation( equationRgb, equationAlpha );
407 DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION );
408 DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationAlpha, TEST_LOCATION );
411 // Render & check GL commands
412 application.SendNotification();
413 application.Render();
415 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
416 DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationRgb(), TEST_LOCATION );
417 DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationAlpha(), TEST_LOCATION );
422 int UtcDaliMaterialSetBlendMode01(void)
424 TestApplication application;
426 tet_infoline("Test setting the blend mode to on with an opaque color renders with blending enabled");
428 Geometry geometry = CreateQuadGeometry();
429 Material material = CreateMaterial(1.0f);
430 Renderer renderer = Renderer::New( geometry, material );
432 Actor actor = Actor::New();
433 actor.AddRenderer(renderer);
434 actor.SetSize(400, 400);
435 Stage::GetCurrent().Add(actor);
437 material.SetBlendMode(BlendingMode::ON);
439 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
440 glAbstraction.EnableCullFaceCallTrace(true);
442 application.SendNotification();
443 application.Render();
445 TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
446 std::ostringstream blendStr;
447 blendStr << GL_BLEND;
448 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
454 int UtcDaliMaterialSetBlendMode02(void)
456 TestApplication application;
458 tet_infoline("Test setting the blend mode to off with a transparent color renders with blending disabled (and not enabled)");
460 Geometry geometry = CreateQuadGeometry();
461 Material material = CreateMaterial(0.5f);
462 Renderer renderer = Renderer::New( geometry, material );
464 Actor actor = Actor::New();
465 actor.AddRenderer(renderer);
466 actor.SetSize(400, 400);
467 Stage::GetCurrent().Add(actor);
469 material.SetBlendMode(BlendingMode::OFF);
471 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
472 glAbstraction.EnableCullFaceCallTrace(true);
474 application.SendNotification();
475 application.Render();
477 TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
478 std::ostringstream blendStr;
479 blendStr << GL_BLEND;
480 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
485 int UtcDaliMaterialSetBlendMode03(void)
487 TestApplication application;
489 tet_infoline("Test setting the blend mode to auto with a transparent material color renders with blending enabled");
491 Geometry geometry = CreateQuadGeometry();
492 Material material = CreateMaterial(0.5f);
493 Renderer renderer = Renderer::New( geometry, material );
495 Actor actor = Actor::New();
496 actor.AddRenderer(renderer);
497 actor.SetSize(400, 400);
498 Stage::GetCurrent().Add(actor);
500 material.SetBlendMode(BlendingMode::AUTO);
502 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
503 glAbstraction.EnableCullFaceCallTrace(true);
505 application.SendNotification();
506 application.Render();
508 TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
509 std::ostringstream blendStr;
510 blendStr << GL_BLEND;
511 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
516 int UtcDaliMaterialSetBlendMode04(void)
518 TestApplication application;
520 tet_infoline("Test setting the blend mode to auto with an opaque color renders with blending disabled");
522 Geometry geometry = CreateQuadGeometry();
523 Material material = CreateMaterial(1.0f);
524 Renderer renderer = Renderer::New( geometry, material );
526 Actor actor = Actor::New();
527 actor.AddRenderer(renderer);
528 actor.SetSize(400, 400);
529 Stage::GetCurrent().Add(actor);
531 material.SetBlendMode(BlendingMode::AUTO);
533 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
534 glAbstraction.EnableCullFaceCallTrace(true);
536 application.SendNotification();
537 application.Render();
539 TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
540 std::ostringstream blendStr;
541 blendStr << GL_BLEND;
542 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
547 int UtcDaliMaterialSetBlendMode04b(void)
549 TestApplication application;
551 tet_infoline("Test setting the blend mode to auto with an opaque material color and a transparent actor color renders with blending enabled");
553 Geometry geometry = CreateQuadGeometry();
554 Material material = CreateMaterial(1.0f);
555 Renderer renderer = Renderer::New( geometry, material );
557 Actor actor = Actor::New();
558 actor.AddRenderer(renderer);
559 actor.SetSize(400, 400);
560 actor.SetColor( Vector4(1.0f, 0.0f, 1.0f, 0.5f) );
561 Stage::GetCurrent().Add(actor);
563 material.SetBlendMode(BlendingMode::AUTO);
565 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
566 glAbstraction.EnableCullFaceCallTrace(true);
568 application.SendNotification();
569 application.Render();
571 TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
572 std::ostringstream blendStr;
573 blendStr << GL_BLEND;
574 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
579 int UtcDaliMaterialSetBlendMode04c(void)
581 TestApplication application;
583 tet_infoline("Test setting the blend mode to auto with an opaque material color and an opaque actor color renders with blending disabled");
585 Geometry geometry = CreateQuadGeometry();
586 Material material = CreateMaterial(1.0f);
587 Renderer renderer = Renderer::New( geometry, material );
589 Actor actor = Actor::New();
590 actor.AddRenderer(renderer);
591 actor.SetSize(400, 400);
592 actor.SetColor( Color::MAGENTA );
593 Stage::GetCurrent().Add(actor);
595 material.SetBlendMode(BlendingMode::AUTO);
597 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
598 glAbstraction.EnableCullFaceCallTrace(true);
600 application.SendNotification();
601 application.Render();
603 TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
604 std::ostringstream blendStr;
605 blendStr << GL_BLEND;
606 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
611 int UtcDaliMaterialSetBlendMode05(void)
613 TestApplication application;
615 tet_infoline("Test setting the blend mode to auto with an opaque color and an image with an alpha channel renders with blending enabled");
617 Geometry geometry = CreateQuadGeometry();
618 BufferImage image = BufferImage::New( 40, 40, Pixel::RGBA8888 );
619 Material material = CreateMaterial(1.0f, image);
620 Renderer renderer = Renderer::New( geometry, material );
622 Actor actor = Actor::New();
623 actor.AddRenderer(renderer);
624 actor.SetSize(400, 400);
625 Stage::GetCurrent().Add(actor);
627 material.SetBlendMode(BlendingMode::AUTO);
629 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
630 glAbstraction.EnableCullFaceCallTrace(true);
632 application.SendNotification();
633 application.Render();
635 TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
636 std::ostringstream blendStr;
637 blendStr << GL_BLEND;
638 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
643 int UtcDaliMaterialSetBlendMode06(void)
645 TestApplication application;
646 tet_infoline("Test setting the blend mode to auto with an opaque color and an image without an alpha channel and a shader with the hint OUTPUT_IS_TRANSPARENT renders with blending enabled");
648 Geometry geometry = CreateQuadGeometry();
649 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_TRANSPARENT );
650 Material material = Material::New(shader);
651 material.SetProperty(Material::Property::COLOR, Color::WHITE);
653 Renderer renderer = Renderer::New( geometry, material );
655 Actor actor = Actor::New();
656 actor.AddRenderer(renderer);
657 actor.SetSize(400, 400);
658 Stage::GetCurrent().Add(actor);
660 material.SetBlendMode(BlendingMode::AUTO);
662 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
663 glAbstraction.EnableCullFaceCallTrace(true);
665 application.SendNotification();
666 application.Render();
668 TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
669 std::ostringstream blendStr;
670 blendStr << GL_BLEND;
671 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
677 //Todo: test the Shader::HINT_OUTPUT_IS_OPAQUE would disable the blending, the test cannot pass with current implementation
678 /*int UtcDaliMaterialSetBlendMode07(void)
680 TestApplication application;
681 tet_infoline("Test setting the blend mode to auto with a transparent color and an image without an alpha channel and a shader with the hint OUTPUT_IS_OPAQUE renders with blending disabled");
682 Geometry geometry = CreateQuadGeometry();
683 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
684 Material material = Material::New(shader);
685 material.SetProperty(Material::Property::COLOR, Color::TRANSPARENT);
687 Renderer renderer = Renderer::New( geometry, material );
689 Actor actor = Actor::New();
690 actor.AddRenderer(renderer);
691 actor.SetSize(400, 400);
692 Stage::GetCurrent().Add(actor);
694 material.SetBlendMode(BlendingMode::AUTO);
696 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
697 glAbstraction.EnableCullFaceCallTrace(true);
699 application.SendNotification();
700 application.Render();
702 TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
703 std::ostringstream blendStr;
704 blendStr << GL_BLEND;
705 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
710 int UtcDaliMaterialSetBlendMode08(void)
712 TestApplication application;
713 tet_infoline("Test setting the blend mode to auto with an opaque color and an image without an alpha channel and a shader with the hint OUTPUT_IS_OPAQUE renders with blending disabled");
715 Geometry geometry = CreateQuadGeometry();
716 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
717 Material material = Material::New(shader);
718 material.SetProperty(Material::Property::COLOR, Color::WHITE);
719 BufferImage image = BufferImage::New( 50, 50, Pixel::RGB888 );
720 material.AddTexture( image, "sTexture" );
721 Renderer renderer = Renderer::New( geometry, material );
723 Actor actor = Actor::New();
724 actor.AddRenderer(renderer);
725 actor.SetSize(400, 400);
726 Stage::GetCurrent().Add(actor);
728 material.SetBlendMode(BlendingMode::AUTO);
730 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
731 glAbstraction.EnableCullFaceCallTrace(true);
733 application.SendNotification();
734 application.Render();
736 TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
737 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", "GL_BLEND" ) );
742 int UtcDaliMaterialGetBlendMode(void)
744 TestApplication application;
746 tet_infoline("Test GetBlendMode()");
748 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
749 Material material = Material::New(shader);
752 DALI_TEST_EQUALS( material.GetBlendMode(), BlendingMode::OFF, TEST_LOCATION );
755 material.SetBlendMode(BlendingMode::AUTO);
756 DALI_TEST_EQUALS( material.GetBlendMode(), BlendingMode::AUTO, TEST_LOCATION );
759 material.SetBlendMode(BlendingMode::ON);
760 DALI_TEST_EQUALS( material.GetBlendMode(), BlendingMode::ON, TEST_LOCATION );
763 material.SetBlendMode(BlendingMode::OFF);
764 DALI_TEST_EQUALS( material.GetBlendMode(), BlendingMode::OFF, TEST_LOCATION );
769 int UtcDaliMaterialSetBlendColor(void)
771 TestApplication application;
773 tet_infoline("Test SetBlendColor(color)");
775 Geometry geometry = CreateQuadGeometry();
776 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
777 Material material = Material::New(shader);
778 material.SetProperty(Material::Property::COLOR, Color::WHITE);
779 BufferImage image = BufferImage::New( 50, 50, Pixel::RGBA8888 );
780 material.AddTexture( image, "sTexture" );
781 Renderer renderer = Renderer::New( geometry, material );
783 Actor actor = Actor::New();
784 actor.AddRenderer(renderer);
785 actor.SetSize(400, 400);
786 Stage::GetCurrent().Add(actor);
788 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
790 application.SendNotification();
791 application.Render();
792 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION );
794 material.SetBlendColor( Color::MAGENTA );
795 application.SendNotification();
796 application.Render();
797 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::MAGENTA, TEST_LOCATION );
799 Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
800 material.SetBlendColor( color );
801 application.SendNotification();
802 application.Render();
803 DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), color, TEST_LOCATION );
808 int UtcDaliMaterialGetBlendColor(void)
810 TestApplication application;
812 tet_infoline("Test GetBlendColor()");
814 Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
815 Material material = Material::New(shader);
817 DALI_TEST_EQUALS( material.GetBlendColor(), Color::TRANSPARENT, TEST_LOCATION );
819 material.SetBlendColor( Color::MAGENTA );
820 application.SendNotification();
821 application.Render();
822 DALI_TEST_EQUALS( material.GetBlendColor(), Color::MAGENTA, TEST_LOCATION );
824 Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
825 material.SetBlendColor( color );
826 application.SendNotification();
827 application.Render();
828 DALI_TEST_EQUALS( material.GetBlendColor(), color, TEST_LOCATION );
833 int UtcDaliMaterialConstraint(void)
835 TestApplication application;
837 tet_infoline("Test that a custom material property can be constrained");
839 Shader shader = Shader::New( "VertexSource", "FragmentSource");
840 Material material = Material::New( shader );
841 material.SetProperty(Material::Property::COLOR, Color::WHITE);
843 Geometry geometry = CreateQuadGeometry();
844 Renderer renderer = Renderer::New( geometry, material );
846 Actor actor = Actor::New();
847 actor.AddRenderer(renderer);
848 actor.SetSize(400, 400);
849 Stage::GetCurrent().Add(actor);
851 Vector4 initialColor = Color::WHITE;
852 Property::Index colorIndex = material.RegisterProperty( "uFadeColor", initialColor );
854 application.SendNotification();
855 application.Render(0);
856 DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
859 Constraint constraint = Constraint::New<Vector4>( material, colorIndex, TestConstraintNoBlue );
861 application.SendNotification();
862 application.Render(0);
864 // Expect no blue component in either buffer - yellow
865 DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
866 application.Render(0);
867 DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
869 material.RemoveConstraints();
870 material.SetProperty(colorIndex, Color::WHITE );
871 application.SendNotification();
872 application.Render(0);
873 DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION );
878 int UtcDaliMaterialConstraint02(void)
880 TestApplication application;
882 tet_infoline("Test that a uniform map material property can be constrained");
884 Shader shader = Shader::New( "VertexSource", "FragmentSource");
885 Material material = Material::New( shader );
886 material.SetProperty(Material::Property::COLOR, Color::WHITE);
888 Geometry geometry = CreateQuadGeometry();
889 Renderer renderer = Renderer::New( geometry, material );
891 Actor actor = Actor::New();
892 actor.AddRenderer(renderer);
893 actor.SetSize(400, 400);
894 Stage::GetCurrent().Add(actor);
895 application.SendNotification();
896 application.Render(0);
898 Vector4 initialColor = Color::WHITE;
899 Property::Index colorIndex = material.RegisterProperty( "uFadeColor", initialColor );
901 TestGlAbstraction& gl = application.GetGlAbstraction();
903 application.SendNotification();
904 application.Render(0);
906 Vector4 actualValue(Vector4::ZERO);
907 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
908 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
911 Constraint constraint = Constraint::New<Vector4>( material, colorIndex, TestConstraintNoBlue );
913 application.SendNotification();
914 application.Render(0);
916 // Expect no blue component in either buffer - yellow
917 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
918 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
920 application.Render(0);
921 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
922 DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
924 material.RemoveConstraints();
925 material.SetProperty(colorIndex, Color::WHITE );
926 application.SendNotification();
927 application.Render(0);
929 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
930 DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
935 int UtcDaliMaterialAnimatedProperty01(void)
937 TestApplication application;
939 tet_infoline("Test that a non-uniform material property can be animated");
941 Shader shader = Shader::New( "VertexSource", "FragmentSource");
942 Material material = Material::New( shader );
943 material.SetProperty(Material::Property::COLOR, Color::WHITE);
945 Geometry geometry = CreateQuadGeometry();
946 Renderer renderer = Renderer::New( geometry, material );
948 Actor actor = Actor::New();
949 actor.AddRenderer(renderer);
950 actor.SetSize(400, 400);
951 Stage::GetCurrent().Add(actor);
953 Vector4 initialColor = Color::WHITE;
954 Property::Index colorIndex = material.RegisterProperty( "uFadeColor", initialColor );
956 application.SendNotification();
957 application.Render(0);
958 DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
960 Animation animation = Animation::New(1.0f);
961 KeyFrames keyFrames = KeyFrames::New();
962 keyFrames.Add(0.0f, initialColor);
963 keyFrames.Add(1.0f, Color::TRANSPARENT);
964 animation.AnimateBetween( Property( material, colorIndex ), keyFrames );
967 application.SendNotification();
968 application.Render(500);
970 DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION );
972 application.Render(500);
974 DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION );
979 int UtcDaliMaterialAnimatedProperty02(void)
981 TestApplication application;
983 tet_infoline("Test that a uniform map material property can be animated");
985 Shader shader = Shader::New( "VertexSource", "FragmentSource");
986 Material material = Material::New( shader );
987 material.SetProperty(Material::Property::COLOR, Color::WHITE);
989 Geometry geometry = CreateQuadGeometry();
990 Renderer renderer = Renderer::New( geometry, material );
992 Actor actor = Actor::New();
993 actor.AddRenderer(renderer);
994 actor.SetSize(400, 400);
995 Stage::GetCurrent().Add(actor);
996 application.SendNotification();
997 application.Render(0);
999 Vector4 initialColor = Color::WHITE;
1000 Property::Index colorIndex = material.RegisterProperty( "uFadeColor", initialColor );
1002 TestGlAbstraction& gl = application.GetGlAbstraction();
1004 application.SendNotification();
1005 application.Render(0);
1007 Vector4 actualValue(Vector4::ZERO);
1008 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1009 DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
1011 Animation animation = Animation::New(1.0f);
1012 KeyFrames keyFrames = KeyFrames::New();
1013 keyFrames.Add(0.0f, initialColor);
1014 keyFrames.Add(1.0f, Color::TRANSPARENT);
1015 animation.AnimateBetween( Property( material, colorIndex ), keyFrames );
1018 application.SendNotification();
1019 application.Render(500);
1021 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1022 DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
1024 application.Render(500);
1025 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
1026 DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
1032 int UtcDaliMaterialSetTextureUniformName01(void)
1034 TestApplication application;
1036 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1038 Material material = CreateMaterial(1.0f);
1039 material.AddTexture( image, "sTexture" );
1041 int textureIndex = material.GetTextureIndex( "sTexture" );
1042 DALI_TEST_EQUALS( textureIndex, 0, TEST_LOCATION );
1044 material.SetTextureUniformName( 0, "sEffectTexture" );
1045 textureIndex = material.GetTextureIndex( "sEffectTexture" );
1046 DALI_TEST_EQUALS( textureIndex, 0, TEST_LOCATION );
1048 Geometry geometry = CreateQuadGeometry();
1049 Renderer renderer = Renderer::New( geometry, material );
1050 Actor actor = Actor::New();
1051 actor.AddRenderer(renderer);
1052 actor.SetParentOrigin( ParentOrigin::CENTER );
1053 actor.SetSize(400, 400);
1055 Stage::GetCurrent().Add( actor );
1057 TestGlAbstraction& gl = application.GetGlAbstraction();
1059 application.SendNotification();
1060 application.Render();
1063 DALI_TEST_CHECK( gl.GetUniformValue<int>( "sEffectTexture", textureUnit ) );
1064 DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
1069 int UtcDaliMaterialSetTextureUniformName02(void)
1071 TestApplication application;
1073 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1074 Image image2 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1076 Material material = CreateMaterial(1.0f);
1077 material.AddTexture( image, "sTexture");
1078 material.SetTextureUniformName( 0, "sEffectTexture" );
1079 material.AddTexture( image2, "sTexture2");
1081 int textureIndex = material.GetTextureIndex( "sEffectTexture" );
1082 DALI_TEST_EQUALS( textureIndex, 0, TEST_LOCATION );
1084 textureIndex = material.GetTextureIndex( "sTexture2" );
1085 DALI_TEST_EQUALS( textureIndex, 1, TEST_LOCATION );
1087 Geometry geometry = CreateQuadGeometry();
1088 Renderer renderer = Renderer::New( geometry, material );
1089 Actor actor = Actor::New();
1090 actor.AddRenderer(renderer);
1091 actor.SetParentOrigin( ParentOrigin::CENTER );
1092 actor.SetSize(400, 400);
1094 Stage::GetCurrent().Add( actor );
1096 TestGlAbstraction& gl = application.GetGlAbstraction();
1098 application.SendNotification();
1099 application.Render();
1102 DALI_TEST_CHECK( gl.GetUniformValue<int>( "sEffectTexture", textureUnit ) );
1103 DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
1105 DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture2", textureUnit ) );
1106 DALI_TEST_EQUALS( textureUnit, 1, TEST_LOCATION );
1111 int UtcDaliMaterialSetTextureAffectsTransparency(void)
1113 TestApplication application;
1115 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1117 Material material = CreateMaterial(1.0f);
1118 material.AddTexture( image, "sTexture" );
1120 Geometry geometry = CreateQuadGeometry();
1121 Renderer renderer = Renderer::New( geometry, material );
1122 Actor actor = Actor::New();
1123 actor.AddRenderer(renderer);
1124 actor.SetParentOrigin( ParentOrigin::CENTER );
1125 actor.SetSize(400, 400);
1126 Stage::GetCurrent().Add( actor );
1128 TestGlAbstraction& gl = application.GetGlAbstraction();
1130 // Test SetAffectsTransparency( false )
1131 material.SetTextureAffectsTransparency( 0, false );
1133 gl.EnableCullFaceCallTrace(true);
1134 application.SendNotification();
1135 application.Render();
1137 TraceCallStack& glEnableStack = gl.GetCullFaceTrace();
1138 std::ostringstream blendStr;
1139 blendStr << GL_BLEND;
1140 DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
1142 // Test SetAffectsTransparency( true )
1143 material.SetTextureAffectsTransparency( 0, true );
1145 glEnableStack.Reset();
1146 gl.EnableCullFaceCallTrace(true);
1147 application.SendNotification();
1148 application.Render();
1150 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
1155 int UtcDaliMaterialAddTexture01(void)
1157 TestApplication application;
1159 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1161 Material material = CreateMaterial(1.0f);
1162 material.AddTexture( image, "sTexture");
1164 Geometry geometry = CreateQuadGeometry();
1165 Renderer renderer = Renderer::New( geometry, material );
1166 Actor actor = Actor::New();
1167 actor.AddRenderer(renderer);
1168 actor.SetParentOrigin( ParentOrigin::CENTER );
1169 actor.SetSize(400, 400);
1171 Stage::GetCurrent().Add( actor );
1173 TestGlAbstraction& gl = application.GetGlAbstraction();
1175 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
1176 texParameterTrace.Reset();
1177 texParameterTrace.Enable( true );
1178 application.SendNotification();
1179 application.Render();
1182 DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture", textureUnit ) );
1183 DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
1185 texParameterTrace.Enable( false );
1188 // There are three calls to TexParameteri when the texture is first created
1189 // as the texture is using default sampling parametrers there shouldn't be any more calls to TexParameteri
1190 DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 3, TEST_LOCATION);
1195 int UtcDaliMaterialAddTexture02(void)
1197 TestApplication application;
1199 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1201 Material material = CreateMaterial(1.0f);
1203 Sampler sampler = Sampler::New();
1204 sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
1205 material.AddTexture( image, "sTexture", sampler );
1207 Geometry geometry = CreateQuadGeometry();
1208 Renderer renderer = Renderer::New( geometry, material );
1209 Actor actor = Actor::New();
1210 actor.AddRenderer(renderer);
1211 actor.SetParentOrigin( ParentOrigin::CENTER );
1212 actor.SetSize(400, 400);
1214 Stage::GetCurrent().Add( actor );
1216 TestGlAbstraction& gl = application.GetGlAbstraction();
1218 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
1219 texParameterTrace.Reset();
1220 texParameterTrace.Enable( true );
1221 application.SendNotification();
1222 application.Render();
1225 DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture", textureUnit ) );
1226 DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
1228 texParameterTrace.Enable( false );
1231 // There are three calls to TexParameteri when the texture is first created
1232 // Texture minification and magnification filters are now different than default so
1233 //there should have been two extra TexParameteri calls to set the new filter mode
1234 DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 4, TEST_LOCATION);
1239 int UtcDaliMaterialRemoveTexture(void)
1241 TestApplication application;
1243 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1245 Material material = CreateMaterial(1.0f);
1246 material.RemoveTexture(0);
1247 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 0, TEST_LOCATION );
1249 material.RemoveTexture(1);
1250 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 0, TEST_LOCATION );
1252 Sampler sampler = Sampler::New();
1253 sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
1254 material.AddTexture( image, "sTexture", sampler );
1255 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 1, TEST_LOCATION );
1257 material.RemoveTexture(1);
1258 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 1, TEST_LOCATION );
1260 material.RemoveTexture(0);
1261 DALI_TEST_EQUALS( material.GetNumberOfTextures(), 0, TEST_LOCATION );
1266 int UtcDaliMaterialSetSampler(void)
1268 TestApplication application;
1270 Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1272 Material material = CreateMaterial(1.0f);
1273 material.AddTexture( image, "sTexture");
1275 Geometry geometry = CreateQuadGeometry();
1276 Renderer renderer = Renderer::New( geometry, material );
1277 Actor actor = Actor::New();
1278 actor.AddRenderer(renderer);
1279 actor.SetParentOrigin( ParentOrigin::CENTER );
1280 actor.SetSize(400, 400);
1282 Stage::GetCurrent().Add( actor );
1284 TestGlAbstraction& gl = application.GetGlAbstraction();
1286 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
1287 texParameterTrace.Reset();
1288 texParameterTrace.Enable( true );
1289 application.SendNotification();
1290 application.Render();
1293 DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture", textureUnit ) );
1294 DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
1296 texParameterTrace.Enable( false );
1299 // There are three calls to TexParameteri when the texture is first created
1300 // as the texture is using default sampling parametrers there shouldn't be any more calls to TexParameteri
1301 DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 3, TEST_LOCATION);
1303 texParameterTrace.Reset();
1304 texParameterTrace.Enable( true );
1306 Sampler sampler = Sampler::New();
1307 sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
1308 material.SetTextureSampler(0, sampler );
1311 application.SendNotification();
1312 application.Render();
1314 texParameterTrace.Enable( false );
1317 //There should have been two calls to TexParameteri to set the new filtering mode
1318 DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 2, TEST_LOCATION);
1324 int UtcDaliMaterialGetTextureIndex(void)
1326 TestApplication application;
1328 Image image0 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1329 Image image1 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1330 Image image2 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1331 Image image3 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
1334 Material material = CreateMaterial(1.0f);
1335 material.AddTexture( image0, "sTexture0");
1336 material.AddTexture( image1, "sTexture1");
1337 material.AddTexture( image2, "sTexture2");
1338 material.AddTexture( image3, "sTexture3");
1340 int textureIndex = material.GetTextureIndex( "sTexture0" );
1341 DALI_TEST_EQUALS( textureIndex, 0, TEST_LOCATION );
1343 textureIndex = material.GetTextureIndex( "sTexture1" );
1344 DALI_TEST_EQUALS( textureIndex, 1, TEST_LOCATION );
1346 textureIndex = material.GetTextureIndex( "sTexture2" );
1347 DALI_TEST_EQUALS( textureIndex, 2, TEST_LOCATION );
1349 textureIndex = material.GetTextureIndex( "sTexture3" );
1350 DALI_TEST_EQUALS( textureIndex, 3, TEST_LOCATION );
1352 material.RemoveTexture(1);
1354 textureIndex = material.GetTextureIndex( "sTexture0" );
1355 DALI_TEST_EQUALS( textureIndex, 0, TEST_LOCATION );
1357 textureIndex = material.GetTextureIndex( "sTexture2" );
1358 DALI_TEST_EQUALS( textureIndex, 1, TEST_LOCATION );
1360 textureIndex = material.GetTextureIndex( "sTexture3" );
1361 DALI_TEST_EQUALS( textureIndex, 2, TEST_LOCATION );