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