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