/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// EXTERNAL INCLUDES
#include <dali/public-api/math/vector3.h>
#include <dali/public-api/object/property-map.h>
-#include <dali/devel-api/object/property-buffer.h>
-#include <dali/devel-api/rendering/geometry.h>
-#include <dali/devel-api/rendering/material.h>
-#include <dali/devel-api/rendering/renderer.h>
-#include <dali/devel-api/rendering/shader.h>
+#include <dali/public-api/rendering/geometry.h>
+#include <dali/public-api/rendering/renderer.h>
+#include <dali/public-api/rendering/shader.h>
+#include <dali/public-api/rendering/texture-set.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
namespace Dali
{
26.f / 130.f
};
-#define MAKE_SHADER(A)#A
-
-// Modify the vertex position according to the bounce coefficient;
-const char* MESH_VERTEX_SHADER = MAKE_SHADER(
-attribute mediump vec3 aPosition1;\n
-attribute mediump vec3 aPosition2;\n
-uniform mediump mat4 uMvpMatrix;\n
-uniform mediump vec3 uSize;
-uniform mediump float uBounceCoefficient;\n
-\n
-void main()\n
-{\n
- gl_Position = uMvpMatrix * vec4(mix( aPosition1, aPosition2, abs(uBounceCoefficient) )*uSize, 1.0);\n
-}
-);
-
-// use the actor color to paint every layer
-const char* MESH_FRAGMENT_SHADER = MAKE_SHADER(
-uniform lowp vec4 uColor;\n
-void main()\n
-{\n
- gl_FragColor = uColor;\n
-}\n
-);
-
} // namespace Anon
Actor CreateBouncingEffectActor( Property::Index& bouncePropertyIndex )
Property::Map vertexFormat;
vertexFormat["aPosition1"] = Property::VECTOR3;
vertexFormat["aPosition2"] = Property::VECTOR3;
- PropertyBuffer vertices = PropertyBuffer::New( vertexFormat );
+ VertexBuffer vertices = VertexBuffer::New( vertexFormat );
vertices.SetData( vertexData, 20u );
- unsigned int indexData[30] = { 0,3,1,0,2,3,4,7,5,4,6,7,8,11,9,8,10,11,12,15,13,12,14,15,16,19,17,16,18,19};
- Property::Map indexFormat;
- indexFormat["indices"] = Property::INTEGER;
- PropertyBuffer indices = PropertyBuffer::New( indexFormat );
- indices.SetData( indexData, 30u );
+ unsigned short indexData[30] = { 0,3,1,0,2,3,4,7,5,4,6,7,8,11,9,8,10,11,12,15,13,12,14,15,16,19,17,16,18,19};
Geometry meshGeometry = Geometry::New();
meshGeometry.AddVertexBuffer( vertices );
- meshGeometry.SetIndexBuffer( indices );
+ meshGeometry.SetIndexBuffer( indexData, sizeof(indexData)/sizeof(indexData[0]) );
- // Create material
- Shader shader = Shader::New( MESH_VERTEX_SHADER, MESH_FRAGMENT_SHADER );
- Material material = Material::New( shader );
+ // Create the shader
+ Shader shader = Shader::New( SHADER_BOUNCING_EFFECT_MESH_SHADER_VERT, SHADER_BOUNCING_EFFECT_MESH_SHADER_FRAG );
// Create renderer
- Renderer renderer = Renderer::New( meshGeometry, material );
+ Renderer renderer = Renderer::New( meshGeometry, shader );
// Create actor
Actor meshActor= Actor::New();