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