+Geometry NewWindowController::CreateMeshGeometry()
+{
+ // Create vertices and specify their color
+ struct Vertex
+ {
+ Vector3 position;
+ Vector2 textureCoordinates;
+ Vector3 color;
+ };
+
+ Vertex vertexData[5] = {
+ { Vector3( 0.0f, 0.0f, 0.5f ), Vector2(0.5f, 0.5f), Vector3(1.0f, 1.0f, 1.0f) },
+ { Vector3( -0.5f, -0.5f, 0.0f ), Vector2(0.0f, 0.0f), Vector3(1.0f, 0.0f, 0.0f) },
+ { Vector3( 0.5f, -0.5f, 0.0f ), Vector2(1.0f, 0.0f), Vector3(1.0f, 1.0f, 0.0f) },
+ { Vector3( -0.5f, 0.5f, 0.0f ), Vector2(0.0f, 1.0f), Vector3(0.0f, 1.0f, 0.0f) },
+ { Vector3( 0.5f, 0.5f, 0.0f ), Vector2(1.0f, 1.0f), Vector3(0.0f, 0.0f, 1.0f) } };
+
+ Property::Map vertexFormat;
+ vertexFormat["aPosition"] = Property::VECTOR3;
+ vertexFormat["aTexCoord"] = Property::VECTOR2;
+ vertexFormat["aColor"] = Property::VECTOR3;
+ PropertyBuffer vertices = PropertyBuffer::New( vertexFormat, 5 );
+ vertices.SetData( vertexData );
+
+ // Specify all the faces
+ unsigned int indexData[12] = { 0,1,3,0,2,4,0,3,4,0,2,1 };
+ Property::Map indexFormat;
+ indexFormat["indices"] = Property::INTEGER;
+ PropertyBuffer indices = PropertyBuffer::New( indexFormat, 12 );
+ indices.SetData( indexData );
+
+ // Create the geometry object
+ Geometry geometry = Geometry::New();
+ geometry.AddVertexBuffer( vertices );
+ geometry.SetIndexBuffer( indices );
+
+ return geometry;
+}
+
+Dali::Property::Map NewWindowController::CreateColorModifierer()
+{
+ const char* fragmentShader ( DALI_COMPOSE_SHADER (
+ precision highp float;\n
+ uniform vec3 uRGBDelta;\n
+ uniform float uIgnoreAlpha;\n
+ \n
+ varying mediump vec2 vTexCoord;\n
+ uniform sampler2D sTexture;\n
+ \n
+ float rand(vec2 co) \n
+ {\n
+ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); \n}
+ \n
+ void main() {\n
+ vec4 color = texture2D(sTexture, vTexCoord); \n
+ // modify the hsv Value
+ color.rgb += uRGBDelta * rand(vTexCoord); \n
+ // if the new vale exceeds one, then decrease it
+ color.rgb -= max(color.rgb*2.0 - vec3(2.0), 0.0);\n
+ // if the new vale drops below zero, then increase it
+ color.rgb -= min(color.rgb*2.0, 0.0);\n
+ gl_FragColor = color; \n
+ }\n
+ ) );
+
+ Property::Map map;
+ Property::Map customShader;
+ customShader[ "fragmentShader" ] = fragmentShader;
+ map[ "shader" ] = customShader;
+
+ return map;
+}
+
+void NewWindowController::NewWindow(void)
+{
+ PositionSize posSize(0, 0, 720, 1280);
+ gApplication.ReplaceWindow(posSize, "NewWindow"); // Generates a new window
+}
+
+bool NewWindowController::OnLoseContextButtonClicked( Toolkit::Button button )
+{
+ // Add as an idle callback to avoid ProcessEvents being recursively called.
+ mApplication.AddIdle( MakeCallback( NewWindowController::NewWindow ) );
+ return true;
+}
+