From affb5e80069ae87251da5bab06ee6799475183c4 Mon Sep 17 00:00:00 2001 From: Ferran Sole Date: Mon, 12 Sep 2016 10:44:02 +0100 Subject: [PATCH] Added animated shapes demo --- com.samsung.dali-demo.xml | 3 --- demo/dali-demo.cpp | 1 + examples/animated-shapes/animated-shapes-example.cpp | 475 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ resources/po/as.po | 3 +++ resources/po/de.po | 3 +++ resources/po/en_GB.po | 3 +++ resources/po/en_US.po | 3 +++ resources/po/es.po | 3 +++ resources/po/ko.po | 3 +++ resources/po/ml.po | 3 +++ resources/po/ur.po | 3 +++ resources/po/zn_CH.po | 3 +++ shared/dali-demo-strings.h | 2 ++ 13 files changed, 505 insertions(+), 3 deletions(-) create mode 100644 examples/animated-shapes/animated-shapes-example.cpp diff --git a/com.samsung.dali-demo.xml b/com.samsung.dali-demo.xml index 4a58819..4ef2af0 100644 --- a/com.samsung.dali-demo.xml +++ b/com.samsung.dali-demo.xml @@ -106,9 +106,6 @@ - - - diff --git a/demo/dali-demo.cpp b/demo/dali-demo.cpp index f413590..5a26efe 100644 --- a/demo/dali-demo.cpp +++ b/demo/dali-demo.cpp @@ -36,6 +36,7 @@ int DALI_EXPORT_API main(int argc, char **argv) // Create the demo launcher DaliTableView demo(app); + demo.AddExample(Example("animated-shapes.example", DALI_DEMO_STR_TITLE_ANIMATED_SHAPES)); demo.AddExample(Example("bubble-effect.example", DALI_DEMO_STR_TITLE_BUBBLES)); demo.AddExample(Example("blocks.example", DALI_DEMO_STR_TITLE_BLOCKS)); demo.AddExample(Example("cube-transition-effect.example", DALI_DEMO_STR_TITLE_CUBE_TRANSITION)); diff --git a/examples/animated-shapes/animated-shapes-example.cpp b/examples/animated-shapes/animated-shapes-example.cpp new file mode 100644 index 0000000..dd79982 --- /dev/null +++ b/examples/animated-shapes/animated-shapes-example.cpp @@ -0,0 +1,475 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include "shared/view.h" + +#include + +using namespace Dali; +using namespace Dali::Toolkit; + +namespace +{ + +const char* APPLICATION_TITLE("Animated Shapes"); + +const char* VERTEX_SHADER = DALI_COMPOSE_SHADER +( + attribute mediump vec3 aCoefficient; + uniform mediump mat4 uMvpMatrix; + uniform mediump vec3 uPosition[MAX_POINT_COUNT]; + varying lowp vec2 vCoefficient; + void main() + { + int vertexId = int(aCoefficient.z); + gl_Position = uMvpMatrix * vec4(uPosition[vertexId], 1.0); + + vCoefficient = aCoefficient.xy; + } +); + +// Fragment shader. +const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER +( + uniform lowp vec4 uColor; + varying lowp vec2 vCoefficient; + void main() + { + lowp float C = (vCoefficient.x*vCoefficient.x-vCoefficient.y); + lowp float Cdx = dFdx(C); + lowp float Cdy = dFdy(C); + + lowp float distance = float(C / sqrt(Cdx*Cdx + Cdy*Cdy)); + lowp float alpha = 0.5 - distance; + gl_FragColor = vec4( uColor.rgb, uColor.a * alpha ); + } +); + +Shader CreateShader( unsigned int pointCount ) +{ + std::ostringstream vertexShader; + vertexShader << "#define MAX_POINT_COUNT "<< pointCount << "\n"<