Merge "Simple TextEditor demo." into devel/master
[platform/core/uifw/dali-demo.git] / examples / refraction-effect / refraction-effect-example.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // EXTERNAL INCLUDES
19 #include <dali/dali.h>
20 #include <dali/devel-api/rendering/renderer.h>
21 #include <dali-toolkit/dali-toolkit.h>
22
23 #include <fstream>
24 #include <sstream>
25 #include <limits>
26
27 // INTERNAL INCLUDES
28 #include "shared/view.h"
29
30 using namespace Dali;
31
32 namespace
33 {
34 const char * const APPLICATION_TITLE( "Refraction Effect" );
35 const char * const TOOLBAR_IMAGE( DEMO_IMAGE_DIR "top-bar.png" );
36 const char * const CHANGE_TEXTURE_ICON( DEMO_IMAGE_DIR "icon-change.png" );
37 const char * const CHANGE_TEXTURE_ICON_SELECTED( DEMO_IMAGE_DIR "icon-change-selected.png" );
38 const char * const CHANGE_MESH_ICON( DEMO_IMAGE_DIR "icon-replace.png" );
39 const char * const CHANGE_MESH_ICON_SELECTED( DEMO_IMAGE_DIR "icon-replace-selected.png" );
40
41 const char* MESH_FILES[] =
42 {
43  DEMO_MODEL_DIR "surface_pattern_v01.obj",
44  DEMO_MODEL_DIR "surface_pattern_v02.obj"
45 };
46 const unsigned int NUM_MESH_FILES( sizeof( MESH_FILES ) / sizeof( MESH_FILES[0] ) );
47
48 const char* TEXTURE_IMAGES[]=
49 {
50   DEMO_IMAGE_DIR "background-1.jpg",
51   DEMO_IMAGE_DIR "background-2.jpg",
52   DEMO_IMAGE_DIR "background-3.jpg",
53   DEMO_IMAGE_DIR "background-4.jpg"
54 };
55 const unsigned int NUM_TEXTURE_IMAGES( sizeof( TEXTURE_IMAGES ) / sizeof( TEXTURE_IMAGES[0] ) );
56
57 struct LightOffsetConstraint
58 {
59   LightOffsetConstraint( float radius )
60   : mRadius( radius )
61   {
62   }
63
64   void operator()( Vector2& current, const PropertyInputContainer& inputs )
65   {
66     float spinAngle = inputs[0]->GetFloat();
67     current.x = cos( spinAngle );
68     current.y = sin( spinAngle );
69
70     current *= mRadius;
71   }
72
73   float mRadius;
74 };
75
76 /**
77  * @brief Load an image, scaled-down to no more than the stage dimensions.
78  *
79  * Uses image scaling mode SCALE_TO_FILL to resize the image at
80  * load time to cover the entire stage with pixels with no borders,
81  * and filter mode BOX_THEN_LINEAR to sample the image with maximum quality.
82  */
83 ResourceImage LoadStageFillingImage( const char * const imagePath )
84 {
85   Size stageSize = Stage::GetCurrent().GetSize();
86   return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR );
87 }
88
89 /**
90  * structure of the vertex in the mesh
91  */
92 struct Vertex
93 {
94   Vector3 position;
95   Vector3 normal;
96   Vector2 textureCoord;
97
98   Vertex()
99   {}
100
101   Vertex( const Vector3& position, const Vector3& normal, const Vector2& textureCoord )
102   : position( position ), normal( normal ), textureCoord( textureCoord )
103   {}
104 };
105
106 /************************************************************************************************
107  *** The shader source is used when the MeshActor is not touched***
108  ************************************************************************************************/
109 const char* VERTEX_SHADER_FLAT = DALI_COMPOSE_SHADER(
110 attribute mediump vec3    aPosition;\n
111 attribute mediump vec3    aNormal;\n
112 attribute highp   vec2    aTexCoord;\n
113 uniform   mediump mat4    uMvpMatrix;\n
114 varying   mediump vec2    vTexCoord;\n
115 void main()\n
116 {\n
117   gl_Position = uMvpMatrix * vec4( aPosition.xy, 0.0, 1.0 );\n
118   vTexCoord = aTexCoord.xy;\n
119 }\n
120 );
121
122 const char* FRAGMENT_SHADER_FLAT = DALI_COMPOSE_SHADER(
123 uniform lowp    vec4  uColor;\n
124 uniform sampler2D     sTexture;\n
125 varying mediump vec2  vTexCoord;\n
126 void main()\n
127 {\n
128   gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
129 }\n
130 );
131
132 /************************************************************
133  ** Custom refraction effect shader***************************
134  ************************************************************/
135 const char* VERTEX_SHADER_REFRACTION = DALI_COMPOSE_SHADER(
136 attribute mediump vec3    aPosition;\n
137 attribute mediump vec3    aNormal;\n
138 attribute highp   vec2    aTexCoord;\n
139 uniform   mediump mat4    uMvpMatrix;\n
140 varying   mediump vec4    vVertex;\n
141 varying   mediump vec3    vNormal;\n
142 varying   mediump vec2    vTexCoord;\n
143 varying   mediump vec2    vTextureOffset;\n
144 void main()\n
145 {\n
146   gl_Position = uMvpMatrix * vec4( aPosition.xy, 0.0, 1.0 );\n
147   vTexCoord = aTexCoord.xy;\n
148
149   vNormal = aNormal;\n
150   vVertex = vec4( aPosition, 1.0 );\n
151   float length = max(0.01, length(aNormal.xy)) * 40.0;\n
152   vTextureOffset = aNormal.xy / length;\n
153 }\n
154 );
155
156 const char* FRAGMENT_SHADER_REFRACTION = DALI_COMPOSE_SHADER(
157 precision mediump float;\n
158 uniform   mediump float  uEffectStrength;\n
159 uniform   mediump vec3   uLightPosition;\n
160 uniform   mediump vec2   uLightXYOffset;\n
161 uniform   mediump vec2   uLightSpinOffset;\n
162 uniform   mediump float  uLightIntensity;\n
163 uniform   lowp    vec4   uColor;\n
164 uniform   sampler2D      sTexture;\n
165 varying   mediump vec4   vVertex;\n
166 varying   mediump vec3   vNormal;\n
167 varying   mediump vec2   vTexCoord;\n
168 varying   mediump vec2   vTextureOffset;\n
169
170 vec3 rgb2hsl(vec3 rgb)\n
171 {\n
172   float epsilon = 1.0e-10;\n
173   vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n
174   vec4 P = mix(vec4(rgb.bg, K.wz), vec4(rgb.gb, K.xy), step(rgb.b, rgb.g));\n
175   vec4 Q = mix(vec4(P.xyw, rgb.r), vec4(rgb.r, P.yzx), step(P.x, rgb.r));\n
176   \n
177   // RGB -> HCV
178   float value = Q.x;\n
179   float chroma = Q.x - min(Q.w, Q.y);\n
180   float hue = abs(Q.z + (Q.w-Q.y) / (6.0*chroma+epsilon));\n
181   // HCV -> HSL
182   float lightness = value - chroma*0.5;\n
183   return vec3( hue, chroma/max( 1.0-abs(lightness*2.0-1.0), 1.0e-1 ), lightness );\n
184 }\n
185
186 vec3 hsl2rgb( vec3 hsl )\n
187 {\n
188   // pure hue->RGB
189   vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n
190   vec3 p = abs(fract(hsl.xxx + K.xyz) * 6.0 - K.www);\n
191   vec3 RGB = clamp(p - K.xxx, 0.0, 1.0);\n
192   \n
193   float chroma = ( 1.0 - abs( hsl.z*2.0-1.0 ) ) * hsl.y;\n
194   return ( RGB - 0.5 ) * chroma + hsl.z;\n
195 }\n
196
197 void main()\n
198 {\n
199   vec3 normal = normalize( vNormal);\n
200
201   vec3 lightPosition = uLightPosition + vec3(uLightXYOffset+uLightSpinOffset, 0.0);\n
202   mediump vec3 vecToLight = normalize( (lightPosition - vVertex.xyz) * 0.01 );\n
203   mediump float spotEffect = pow( max(0.05, vecToLight.z ) - 0.05, 8.0);\n
204
205   spotEffect = spotEffect * uEffectStrength;\n
206   mediump float lightDiffuse = ( ( dot( vecToLight, normal )-0.75 ) *uLightIntensity  ) * spotEffect;\n
207
208   lowp vec4 color = texture2D( sTexture, vTexCoord + vTextureOffset * spotEffect );\n
209   vec3 lightedColor =  hsl2rgb( rgb2hsl(color.rgb) + vec3(0.0,0.0,lightDiffuse) );\n
210
211   gl_FragColor = vec4( lightedColor, color.a ) * uColor;\n
212 }\n
213 );
214
215 } // namespace
216
217
218 /*************************************************/
219 /*Demo using RefractionEffect*****************/
220 /*************************************************/
221 class RefractionEffectExample : public ConnectionTracker
222 {
223 public:
224   RefractionEffectExample( Application &application )
225   : mApplication( application ),
226     mCurrentTextureId( 1 ),
227     mCurrentMeshId( 0 )
228   {
229     // Connect to the Application's Init signal
230     application.InitSignal().Connect(this, &RefractionEffectExample::Create);
231   }
232
233   ~RefractionEffectExample()
234   {
235   }
236
237 private:
238
239   // The Init signal is received once (only) during the Application lifetime
240   void Create(Application& application)
241   {
242     Stage stage = Stage::GetCurrent();
243     Vector2 stageSize = stage.GetSize();
244
245     stage.KeyEventSignal().Connect(this, &RefractionEffectExample::OnKeyEvent);
246
247     // Creates a default view with a default tool bar.
248     // The view is added to the stage.
249     Toolkit::ToolBar toolBar;
250     Toolkit::Control    view;
251     mContent = DemoHelper::CreateView( application,
252         view,
253         toolBar,
254         "",
255         TOOLBAR_IMAGE,
256         APPLICATION_TITLE );
257
258     // Add a button to change background. (right of toolbar)
259     mChangeTextureButton = Toolkit::PushButton::New();
260     mChangeTextureButton.SetUnselectedImage( CHANGE_TEXTURE_ICON );
261     mChangeTextureButton.SetSelectedImage( CHANGE_TEXTURE_ICON_SELECTED );
262     mChangeTextureButton.ClickedSignal().Connect( this, &RefractionEffectExample::OnChangeTexture );
263     toolBar.AddControl( mChangeTextureButton,
264                         DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage,
265                         Toolkit::Alignment::HorizontalRight,
266                         DemoHelper::DEFAULT_MODE_SWITCH_PADDING  );
267     // Add a button to change mesh pattern. ( left of bar )
268     mChangeMeshButton = Toolkit::PushButton::New();
269     mChangeMeshButton.SetUnselectedImage( CHANGE_MESH_ICON );
270     mChangeMeshButton.SetSelectedImage( CHANGE_MESH_ICON_SELECTED );
271     mChangeMeshButton.ClickedSignal().Connect( this, &RefractionEffectExample::OnChangeMesh );
272     toolBar.AddControl( mChangeMeshButton,
273                         DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage,
274                         Toolkit::Alignment::HorizontalLeft,
275                         DemoHelper::DEFAULT_MODE_SWITCH_PADDING  );
276
277
278
279     // shader used when the screen is not touched, render a flat surface
280     mShaderFlat = Shader::New( VERTEX_SHADER_FLAT, FRAGMENT_SHADER_FLAT );
281     mGeometry = CreateGeometry( MESH_FILES[mCurrentMeshId] );
282
283     Image texture = LoadStageFillingImage( TEXTURE_IMAGES[mCurrentTextureId] );
284     mTextureSet = TextureSet::New();
285     mTextureSet.SetImage( 0u, texture );
286
287     mRenderer = Renderer::New( mGeometry, mShaderFlat );
288     mRenderer.SetTextures( mTextureSet );
289
290     mMeshActor = Actor::New();
291     mMeshActor.AddRenderer( mRenderer );
292     mMeshActor.SetSize( stageSize );
293     mMeshActor.SetParentOrigin(ParentOrigin::CENTER);
294     mContent.Add( mMeshActor );
295
296     // Connect the callback to the touch signal on the mesh actor
297     mContent.TouchSignal().Connect( this, &RefractionEffectExample::OnTouch );
298
299     // shader used when the finger is touching the screen. render refraction effect
300     mShaderRefraction = Shader::New( VERTEX_SHADER_REFRACTION, FRAGMENT_SHADER_REFRACTION );
301
302     // register uniforms
303     mLightXYOffsetIndex = mMeshActor.RegisterProperty( "uLightXYOffset", Vector2::ZERO );
304
305     mLightIntensityIndex = mMeshActor.RegisterProperty( "uLightIntensity", 2.5f );
306
307     mEffectStrengthIndex = mMeshActor.RegisterProperty( "uEffectStrength",  0.f );
308
309     Vector3 lightPosition( -stageSize.x*0.5f, -stageSize.y*0.5f, stageSize.x*0.5f ); // top_left
310     mMeshActor.RegisterProperty( "uLightPosition", lightPosition );
311
312     Property::Index lightSpinOffsetIndex = mMeshActor.RegisterProperty( "uLightSpinOffset", Vector2::ZERO );
313
314     mSpinAngleIndex = mMeshActor.RegisterProperty("uSpinAngle", 0.f );
315     Constraint constraint = Constraint::New<Vector2>( mMeshActor, lightSpinOffsetIndex, LightOffsetConstraint(stageSize.x*0.1f) );
316     constraint.AddSource( LocalSource(mSpinAngleIndex) );
317     constraint.Apply();
318
319     // the animation which spin the light around the finger touch position
320     mLightAnimation = Animation::New(2.f);
321     mLightAnimation.AnimateTo( Property( mMeshActor, mSpinAngleIndex ), Math::PI*2.f );
322     mLightAnimation.SetLooping( true );
323     mLightAnimation.Pause();
324   }
325
326   void SetLightXYOffset( const Vector2& offset )
327   {
328     mMeshActor.SetProperty( mLightXYOffsetIndex,  offset );
329   }
330
331   /**
332    * Create a mesh actor with different geometry to replace the current one
333    */
334   bool OnChangeMesh( Toolkit::Button button  )
335   {
336     mCurrentMeshId = ( mCurrentMeshId + 1 ) % NUM_MESH_FILES;
337     mGeometry = CreateGeometry( MESH_FILES[mCurrentMeshId] );
338     mRenderer.SetGeometry( mGeometry );
339
340     return true;
341   }
342
343   bool OnChangeTexture( Toolkit::Button button )
344   {
345     mCurrentTextureId = ( mCurrentTextureId + 1 ) % NUM_TEXTURE_IMAGES;
346     Image texture = LoadStageFillingImage( TEXTURE_IMAGES[mCurrentTextureId] );
347     mTextureSet.SetImage( 0u, texture );
348     return true;
349   }
350
351   bool OnTouch( Actor actor, const TouchData& event )
352   {
353     switch( event.GetState( 0 ) )
354     {
355       case PointState::DOWN:
356       {
357         mRenderer.SetShader( mShaderRefraction );
358
359         SetLightXYOffset( event.GetScreenPosition( 0 ) );
360
361         mLightAnimation.Play();
362
363         if( mStrenghAnimation )
364         {
365           mStrenghAnimation.Clear();
366         }
367
368         mStrenghAnimation= Animation::New(0.5f);
369         mStrenghAnimation.AnimateTo( Property( mMeshActor, mEffectStrengthIndex ), 1.f );
370         mStrenghAnimation.Play();
371
372         break;
373       }
374       case PointState::MOTION:
375       {
376         // make the light position following the finger movement
377         SetLightXYOffset( event.GetScreenPosition( 0 ) );
378         break;
379       }
380       case PointState::UP:
381       case PointState::LEAVE:
382       case PointState::INTERRUPTED:
383       {
384         mLightAnimation.Pause();
385
386         if( mStrenghAnimation )
387         {
388           mStrenghAnimation.Clear();
389         }
390         mStrenghAnimation = Animation::New(0.5f);
391         mStrenghAnimation.AnimateTo( Property( mMeshActor, mEffectStrengthIndex ), 0.f );
392         mStrenghAnimation.FinishedSignal().Connect( this, &RefractionEffectExample::OnTouchFinished );
393         mStrenghAnimation.Play();
394         break;
395       }
396       case PointState::STATIONARY:
397       {
398         break;
399       }
400     }
401
402     return true;
403   }
404
405   void OnTouchFinished( Animation& source )
406   {
407     mRenderer.SetShader( mShaderFlat );
408     SetLightXYOffset( Vector2::ZERO );
409   }
410
411   Geometry CreateGeometry(const std::string& objFileName)
412   {
413     std::vector<Vector3> vertexPositions;
414     Vector<unsigned int> faceIndices;
415     Vector<float> boundingBox;
416     // read the vertice and faces from the .obj file, and record the bounding box
417     ReadObjFile( objFileName, boundingBox, vertexPositions, faceIndices );
418
419     std::vector<Vector2> textureCoordinates;
420     // align the mesh, scale it to fit the screen size, and calculate the texture coordinate for each vertex
421     ShapeResizeAndTexureCoordinateCalculation( boundingBox, vertexPositions, textureCoordinates );
422
423     // re-organize the mesh, the vertices are duplicated, each vertex only belongs to one triangle.
424     // Without sharing vertex between triangle, so we can manipulate the texture offset on each triangle conveniently.
425     std::vector<Vertex> vertices;
426
427     std::size_t size = faceIndices.Size();
428     vertices.reserve( size );
429
430     for( std::size_t i=0; i<size; i=i+3 )
431     {
432       Vector3 edge1 = vertexPositions[ faceIndices[i+2] ] - vertexPositions[ faceIndices[i] ];
433       Vector3 edge2 = vertexPositions[ faceIndices[i+1] ] - vertexPositions[ faceIndices[i] ];
434       Vector3 normal = edge1.Cross(edge2);
435       normal.Normalize();
436
437       // make sure all the faces are front-facing
438       if( normal.z > 0 )
439       {
440         vertices.push_back( Vertex( vertexPositions[ faceIndices[i] ], normal, textureCoordinates[ faceIndices[i] ] ) );
441         vertices.push_back( Vertex( vertexPositions[ faceIndices[i+1] ], normal, textureCoordinates[ faceIndices[i+1] ] ) );
442         vertices.push_back( Vertex( vertexPositions[ faceIndices[i+2] ], normal, textureCoordinates[ faceIndices[i+2] ] ) );
443       }
444       else
445       {
446         normal *= -1.f;
447         vertices.push_back( Vertex( vertexPositions[ faceIndices[i] ], normal, textureCoordinates[ faceIndices[i] ] ) );
448         vertices.push_back( Vertex( vertexPositions[ faceIndices[i+2] ], normal, textureCoordinates[ faceIndices[i+2] ] ) );
449         vertices.push_back( Vertex( vertexPositions[ faceIndices[i+1] ], normal, textureCoordinates[ faceIndices[i+1] ] ) );
450       }
451     }
452
453     Property::Map vertexFormat;
454     vertexFormat["aPosition"] = Property::VECTOR3;
455     vertexFormat["aNormal"] = Property::VECTOR3;
456     vertexFormat["aTexCoord"] = Property::VECTOR2;
457     PropertyBuffer surfaceVertices = PropertyBuffer::New( vertexFormat );
458     surfaceVertices.SetData( &vertices[0], vertices.size() );
459
460     Geometry surface = Geometry::New();
461     surface.AddVertexBuffer( surfaceVertices );
462
463     return surface;
464   }
465
466   void ReadObjFile( const std::string& objFileName,
467       Vector<float>& boundingBox,
468       std::vector<Vector3>& vertexPositions,
469       Vector<unsigned int>& faceIndices)
470   {
471     std::ifstream ifs( objFileName.c_str(), std::ios::in );
472
473     boundingBox.Resize( 6 );
474     boundingBox[0]=boundingBox[2]=boundingBox[4] = std::numeric_limits<float>::max();
475     boundingBox[1]=boundingBox[3]=boundingBox[5] = -std::numeric_limits<float>::max();
476
477     std::string line;
478     while( std::getline( ifs, line ) )
479     {
480       if( line[0] == 'v' && std::isspace(line[1]))  // vertex
481       {
482         std::istringstream iss(line.substr(2), std::istringstream::in);
483         unsigned int i = 0;
484         Vector3 vertex;
485         while( iss >> vertex[i++] && i < 3);
486         if( vertex.x < boundingBox[0] )  boundingBox[0] = vertex.x;
487         if( vertex.x > boundingBox[1] )  boundingBox[1] = vertex.x;
488         if( vertex.y < boundingBox[2] )  boundingBox[2] = vertex.y;
489         if( vertex.y > boundingBox[3] )  boundingBox[3] = vertex.y;
490         if( vertex.z < boundingBox[4] )  boundingBox[4] = vertex.z;
491         if( vertex.z > boundingBox[5] )  boundingBox[5] = vertex.z;
492         vertexPositions.push_back( vertex );
493       }
494       else if( line[0] == 'f' ) //face
495       {
496         unsigned int numOfInt = 3;
497         while( true )
498         {
499           std::size_t found  = line.find('/');
500           if( found == std::string::npos )
501           {
502             break;
503           }
504           line[found] = ' ';
505           numOfInt++;
506         }
507
508         std::istringstream iss(line.substr(2), std::istringstream::in);
509         unsigned int indices[ numOfInt ];
510         unsigned int i=0;
511         while( iss >> indices[i++] && i < numOfInt);
512         unsigned int step = (i+1) / 3;
513         faceIndices.PushBack( indices[0]-1 );
514         faceIndices.PushBack( indices[step]-1 );
515         faceIndices.PushBack( indices[2*step]-1 );
516       }
517     }
518
519     ifs.close();
520   }
521
522   void ShapeResizeAndTexureCoordinateCalculation( const Vector<float>& boundingBox,
523       std::vector<Vector3>& vertexPositions,
524       std::vector<Vector2>& textureCoordinates)
525   {
526     Vector3 bBoxSize( boundingBox[1] - boundingBox[0], boundingBox[3] - boundingBox[2], boundingBox[5] - boundingBox[4]);
527     Vector3 bBoxMinCorner( boundingBox[0], boundingBox[2], boundingBox[4] );
528
529     Vector2 stageSize = Stage::GetCurrent().GetSize();
530     Vector3 scale( stageSize.x / bBoxSize.x, stageSize.y / bBoxSize.y, 1.f );
531     scale.z = (scale.x + scale.y)/2.f;
532
533     textureCoordinates.reserve(vertexPositions.size());
534
535     for( std::vector<Vector3>::iterator iter = vertexPositions.begin(); iter != vertexPositions.end(); iter++ )
536     {
537       Vector3 newPosition(  (*iter) - bBoxMinCorner ) ;
538
539      textureCoordinates.push_back( Vector2( newPosition.x / bBoxSize.x, newPosition.y / bBoxSize.y ) );
540
541       newPosition -= bBoxSize * 0.5f;
542       (*iter) = newPosition * scale;
543     }
544   }
545
546   /**
547    * Main key event handler
548    */
549   void OnKeyEvent(const KeyEvent& event)
550   {
551     if(event.state == KeyEvent::Down)
552     {
553       if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
554       {
555         mApplication.Quit();
556       }
557     }
558   }
559
560 private:
561
562   Application&   mApplication;
563   Layer          mContent;
564   TextureSet     mTextureSet;
565   Geometry       mGeometry;
566   Renderer       mRenderer;
567   Actor          mMeshActor;
568
569   Shader         mShaderFlat;
570   Shader         mShaderRefraction;
571
572   Animation      mLightAnimation;
573   Animation      mStrenghAnimation;
574
575   Property::Index mLightXYOffsetIndex;
576   Property::Index mSpinAngleIndex;
577   Property::Index mLightIntensityIndex;
578   Property::Index mEffectStrengthIndex;
579
580   Toolkit::PushButton        mChangeTextureButton;
581   Toolkit::PushButton        mChangeMeshButton;
582   unsigned int               mCurrentTextureId;
583   unsigned int               mCurrentMeshId;
584 };
585
586 /*****************************************************************************/
587
588 static void
589 RunTest(Application& app)
590 {
591   RefractionEffectExample theApp(app);
592   app.MainLoop();
593 }
594
595 /*****************************************************************************/
596
597 int DALI_EXPORT_API main(int argc, char **argv)
598 {
599   Application app = Application::New(&argc, &argv, DEMO_THEME_PATH);
600
601   RunTest(app);
602
603   return 0;
604 }