[dali_1.1.21] Merge branch 'devel/master'
[platform/core/uifw/dali-demo.git] / examples / textured-mesh / textured-mesh-example.cpp
index 04b3e7b..a586a07 100644 (file)
@@ -26,8 +26,8 @@ using namespace Dali;
 
 namespace
 {
-const char* MATERIAL_SAMPLE( DALI_IMAGE_DIR "gallery-small-48.jpg" );
-const char* MATERIAL_SAMPLE2( DALI_IMAGE_DIR "gallery-medium-19.jpg" );
+const char* MATERIAL_SAMPLE( DEMO_IMAGE_DIR "gallery-small-48.jpg" );
+const char* MATERIAL_SAMPLE2( DEMO_IMAGE_DIR "gallery-medium-19.jpg" );
 
 #define MAKE_SHADER(A)#A
 
@@ -81,7 +81,7 @@ Geometry CreateGeometry()
   // Create indices
   unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 };
   Property::Map indexFormat;
-  indexFormat["indices"] = Property::UNSIGNED_INTEGER;
+  indexFormat["indices"] = Property::INTEGER;
   PropertyBuffer indices = PropertyBuffer::New( indexFormat, sizeof(indexData)/sizeof(indexData[0]) );
   indices.SetData(indexData);
 
@@ -144,18 +144,15 @@ public:
     // Hide the indicator bar
     application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
 
-    mImage = ResourceImage::New( MATERIAL_SAMPLE, ResourceImage::ON_DEMAND, Image::NEVER );
-    mSampler1 = Sampler::New(mImage, "sTexture");
-
+    mImage = ResourceImage::New( MATERIAL_SAMPLE );
     Image image = ResourceImage::New( MATERIAL_SAMPLE2 );
-    mSampler2 = Sampler::New(image, "sTexture");
 
     mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
     mMaterial1 = Material::New( mShader );
-    mMaterial1.AddSampler( mSampler1 );
+    mMaterial1.AddTexture(mImage, "sTexture");
 
     mMaterial2 = Material::New( mShader );
-    mMaterial2.AddSampler( mSampler2 );
+    mMaterial2.AddTexture(image, "sTexture");
 
     mGeometry = CreateGeometry();
 
@@ -165,10 +162,8 @@ public:
     mMeshActor.AddRenderer( mRenderer );
     mMeshActor.SetSize(400, 400);
 
-    Property::Index fadeColorIndex = mMeshActor.RegisterProperty( "uFadeColor", Color::GREEN );
-
-    fadeColorIndex = mRenderer.RegisterProperty( "uFadeColor", Color::MAGENTA );
-    mRenderer.SetDepthIndex(0);
+    Property::Index fadeColorIndex = mRenderer.RegisterProperty( "uFadeColor", Color::MAGENTA );
+    mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
 
     mMeshActor.SetParentOrigin( ParentOrigin::TOP_CENTER );
     mMeshActor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
@@ -180,13 +175,12 @@ public:
     mMeshActor2.AddRenderer( mRenderer2 );
     mMeshActor2.SetSize(400, 400);
 
-    mMeshActor2.RegisterProperty( "a-n-other-property", Color::GREEN );
-    Property::Index fadeColorIndex2 = mMeshActor2.RegisterProperty( "uFadeColor", Color::GREEN );
+    mMeshActor2.RegisterProperty( "anotherProperty",    Color::GREEN );
 
-    mRenderer2.RegisterProperty( "a-n-other-property", Vector3::ZERO );
-    mRenderer2.RegisterProperty( "a-coefficient", 0.008f );
-    fadeColorIndex2 = mRenderer2.RegisterProperty( "uFadeColor", Color::BLUE );
-    mRenderer2.SetDepthIndex(0);
+    mRenderer2.RegisterProperty( "anotherProperty",    Vector3::ZERO );
+    mRenderer2.RegisterProperty( "aCoefficient",  0.008f );
+    Property::Index fadeColorIndex2 = mRenderer2.RegisterProperty( "uFadeColor", Color::BLUE );
+    mRenderer2.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
 
     mMeshActor2.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
     mMeshActor2.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
@@ -206,7 +200,7 @@ public:
     animation.SetLooping(true);
     animation.Play();
 
-    stage.SetBackgroundColor(Vector4(0.0f, 0.2f, 0.2f, 1.0f));;
+    stage.SetBackgroundColor(Vector4(0.0f, 0.2f, 0.2f, 1.0f));
   }
 
   BufferImage CreateBufferImage()
@@ -267,8 +261,6 @@ private:
   Vector3 mStageSize;                                     ///< The size of the stage
 
   Image    mImage;
-  Sampler  mSampler1;
-  Sampler  mSampler2;
   Shader   mShader;
   Material mMaterial1;
   Material mMaterial2;