[dali_1.1.30] Merge branch 'devel/master'
[platform/core/uifw/dali-demo.git] / examples / line-mesh / line-mesh-example.cpp
index 6d8b423..8916928 100644 (file)
  */
 
 // EXTERNAL INCLUDES
+#include <dali/devel-api/rendering/renderer.h>
+#include <dali-toolkit/dali-toolkit.h>
 
 // INTERNAL INCLUDES
 #include "shared/view.h"
 
-#include <dali-toolkit/dali-toolkit.h>
-
 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" );
 
 #define MAKE_SHADER(A)#A
 
@@ -82,20 +80,20 @@ Geometry CreateGeometry()
 
   Property::Map pentagonVertexFormat;
   pentagonVertexFormat["aPosition1"] = Property::VECTOR2;
-  PropertyBuffer pentagonVertices = PropertyBuffer::New( pentagonVertexFormat, 5 );
-  pentagonVertices.SetData(pentagonVertexData);
+  PropertyBuffer pentagonVertices = PropertyBuffer::New( pentagonVertexFormat );
+  pentagonVertices.SetData(pentagonVertexData, 5);
 
   Property::Map pentacleVertexFormat;
   pentacleVertexFormat["aPosition2"] = Property::VECTOR2;
-  PropertyBuffer pentacleVertices = PropertyBuffer::New( pentacleVertexFormat, 5 );
-  pentacleVertices.SetData(pentacleVertexData);
+  PropertyBuffer pentacleVertices = PropertyBuffer::New( pentacleVertexFormat );
+  pentacleVertices.SetData( pentacleVertexData, 5 );
 
   // Create indices
   unsigned int indexData[10] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 0 };
   Property::Map indexFormat;
-  indexFormat["indices"] = Property::UNSIGNED_INTEGER;
-  PropertyBuffer indices = PropertyBuffer::New( indexFormat, sizeof(indexData)/sizeof(indexData[0]) );
-  indices.SetData(indexData);
+  indexFormat["indices"] = Property::INTEGER;
+  PropertyBuffer indices = PropertyBuffer::New( indexFormat );
+  indices.SetData( indexData, sizeof(indexData)/sizeof(indexData[0]) );
 
   // Create the geometry object
   Geometry pentagonGeometry = Geometry::New();
@@ -151,12 +149,9 @@ public:
     // Hide the indicator bar
     application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
 
-    mImage = ResourceImage::New( MATERIAL_SAMPLE );
-    mSampler = Sampler::New(mImage, "sTexture");
     mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
 
     mMaterial = Material::New( mShader );
-    mMaterial.AddSampler( mSampler );
 
     mGeometry = CreateGeometry();
 
@@ -168,16 +163,12 @@ public:
 
     Property::Index morphAmountIndex = mMeshActor.RegisterProperty( "uMorphAmount", 0.0f );
 
-    mRenderer.SetDepthIndex(0);
+    mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
 
     mMeshActor.SetParentOrigin( ParentOrigin::CENTER );
     mMeshActor.SetAnchorPoint( AnchorPoint::CENTER );
     stage.Add( mMeshActor );
 
-    mChangeImageTimer = Timer::New( 5000 );
-    mChangeImageTimer.TickSignal().Connect( this, &ExampleController::OnTimer );
-    mChangeImageTimer.Start();
-
     Animation  animation = Animation::New(5);
     KeyFrames keyFrames = KeyFrames::New();
     keyFrames.Add(0.0f, 0.0f);
@@ -187,7 +178,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));
   }
 
   /**
@@ -201,13 +192,6 @@ public:
     return true;
   }
 
-  bool OnTimer()
-  {
-    Image image = ResourceImage::New( MATERIAL_SAMPLE2 );
-    mSampler.SetImage( image );
-    return false;
-  }
-
   void OnKeyEvent(const KeyEvent& event)
   {
     if(event.state == KeyEvent::Down)
@@ -224,16 +208,11 @@ private:
   Application&  mApplication;                             ///< Application instance
   Vector3 mStageSize;                                     ///< The size of the stage
 
-  Image    mImage;
-  Sampler  mSampler;
   Shader   mShader;
   Material mMaterial;
   Geometry mGeometry;
   Renderer mRenderer;
   Actor    mMeshActor;
-  Renderer mRenderer2;
-  Actor    mMeshActor2;
-  Timer    mChangeImageTimer;
 };
 
 void RunTest( Application& application )