END_TEST;
}
+int UtcDaliShaderDefaultProperties(void)
+{
+ TestApplication application;
+// from shader-impl.cpp
+// DALI_PROPERTY( "program", MAP, true, false, false, Dali::Shader::Property::PROGRAM )
+
+ Shader shader = Shader::New(VertexSource, FragmentSource);
+ DALI_TEST_EQUALS( shader.GetPropertyCount(), 1, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( shader.GetPropertyName( Shader::Property::PROGRAM ), "program", TEST_LOCATION );
+ DALI_TEST_EQUALS( shader.GetPropertyIndex( "program" ), (Property::Index)Shader::Property::PROGRAM, TEST_LOCATION );
+ DALI_TEST_EQUALS( shader.GetPropertyType( Shader::Property::PROGRAM ), Property::MAP, TEST_LOCATION );
+ DALI_TEST_EQUALS( shader.IsPropertyWritable( Shader::Property::PROGRAM ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( shader.IsPropertyAnimatable( Shader::Property::PROGRAM ), false, TEST_LOCATION );
+ DALI_TEST_EQUALS( shader.IsPropertyAConstraintInput( Shader::Property::PROGRAM ), false, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliShaderConstraint01(void)
{
TestApplication application;
Actor actor = Actor::New();
actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
Stage::GetCurrent().Add(actor);
Vector4 initialColor = Color::WHITE;
Actor actor = Actor::New();
actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
Stage::GetCurrent().Add(actor);
application.SendNotification();
application.Render(0);
Actor actor = Actor::New();
actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
Stage::GetCurrent().Add(actor);
Vector4 initialColor = Color::WHITE;
Actor actor = Actor::New();
actor.AddRenderer(renderer);
- actor.SetSize(400, 400);
+ actor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.0f ) );
Stage::GetCurrent().Add(actor);
application.SendNotification();
application.Render(0);
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
+ // change shader program
+ Property::Map map;
+ map["vertex"] = VertexSource;
+ map["fragment"] = FragmentSource;
+ map["hints"] = "MODIFIES_GEOMETRY";
+ shader.SetProperty( Shader::Property::PROGRAM, Property::Value(map) );
+ application.SendNotification();
+ application.Render(100);
+
+ // register another custom property as well
+ Property::Index customIndex = shader.RegisterProperty( "uCustom", Vector3(1,2,3) );
+ DALI_TEST_EQUALS( shader.GetProperty<Vector3>( customIndex ), Vector3(1,2,3), TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(100);
+
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+ DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
+
+ Vector3 customValue;
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector3>( "uCustom", customValue ) );
+ DALI_TEST_EQUALS( customValue, Vector3(1,2,3), TEST_LOCATION );
END_TEST;
}
map["hints"] = hintSet;
shader.SetProperty( Shader::Property::PROGRAM, Property::Value(map) );
+ // register a custom property as well
+ Property::Index customIndex = shader.RegisterProperty( "custom", Vector3(1,2,3) );
+ DALI_TEST_EQUALS( shader.GetProperty<Vector3>( customIndex ), Vector3(1,2,3), TEST_LOCATION );
Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
DALI_TEST_CHECK( value.GetType() == Property::MAP);
value = shader.GetCurrentProperty( Shader::Property::PROGRAM );
DALI_TEST_CHECK( value.GetType() == Property::MAP);
outMap = value.GetMap();
+ // check that changing the shader did not cause us to loose custom property
+ DALI_TEST_EQUALS( shader.GetProperty<Vector3>( customIndex ), Vector3(1,2,3), TEST_LOCATION );
+ using Dali::Animation;
+ Animation animation = Animation::New( 0.1f );
+ animation.AnimateTo( Property( shader, customIndex ), Vector3(4,5,6) );
+ animation.Play();
+ application.SendNotification();
+ application.Render(100);
+ DALI_TEST_EQUALS( shader.GetProperty<Vector3>( customIndex ), Vector3(4,5,6), TEST_LOCATION );
v = (*outMap)["vertex"].Get<std::string>();
f = (*outMap)["fragment"].Get<std::string>();