Merge "Updates following rename of PropertyBuffer" into devel/master
[platform/core/uifw/dali-demo.git] / examples / point-mesh / point-mesh-example.cpp
index 22d557d..16ce8c0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 
 // EXTERNAL INCLUDES
-#include <dali/devel-api/rendering/renderer.h>
 #include <dali-toolkit/dali-toolkit.h>
 
 // INTERNAL INCLUDES
 #include "shared/view.h"
+#include "shared/utility.h"
 
 using namespace Dali;
 
@@ -82,7 +82,7 @@ Geometry CreateGeometry()
   // Create vertices
   struct Vertex { Vector2 position; float hue; };
 
-  unsigned int numSides = 20;
+  const unsigned int numSides = 20;
   Vertex polyhedraVertexData[numSides];
   float angle=0;
   float sectorAngle = 2.0f * Math::PI / (float) numSides;
@@ -98,13 +98,13 @@ Geometry CreateGeometry()
   Property::Map polyhedraVertexFormat;
   polyhedraVertexFormat["aPosition"] = Property::VECTOR2;
   polyhedraVertexFormat["aHue"] = Property::FLOAT;
-  PropertyBuffer polyhedraVertices = PropertyBuffer::New( polyhedraVertexFormat );
+  VertexBuffer polyhedraVertices = VertexBuffer::New( polyhedraVertexFormat );
   polyhedraVertices.SetData( polyhedraVertexData, numSides );
 
   // Create the geometry object
   Geometry polyhedraGeometry = Geometry::New();
   polyhedraGeometry.AddVertexBuffer( polyhedraVertices );
-  polyhedraGeometry.SetGeometryType( Geometry::POINTS );
+  polyhedraGeometry.SetType( Geometry::POINTS );
 
   return polyhedraGeometry;
 }
@@ -142,24 +142,21 @@ public:
    */
   void Create( Application& application )
   {
-    Stage stage = Stage::GetCurrent();
-    stage.KeyEventSignal().Connect(this, &ExampleController::OnKeyEvent);
+    Window window = application.GetWindow();
+    window.KeyEventSignal().Connect(this, &ExampleController::OnKeyEvent);
 
-    mStageSize = stage.GetSize();
+    mWindowSize = window.GetSize();
 
     // The Init signal is received once (only) during the Application lifetime
 
-    // Hide the indicator bar
-    application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE );
-
-    Image image0 = ResourceImage::New( MATERIAL_SAMPLE );
-    Image image1 = ResourceImage::New( MATERIAL_SAMPLE2 );
+    Texture texture0 = DemoHelper::LoadTexture( MATERIAL_SAMPLE );
+    Texture texture1 = DemoHelper::LoadTexture( MATERIAL_SAMPLE2 );
 
     Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
 
     TextureSet textureSet = TextureSet::New();
-    textureSet.SetImage( 0u, image0 );
-    textureSet.SetImage( 1u, image1 );
+    textureSet.SetTexture( 0u, texture0 );
+    textureSet.SetTexture( 1u, texture1 );
 
     Geometry geometry = CreateGeometry();
 
@@ -168,7 +165,7 @@ public:
 
     mMeshActor = Actor::New();
     mMeshActor.AddRenderer( mRenderer );
-    mMeshActor.SetSize(400, 400);
+    mMeshActor.SetProperty( Actor::Property::SIZE, Vector2(400, 400) );
 
     mMeshActor.RegisterProperty( "uFadeColor", Color::GREEN );
 
@@ -176,9 +173,9 @@ public:
     mRenderer.RegisterProperty( "uPointSize", 80.0f );
     mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, 0 );
 
-    mMeshActor.SetParentOrigin( ParentOrigin::CENTER );
-    mMeshActor.SetAnchorPoint( AnchorPoint::CENTER );
-    stage.Add( mMeshActor );
+    mMeshActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+    mMeshActor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
+    window.Add( mMeshActor );
 
     Animation  animation = Animation::New(15);
     KeyFrames keyFrames = KeyFrames::New();
@@ -190,7 +187,7 @@ public:
     animation.SetLooping(true);
     animation.Play();
 
-    stage.SetBackgroundColor(Vector4(0.0f, 0.2f, 0.2f, 1.0f));
+    window.SetBackgroundColor(Vector4(0.0f, 0.2f, 0.2f, 1.0f));
   }
 
   /**
@@ -206,7 +203,7 @@ public:
 
   void OnKeyEvent(const KeyEvent& event)
   {
-    if(event.state == KeyEvent::Down)
+    if(event.GetState() == KeyEvent::Down)
     {
       if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
       {
@@ -218,7 +215,7 @@ public:
 private:
 
   Application&  mApplication;                             ///< Application instance
-  Vector3 mStageSize;                                     ///< The size of the stage
+  Vector3 mWindowSize;                                     ///< The size of the window
 
   Renderer mRenderer;
   Actor    mMeshActor;
@@ -227,20 +224,10 @@ private:
   Timer    mChangeImageTimer;
 };
 
-void RunTest( Application& application )
-{
-  ExampleController test( application );
-
-  application.MainLoop();
-}
-
-// Entry point for Linux & SLP applications
-//
 int DALI_EXPORT_API main( int argc, char **argv )
 {
   Application application = Application::New( &argc, &argv );
-
-  RunTest( application );
-
+  ExampleController test( application );
+  application.MainLoop();
   return 0;
 }