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