- Geometry geometry = CreateQuadGeometry();
- BufferImage image = BufferImage::New( 40, 40, Pixel::RGBA8888 );
- Material material = CreateMaterial(1.0f, image);
- Renderer renderer = Renderer::New( geometry, material );
-
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
- Stage::GetCurrent().Add(actor);
-
- material.SetBlendMode(BlendingMode::AUTO);
-
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
-
- application.SendNotification();
- application.Render();
-
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
-
- END_TEST;
-}
-
-int UtcDaliMaterialSetBlendMode06(void)
-{
- TestApplication application;
- 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");
-
- Geometry geometry = CreateQuadGeometry();
- Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_TRANSPARENT );
- Material material = Material::New(shader);
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
-
- Renderer renderer = Renderer::New( geometry, material );
-
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
- Stage::GetCurrent().Add(actor);
-
- material.SetBlendMode(BlendingMode::AUTO);
-
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
-
- application.SendNotification();
- application.Render();
-
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
-
- END_TEST;
-}
-
-
-//Todo: test the Shader::HINT_OUTPUT_IS_OPAQUE would disable the blending, the test cannot pass with current implementation
-/*int UtcDaliMaterialSetBlendMode07(void)
-{
- TestApplication application;
- 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");
- Geometry geometry = CreateQuadGeometry();
- Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
- Material material = Material::New(shader);
- material.SetProperty(Material::Property::COLOR, Color::TRANSPARENT);
-
- Renderer renderer = Renderer::New( geometry, material );
-
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
- Stage::GetCurrent().Add(actor);
-
- material.SetBlendMode(BlendingMode::AUTO);
-
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
-
- application.SendNotification();
- application.Render();
-
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
-
- END_TEST;
-}*/
-
-int UtcDaliMaterialSetBlendMode08(void)
-{
- TestApplication application;
- 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");
-
- Geometry geometry = CreateQuadGeometry();
- Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
- Material material = Material::New(shader);
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
- BufferImage image = BufferImage::New( 50, 50, Pixel::RGB888 );
- Sampler sampler = Sampler::New( image, "sTexture" );
- material.AddSampler( sampler );
- Renderer renderer = Renderer::New( geometry, material );
-
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
- Stage::GetCurrent().Add(actor);
-
- material.SetBlendMode(BlendingMode::AUTO);
-
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
-
- application.SendNotification();
- application.Render();
-
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
- std::ostringstream blendStr;
- blendStr << GL_BLEND;
- DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
-
- END_TEST;
-}
-
-int UtcDaliMaterialGetBlendMode(void)
-{
- TestApplication application;
-
- tet_infoline("Test GetBlendMode()");
-
- Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
- Material material = Material::New(shader);
-
- // default value
- DALI_TEST_EQUALS( material.GetBlendMode(), BlendingMode::OFF, TEST_LOCATION );
-
- // AUTO
- material.SetBlendMode(BlendingMode::AUTO);
- DALI_TEST_EQUALS( material.GetBlendMode(), BlendingMode::AUTO, TEST_LOCATION );
-
- // ON
- material.SetBlendMode(BlendingMode::ON);
- DALI_TEST_EQUALS( material.GetBlendMode(), BlendingMode::ON, TEST_LOCATION );
-
- // OFF
- material.SetBlendMode(BlendingMode::OFF);
- DALI_TEST_EQUALS( material.GetBlendMode(), BlendingMode::OFF, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliMaterialSetBlendColor(void)
-{
- TestApplication application;
-
- tet_infoline("Test SetBlendColor(color)");
-
- Geometry geometry = CreateQuadGeometry();
- Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
- Material material = Material::New(shader);
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
- BufferImage image = BufferImage::New( 50, 50, Pixel::RGBA8888 );
- Sampler sampler = Sampler::New( image, "sTexture" );
- material.AddSampler( sampler );
- Renderer renderer = Renderer::New( geometry, material );
-
- Actor actor = Actor::New();
- actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
- Stage::GetCurrent().Add(actor);
-
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
-
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION );
-
- material.SetBlendColor( Color::MAGENTA );
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::MAGENTA, TEST_LOCATION );
-
- Vector4 color( 0.1f, 0.2f, 0.3f, 0.4f );
- material.SetBlendColor( color );
- application.SendNotification();
- application.Render();
- DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), color, TEST_LOCATION );