Commit 7a0e60c023ed452ad4fe58d9d452e3ffec47ca85

Authored by Gonzalo Reynaga
Committed by Paul Wisbey
1 parent c0e4586a

Rendering API example: basic light

Change-Id: Ice5ef50aa0bde7ddac16414dfac8615d76d9ec18
build/tizen/CMakeLists.txt
... ... @@ -108,6 +108,7 @@ CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/style-example-theme-one.json.in ${LOCAL_STYLE
108 108 CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/style-example-theme-two.json.in ${LOCAL_STYLE_DIR}/style-example-theme-two.json )
109 109 CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/style-example-theme-three.json.in ${LOCAL_STYLE_DIR}/style-example-theme-three.json )
110 110 CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/tooltip-example-theme.json.in ${LOCAL_STYLE_DIR}/tooltip-example-theme.json )
  111 +CONFIGURE_FILE( ${LOCAL_STYLE_DIR}/basic-light-theme.json.in ${LOCAL_STYLE_DIR}/basic-light-theme.json )
111 112 MESSAGE("Configured ${LOCAL_STYLE_DIR}/style-example-theme<>.json files")
112 113  
113 114 FILE(GLOB LOCAL_STYLES_LIST "${LOCAL_STYLE_DIR}/*.json")
... ...
com.samsung.dali-demo.xml
... ... @@ -215,4 +215,7 @@
215 215 <ui-application appid="rendering-radial-progress.example" exec="/usr/apps/com.samsung.dali-demo/bin/rendering-radial-progress.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
216 216 <label>Rendering Radial Progress</label>
217 217 </ui-application>
  218 + <ui-application appid="rendering-basic-light.example" exec="/usr/apps/com.samsung.dali-demo/bin/rendering-basic-light.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true">
  219 + <label>Basic Light</label>
  220 + </ui-application>
218 221 </manifest>
... ...
examples-reel/dali-examples-reel.cpp
... ... @@ -63,6 +63,7 @@ int DALI_EXPORT_API main(int argc, char **argv)
63 63 demo.AddExample(Example("pivot.example", DALI_DEMO_STR_TITLE_PIVOT));
64 64 demo.AddExample(Example("primitive-shapes.example", DALI_DEMO_STR_TITLE_PRIMITIVE_SHAPES));
65 65 demo.AddExample(Example("progress-bar.example", DALI_DEMO_STR_TITLE_PROGRESS_BAR));
  66 + demo.AddExample(Example("rendering-basic-light.example", DALI_DEMO_STR_TITLE_BASIC_LIGHT));
66 67 demo.AddExample(Example("rendering-line.example", DALI_DEMO_STR_TITLE_RENDERING_DRAW_LINE));
67 68 demo.AddExample(Example("rendering-triangle.example", DALI_DEMO_STR_TITLE_RENDERING_DRAW_TRIANGLE));
68 69 demo.AddExample(Example("rendering-cube.example", DALI_DEMO_STR_TITLE_RENDERING_DRAW_CUBE));
... ...
examples/rendering-basic-light/rendering-basic-light-example.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2017 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 +
  21 +using namespace Dali;
  22 +using namespace Toolkit;
  23 +
  24 +#define MATERIALS_MAX 24
  25 +
  26 +namespace
  27 +{
  28 +
  29 +const char* BASIC_LIGHT_THEME( DEMO_STYLE_DIR "basic-light-theme.json" );
  30 +const char* const CUSTOM_BASIC_LIGHT_THEME = "BasicLightButton";
  31 +
  32 +struct Material
  33 +{
  34 + const char *name;
  35 + Vector3 ambient;
  36 + Vector3 diffuse;
  37 + Vector3 specular;
  38 + float shininess;
  39 +};
  40 +
  41 +Material material[] =
  42 +{
  43 + {"Emerald", Vector3( 0.0215f, 0.1745f, 0.0215f ), Vector3( 0.07568f, 0.61424f, 0.07568f ), Vector3( 0.633, 0.727811f, 0.633f ), 0.6f },
  44 + {"Jade", Vector3( 0.135f, 0.2225f, 0.1575f ), Vector3( 0.54f, 0.89f, 0.63f ), Vector3( 0.316228f, 0.316228f, 0.316228f ), 0.1f },
  45 + {"Obsidian", Vector3( 0.05375f, 0.05f, 0.06625f ), Vector3( 0.18275f, 0.17f, 0.22525f ), Vector3( 0.332741f, 0.328634f, 0.346435f ), 0.3f },
  46 + {"Perl", Vector3( 0.25f, 0.20725f, 0.20725f ), Vector3( 1.0f, 0.829f, 0.829f ), Vector3( 0.296648f, 0.296648f, 0.296648f ), 0.088f },
  47 + {"Ruby", Vector3( 0.1745f, 0.01175f, 0.01175f ), Vector3( 0.61424f, 0.04136f, 0.04136f ), Vector3( 0.727811f, 0.626959f, 0.626959f ), 0.6f },
  48 + {"Turquoise", Vector3( 0.1f, 0.18725f, 0.1745f ), Vector3( 0.396f, 0.74151f, 0.69102f ), Vector3( 0.297254, 0.30829f, 0.306678f ), 0.1f },
  49 + {"Brass", Vector3( 0.329412f, 0.223529f, 0.027451f ), Vector3( 0.780392f, 0.568627f, 0.113725f ), Vector3( 0.992157f, 0.941176f, 0.807843f ), 0.21794872f },
  50 + {"Bronze", Vector3( 0.2125f, 0.1275f, 0.054f ), Vector3( 0.714f, 0.4284f, 0.18144f ), Vector3( 0.393548f, 0.271906f, 0.166721f ), 0.2f },
  51 + {"Chrome", Vector3( 0.25f, 0.25f, 0.25f ), Vector3( 0.4f, 0.4f, 0.4f), Vector3( 0.774597f, 0.774597f, 0.774597f ), 0.6f },
  52 + {"Copper", Vector3( 0.19125f, 0.0735f, 0.0225f ), Vector3( 0.7038f, 0.27048f, 0.0828f ), Vector3( 0.256777f, 0.137622f, 0.086014f ), 0.1f },
  53 + {"Gold", Vector3( 0.24725f, 0.1995f, 0.0745f ), Vector3( 0.75164f, 0.60648f, 0.22648f ), Vector3( 0.628281f, 0.555802f, 0.366065f ), 0.4f },
  54 + {"Silver", Vector3( 0.19225f, 0.19225f, 0.19225f ), Vector3( 0.50754f, 0.50754f, 0.50754f ), Vector3( 0.508273f, 0.508273f, 0.508273f ), 0.4f },
  55 + {"Black plastic", Vector3( 0.0f, 0.0f, 0.0f ), Vector3( 0.01f, 0.01f, 0.01f ), Vector3( 0.50f, 0.50f, 0.50f ), 0.25f },
  56 + {"Cyan plastic", Vector3( 0.0f, 0.1f, 0.06f ), Vector3( 0.0f, 0.50980392f, 0.50980392f ), Vector3( 0.50196078f, 0.50196078f, 0.50196078f ), 0.25f },
  57 + {"Green plastic", Vector3( 0.0f, 0.0f, 0.0f ), Vector3( 0.1f, 0.35f, 0.1f ), Vector3( 0.45, 0.55, 0.45 ), 0.25f },
  58 + {"Red plastic", Vector3( 0.0f, 0.0f, 0.0f ), Vector3( 0.5f, 0.0f, 0.0f ), Vector3( 0.7f, 0.6f, 0.6f ), 0.25f },
  59 + {"White plastic", Vector3( 0.0f, 0.0f, 0.0f ), Vector3( 0.55f, 0.55f, 0.55f ), Vector3( 0.7f, 0.7f, 0.7f ), 0.25f },
  60 + {"Yellow plastic", Vector3( 0.0f, 0.0f, 0.0f ), Vector3( 0.5f, 0.5f, 0.0f ), Vector3( 0.6f, 0.6f, 0.5f ), 0.25f },
  61 + {"Black rubber", Vector3( 0.02f, 0.02f, 0.02f ), Vector3( 0.01f, 0.01f, 0.01f ), Vector3( 0.4f, 0.4f, 0.4f ), 0.078125f },
  62 + {"Cyan rubber", Vector3( 0.0f, 0.05f, 0.05f ), Vector3( 0.4f, 0.5f, 0.5f ), Vector3( 0.04f, 0.7f, 0.7f ), 0.078125f },
  63 + {"Green rubber", Vector3( 0.0f, 0.05f, 0.0f ), Vector3( 0.4f, 0.5f, 0.4f ), Vector3( 0.04f, 0.7f, 0.04f ), 0.078125f },
  64 + {"Red rubber", Vector3( 0.05f, 0.0f, 0.0f ), Vector3( 0.5f, 0.4f, 0.4f ), Vector3( 0.7f, 0.04f, 0.04f ), 0.078125f },
  65 + {"White rubber", Vector3( 0.05f, 0.05f, 0.05f ), Vector3( 0.5f, 0.5f, 0.5f ), Vector3( 0.7f, 0.7f, 0.7f ), 0.078125f },
  66 + {"Yellow rubber", Vector3( 0.05f, 0.05f, 0.0f ), Vector3( 0.5f, 0.5f, 0.4f ), Vector3( 0.7f, 0.7f, 0.04f ), 0.078125f }
  67 +};
  68 +
  69 +int MaterialID = 0;
  70 +
  71 +/*
  72 + * Vertex shader
  73 + */
  74 +const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
  75 +attribute mediump vec3 aPosition;\n // DALi shader builtin
  76 +attribute mediump vec3 aNormal;\n // DALi shader builtin
  77 +uniform mediump mat4 uMvpMatrix;\n // DALi shader builtin
  78 +uniform mediump vec3 uSize;\n // DALi shader builtin
  79 +uniform mediump mat4 uModelView;\n // DALi shader builtin
  80 +uniform mediump mat3 uNormalMatrix;\n // DALi shader builtin
  81 +\n
  82 +varying mediump vec3 vNormal;\n
  83 +varying mediump vec3 vFragPos;\n
  84 +\n
  85 +void main()\n
  86 +{\n
  87 + mediump vec4 vertexPosition = vec4(aPosition, 1.0);\n
  88 + vertexPosition.xyz *= uSize;\n
  89 + vFragPos = vec3(uModelView * vertexPosition);\n
  90 + vNormal = uNormalMatrix * aNormal;\n
  91 + \n
  92 + gl_Position = uMvpMatrix * vertexPosition;\n
  93 +}\n
  94 +);
  95 +
  96 +/*
  97 + * Fragment shader
  98 + */
  99 +const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
  100 +varying mediump vec3 vNormal;\n
  101 +varying mediump vec3 vFragPos;\n
  102 +uniform mediump vec3 viewPos;\n // custom uniform
  103 +\n
  104 +struct Material {\n
  105 + mediump vec3 ambient;\n
  106 + mediump vec3 diffuse;\n
  107 + mediump vec3 specular;\n
  108 + mediump float shininess;\n
  109 +};\n
  110 +struct Light {\n
  111 + mediump vec3 position;\n
  112 + mediump vec3 color;\n
  113 +};\n
  114 +uniform Material material;\n // custom uniform
  115 +uniform Light light;\n // custom uniform
  116 +\n
  117 +void main()\n
  118 +{\n
  119 +\n // Ambient
  120 + mediump vec3 ambient = material.ambient * light.color;\n
  121 +\n // Diffuse
  122 + mediump vec3 norm = normalize(vNormal);\n
  123 + mediump vec3 lightDir = normalize(light.position - vFragPos);\n
  124 + mediump float diff = max(dot(norm, lightDir), 0.0);\n
  125 + mediump vec3 diffuse = material.diffuse * diff * light.color;\n
  126 + \n
  127 +\n // Specular
  128 + mediump vec3 viewDir = normalize(viewPos - vFragPos);\n
  129 + mediump vec3 reflectDir = reflect(-lightDir, norm); \n
  130 + mediump float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);\n
  131 + mediump vec3 specular = material.specular * spec * light.color; \n
  132 + mediump vec3 result = (ambient + diffuse + specular);\n
  133 + gl_FragColor = vec4(result, 1.0);\n
  134 +}\n
  135 +);
  136 +
  137 +}
  138 +
  139 +// This example shows per-pixel lighting of materials with different ambient, diffuse, specular and shininess parameters
  140 +//
  141 +class BasicLightController : public ConnectionTracker
  142 +{
  143 +public:
  144 +
  145 + BasicLightController( Application& application )
  146 + : mApplication( application )
  147 + {
  148 + // Connect to the Application's Init signal
  149 + mApplication.InitSignal().Connect( this, &BasicLightController::Create );
  150 + }
  151 +
  152 + ~BasicLightController()
  153 + {
  154 + // Nothing to do here;
  155 + }
  156 +
  157 + // The Init signal is received once (only) during the Application lifetime
  158 + void Create( Application& application )
  159 + {
  160 + // Get a handle to the stage
  161 + Stage stage = Stage::GetCurrent();
  162 + stage.SetBackgroundColor( Color::BLACK );
  163 + mLabel = TextLabel::New( material[MaterialID].name );
  164 + mLabel.SetAnchorPoint( AnchorPoint::TOP_CENTER );
  165 + mLabel.SetParentOrigin( Vector3( 0.5f, 0.0f, 0.5f ) );
  166 + mLabel.SetSize( stage.GetSize().x * 0.5f, stage.GetSize().y * 0.083f );
  167 + mLabel.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
  168 + mLabel.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
  169 + mLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ));
  170 + stage.Add( mLabel );
  171 + mButton = PushButton::New();
  172 + mButton.SetProperty( Button::Property::LABEL, "Exit" );
  173 + mButton.SetParentOrigin( ParentOrigin::CENTER );
  174 + mButton.SetAnchorPoint( AnchorPoint::CENTER );
  175 + mButton.ClickedSignal().Connect( this, &BasicLightController::OnExit );
  176 + mButton.SetParentOrigin( Vector3( 0.5f, 0.1f, 0.5f ) );
  177 + mButton.SetStyleName(CUSTOM_BASIC_LIGHT_THEME);
  178 + mButton.SetColor( Vector4( material[MaterialID].diffuse) + Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) );
  179 + stage.Add(mButton);
  180 +
  181 + // Step 1. Create shader
  182 + CreateCubeShader();
  183 +
  184 + // Step 2. Prepare geometry
  185 + CreateCubeGeometry();
  186 +
  187 + // Step 3. Create a renderer
  188 + CreateRenderer();
  189 +
  190 + // Step 4. Create an Actor
  191 + CreateActor();
  192 +
  193 + // Step 5. Play animation to rotate the cube
  194 + PlayAnimation();
  195 +
  196 + // Respond to a click anywhere on the stage
  197 + stage.GetRootLayer().TouchSignal().Connect( this, &BasicLightController::OnTouch );
  198 +
  199 + // Respond to key events
  200 + stage.KeyEventSignal().Connect( this, &BasicLightController::OnKeyEvent );
  201 + }
  202 +
  203 + /**
  204 + * This function will change the material of the cube when touched
  205 + */
  206 + bool OnTouch( Actor actor, const TouchData& touch )
  207 + {
  208 + if(touch.GetState(0) == PointState::UP)
  209 + {
  210 + MaterialID++;
  211 + MaterialID %= MATERIALS_MAX;
  212 +
  213 + mShader.SetProperty( mShader.GetPropertyIndex( "material.ambient" ), material[MaterialID].ambient );
  214 + mShader.SetProperty( mShader.GetPropertyIndex( "material.diffuse" ), material[MaterialID].diffuse );
  215 + mShader.SetProperty( mShader.GetPropertyIndex( "material.specular" ), material[MaterialID].specular );
  216 + mShader.SetProperty( mShader.GetPropertyIndex( "material.shininess" ), material[MaterialID].shininess * 128.0f );
  217 + mLabel.SetProperty( TextLabel::Property::TEXT, material[MaterialID].name );
  218 + mButton.SetColor( Vector4(material[MaterialID].diffuse) + Vector4(0.0f, 0.0f, 0.0f, 1.0f) );
  219 + }
  220 + return true;
  221 + }
  222 +
  223 + /**
  224 + * This function will the terminate the application when the exit button is pressed
  225 + */
  226 + bool OnExit( Button button )
  227 + {
  228 + mApplication.Quit();
  229 + return true;
  230 + }
  231 +
  232 + /**
  233 + * @brief Called when any key event is received
  234 + *
  235 + * Will use this to quit the application if Back or the Escape key is received
  236 + * @param[in] event The key event information
  237 + */
  238 + void OnKeyEvent( const KeyEvent& event )
  239 + {
  240 + if( event.state == KeyEvent::Down )
  241 + {
  242 + if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
  243 + {
  244 + mApplication.Quit();
  245 + }
  246 + }
  247 + }
  248 +
  249 + /**
  250 + * This function creates a cube geometry including texture coordinates.
  251 + * Also it demonstrates using the indexed draw feature by setting an index array.
  252 + */
  253 + void CreateCubeGeometry()
  254 + {
  255 + struct Vertex
  256 + {
  257 + Vector3 aPosition;
  258 + Vector3 aNormal;
  259 + };
  260 +
  261 + const Vector3 NORMAL0(-1.0f, 0.0f, 0.0f );
  262 + const Vector3 NORMAL1( 0.0f, 1.0f, 0.0f );
  263 + const Vector3 NORMAL2( 0.0f,-1.0f, 0.0f );
  264 + const Vector3 NORMAL3( 0.0f, 0.0f, 1.0f );
  265 + const Vector3 NORMAL4( 1.0f, 0.0f, 0.0f );
  266 + const Vector3 NORMAL5( 0.0f, 0.0f,-1.0f );
  267 +
  268 + Vertex vertices[] = {
  269 + { Vector3( 1.0f,-1.0f,-1.0f ), NORMAL5 },
  270 + { Vector3( -1.0f, 1.0f,-1.0f ), NORMAL5 },
  271 + { Vector3( 1.0f, 1.0f,-1.0f ), NORMAL5 },
  272 + { Vector3( -1.0f, 1.0f, 1.0f ), NORMAL3 },
  273 + { Vector3( 1.0f,-1.0f, 1.0f ), NORMAL3 },
  274 + { Vector3( 1.0f, 1.0f, 1.0f ), NORMAL3 },
  275 + { Vector3( 1.0f, 1.0f, 1.0f ), NORMAL4 },
  276 + { Vector3( 1.0f,-1.0f,-1.0f ), NORMAL4 },
  277 + { Vector3( 1.0f, 1.0f,-1.0f ), NORMAL4 },
  278 + { Vector3( 1.0f,-1.0f, 1.0f ), NORMAL1 },
  279 + { Vector3( -1.0f,-1.0f,-1.0f ), NORMAL1 },
  280 + { Vector3( 1.0f,-1.0f,-1.0f ), NORMAL1 },
  281 + { Vector3( -1.0f,-1.0f,-1.0f ), NORMAL0 },
  282 + { Vector3( -1.0f, 1.0f, 1.0f ), NORMAL0 },
  283 + { Vector3( -1.0f, 1.0f,-1.0f ), NORMAL0 },
  284 + { Vector3( 1.0f, 1.0f,-1.0f ), NORMAL2 },
  285 + { Vector3( -1.0f, 1.0f, 1.0f ), NORMAL2 },
  286 + { Vector3( 1.0f, 1.0f, 1.0f ), NORMAL2 },
  287 + { Vector3( 1.0f,-1.0f,-1.0f ), NORMAL5 },
  288 + { Vector3( -1.0f,-1.0f,-1.0f ), NORMAL5 },
  289 + { Vector3( -1.0f, 1.0f,-1.0f ), NORMAL5 },
  290 + { Vector3( -1.0f, 1.0f, 1.0f ), NORMAL3 },
  291 + { Vector3( -1.0f,-1.0f, 1.0f ), NORMAL3 },
  292 + { Vector3( 1.0f,-1.0f, 1.0f ), NORMAL3 },
  293 + { Vector3( 1.0f, 1.0f, 1.0f ), NORMAL4 },
  294 + { Vector3( 1.0f,-1.0f, 1.0f ), NORMAL4 },
  295 + { Vector3( 1.0f,-1.0f,-1.0f ), NORMAL4 },
  296 + { Vector3( 1.0f,-1.0f, 1.0f ), NORMAL1 },
  297 + { Vector3( -1.0f,-1.0f, 1.0f ), NORMAL1 },
  298 + { Vector3( -1.0f,-1.0f,-1.0f ), NORMAL1 },
  299 + { Vector3( -1.0f,-1.0f,-1.0f ), NORMAL0 },
  300 + { Vector3( -1.0f,-1.0f, 1.0f ), NORMAL0 },
  301 + { Vector3( -1.0f, 1.0f, 1.0f ), NORMAL0 },
  302 + { Vector3( 1.0f, 1.0f,-1.0f ), NORMAL2 },
  303 + { Vector3( -1.0f, 1.0f,-1.0f ), NORMAL2 },
  304 + { Vector3( -1.0f, 1.0f, 1.0f ), NORMAL2 },
  305 + };
  306 +
  307 + Property::Map property;
  308 + property.Insert( "aPosition", Property::VECTOR3 );
  309 + property.Insert( "aNormal", Property::VECTOR3 );
  310 +
  311 + PropertyBuffer vertexBuffer = PropertyBuffer::New( property );
  312 +
  313 + vertexBuffer.SetData( vertices, sizeof(vertices) / sizeof(Vertex) );
  314 +
  315 + // create indices
  316 + const unsigned short INDEX_CUBE[] = {
  317 + 2, 1, 0,
  318 + 5, 4, 3,
  319 + 8, 7, 6,
  320 + 11, 10, 9,
  321 + 14, 13, 12,
  322 + 17, 16, 15,
  323 + 20, 19, 18,
  324 + 23, 22, 21,
  325 + 26, 25, 24,
  326 + 29, 28, 27,
  327 + 32, 31, 30,
  328 + 35, 34, 33
  329 + };
  330 + mGeometry = Geometry::New();
  331 + mGeometry.AddVertexBuffer( vertexBuffer );
  332 + mGeometry.SetIndexBuffer( INDEX_CUBE,
  333 + sizeof(INDEX_CUBE)/sizeof(INDEX_CUBE[0])
  334 + );
  335 + mGeometry.SetType( Geometry::TRIANGLES );
  336 + }
  337 +
  338 + /**
  339 + * Creates a shader using inlined variable VERTEX_SHADER and FRAGMENT_SHADER
  340 + *
  341 + * Shaders are very basic and all they do is transforming vertices and interpolating
  342 + * input per-vertex color.
  343 + */
  344 + void CreateCubeShader()
  345 + {
  346 + mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
  347 +
  348 + float scale = 120.0f;
  349 + mShader.RegisterProperty( "light.position",Vector3( 1.2 * scale, scale, 2.0 * scale ) );
  350 + mShader.RegisterProperty( "light.color", Vector3( 1.0f, 1.0f, 1.0f ) );
  351 + mShader.RegisterProperty( "viewPos", Vector3( 0, 0, 3.0 * scale ) );
  352 +
  353 + mShader.RegisterProperty( "material.ambient", material[MaterialID].ambient );
  354 + mShader.RegisterProperty( "material.diffuse", material[MaterialID].diffuse );
  355 + mShader.RegisterProperty( "material.specular", material[MaterialID].specular );
  356 + mShader.RegisterProperty( "material.shininess", material[MaterialID].shininess * 128.0f );
  357 + }
  358 +
  359 + /**
  360 + * Function creates renderer. It turns on depth test and depth write.
  361 + */
  362 + void CreateRenderer()
  363 + {
  364 + mRenderer = Renderer::New( mGeometry, mShader );
  365 +
  366 + // Face culling is enabled to hide the backwards facing sides of the cube
  367 + // This is sufficient to render a single object; for more complex scenes depth-testing might be required
  368 + mRenderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, FaceCullingMode::BACK );
  369 + }
  370 +
  371 + /**
  372 + * Creates new actor and attaches renderer.
  373 + */
  374 + void CreateActor()
  375 + {
  376 + Stage stage = Stage::GetCurrent();
  377 +
  378 + float quarterStageWidth = stage.GetSize().x * 0.25f;
  379 + mActor = Actor::New();
  380 + mActor.SetColor( Vector4( 1.0f, 1.0f, 0.6f, 1.0f ) );
  381 + mActor.SetAnchorPoint( AnchorPoint::CENTER );
  382 + mActor.SetParentOrigin( ParentOrigin::CENTER );
  383 + mActor.SetSize( Vector3( quarterStageWidth, quarterStageWidth, quarterStageWidth ) );
  384 + mActor.AddRenderer( mRenderer );
  385 + stage.Add( mActor );
  386 + }
  387 +
  388 + /**
  389 + * Plays animation
  390 + */
  391 + void PlayAnimation()
  392 + {
  393 + mAnimation = Animation::New( 15.0f );
  394 + mAnimation.SetLooping( true );
  395 + mAnimation.AnimateBy( Property( mActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( 360 )), Vector3::ZAXIS ) );
  396 + mAnimation.AnimateBy( Property( mActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( 360 )), Vector3::YAXIS ) );
  397 + mAnimation.AnimateBy( Property( mActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( 360 )), Vector3::XAXIS ) );
  398 + mAnimation.Play();
  399 + }
  400 +
  401 +private:
  402 + Application& mApplication;
  403 + TextLabel mLabel;
  404 + PushButton mButton;
  405 + Renderer mRenderer;
  406 + Shader mShader;
  407 + Geometry mGeometry;
  408 + Actor mActor;
  409 + Animation mAnimation;
  410 +};
  411 +
  412 +void RunTest( Application& application )
  413 +{
  414 + BasicLightController test( application );
  415 +
  416 + application.MainLoop();
  417 +}
  418 +
  419 +// Entry point for Linux & Tizen applications
  420 +//
  421 +int DALI_EXPORT_API main( int argc, char **argv )
  422 +{
  423 + Application application = Application::New( &argc, &argv, BASIC_LIGHT_THEME);
  424 +
  425 + RunTest( application );
  426 +
  427 + return 0;
  428 +}
... ...
resources/images/button-white-up.9.png 0 → 100644

924 Bytes

resources/po/as.po
... ... @@ -4,6 +4,9 @@ msgstr &quot;অ্যানিমেটেড ইমেজ&quot;
4 4 msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES"
5 5 msgstr "অ্যানিমেটেড আকার"
6 6  
  7 +msgid "DALI_DEMO_STR_TITLE_BASIC_LIGHT"
  8 +msgstr "বেসিক আলো"
  9 +
7 10 msgid "DALI_DEMO_STR_TITLE_BLOCKS"
8 11 msgstr "অৱৰুদ্ধ কৰক"
9 12  
... ...
resources/po/de.po
... ... @@ -4,6 +4,9 @@ msgstr &quot;Animierte Bilder&quot;
4 4 msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES"
5 5 msgstr "Animierte Formen"
6 6  
  7 +msgid "DALI_DEMO_STR_TITLE_BASIC_LIGHT"
  8 +msgstr "Grundleuchte"
  9 +
7 10 msgid "DALI_DEMO_STR_TITLE_BLOCKS"
8 11 msgstr "Blöcke"
9 12  
... ...
resources/po/en_GB.po
... ... @@ -4,6 +4,9 @@ msgstr &quot;Animated Images&quot;
4 4 msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES"
5 5 msgstr "Animated Shapes"
6 6  
  7 +msgid "DALI_DEMO_STR_TITLE_BASIC_LIGHT"
  8 +msgstr "Basic Light"
  9 +
7 10 msgid "DALI_DEMO_STR_TITLE_BLOCKS"
8 11 msgstr "Blocks"
9 12  
... ...
resources/po/en_US.po
... ... @@ -4,6 +4,9 @@ msgstr &quot;Animated Images&quot;
4 4 msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES"
5 5 msgstr "Animated Shapes"
6 6  
  7 +msgid "DALI_DEMO_STR_TITLE_BASIC_LIGHT"
  8 +msgstr "Basic Light"
  9 +
7 10 msgid "DALI_DEMO_STR_TITLE_BLOCKS"
8 11 msgstr "Blocks"
9 12  
... ...
resources/po/es.po
... ... @@ -4,6 +4,9 @@ msgstr &quot;Imágenes animadas&quot;
4 4 msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES"
5 5 msgstr "Formas Animadas"
6 6  
  7 +msgid "DALI_DEMO_STR_TITLE_BASIC_LIGHT"
  8 +msgstr "Iluminación Básica"
  9 +
7 10 msgid "DALI_DEMO_STR_TITLE_BLOCKS"
8 11 msgstr "Bloques"
9 12  
... ...
resources/po/fi.po
... ... @@ -4,6 +4,9 @@ msgstr &quot;animoituja kuvia&quot;
4 4 msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES"
5 5 msgstr "Animoidut Muodot"
6 6  
  7 +msgid "DALI_DEMO_STR_TITLE_BASIC_LIGHT"
  8 +msgstr "Perusvalo"
  9 +
7 10 msgid "DALI_DEMO_STR_TITLE_BLOCKS"
8 11 msgstr "Lohko Peli"
9 12  
... ...
resources/po/ko.po
... ... @@ -4,6 +4,9 @@ msgstr &quot;애니메이션 이미지&quot;
4 4 msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES"
5 5 msgstr "애니메이션 모양"
6 6  
  7 +msgid "DALI_DEMO_STR_TITLE_BASIC_LIGHT"
  8 +msgstr "기본 표시 등"
  9 +
7 10 msgid "DALI_DEMO_STR_TITLE_BLOCKS"
8 11 msgstr "블록"
9 12  
... ...
resources/po/ml.po
... ... @@ -4,6 +4,9 @@ msgstr &quot;അനിമേറ്റഡ് ചിത്രങ്ങൾ&quot;
4 4 msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES"
5 5 msgstr "ആനിമേഷൻ രൂപങ്ങൾ"
6 6  
  7 +msgid "DALI_DEMO_STR_TITLE_BASIC_LIGHT"
  8 +msgstr "അടിസ്ഥാന വെളിച്ചം"
  9 +
7 10 msgid "DALI_DEMO_STR_TITLE_BLOCKS"
8 11 msgstr "തടയപ്പെട്ട"
9 12  
... ...
resources/po/ur.po
... ... @@ -4,6 +4,9 @@ msgstr &quot;متحرک تصاویر&quot;
4 4 msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES"
5 5 msgstr "متحرک شکلیں"
6 6  
  7 +msgid "DALI_DEMO_STR_TITLE_BASIC_LIGHT"
  8 +msgstr "بیسک روشنی"
  9 +
7 10 msgid "DALI_DEMO_STR_TITLE_BLOCKS"
8 11 msgstr "اینٹیں"
9 12  
... ...
resources/po/zn_CH.po
... ... @@ -4,6 +4,9 @@ msgstr &quot;动态图&quot;
4 4 msgid "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES"
5 5 msgstr "动画造型"
6 6  
  7 +msgid "DALI_DEMO_STR_TITLE_BASIC_LIGHT"
  8 +msgstr "基本光"
  9 +
7 10 msgid "DALI_DEMO_STR_TITLE_BLOCKS"
8 11 msgstr "块体"
9 12  
... ...
resources/style/.gitignore
... ... @@ -6,3 +6,4 @@ style-example-theme-three.json
6 6 style-example-theme-two.json
7 7 style-example-theme-one.json
8 8 tooltip-example-theme.json
  9 +basic-light-theme.json
... ...
resources/style/basic-light-theme.json.in 0 → 100644
  1 +/*
  2 + * Copyright (c) 2000-2017 Samsung Electronics Co., Ltd
  3 + * Licensed under the Apache License, Version 2.0 (the "License");
  4 + * you may not use this file except in compliance with the License.
  5 + * You may obtain a copy of the License at
  6 + *
  7 + * http://www.apache.org/licenses/LICENSE-2.0
  8 + *
  9 + * Unless required by applicable law or agreed to in writing, software
  10 + * distributed under the License is distributed on an "AS IS" BASIS,
  11 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 + * See the License for the specific language governing permissions and
  13 + * limitations under the License.
  14 + *
  15 + */
  16 +
  17 +{
  18 + "styles":
  19 + {
  20 + //
  21 + // Simple Visuals Application styling
  22 + //
  23 + "BasicLightButton":
  24 + {
  25 + "states":
  26 + {
  27 + "NORMAL":
  28 + {
  29 + "unselectedBackgroundVisual":
  30 + {
  31 + "url":"{APPLICATION_RESOURCE_PATH}/images/button-white-up.9.png"
  32 + }
  33 + },
  34 + "FOCUSED":
  35 + {
  36 + "unselectedBackgroundVisual":
  37 + {
  38 + "url":"{APPLICATION_RESOURCE_PATH}/images/button-white-up.9.png"
  39 + }
  40 + }
  41 + }
  42 + }
  43 + }
  44 +}
... ...
resources/style/mobile/basic-light-theme.json.in 0 → 100644
  1 +/*
  2 + * Copyright (c) 2000-2017 Samsung Electronics Co., Ltd
  3 + * Licensed under the Apache License, Version 2.0 (the "License");
  4 + * you may not use this file except in compliance with the License.
  5 + * You may obtain a copy of the License at
  6 + *
  7 + * http://www.apache.org/licenses/LICENSE-2.0
  8 + *
  9 + * Unless required by applicable law or agreed to in writing, software
  10 + * distributed under the License is distributed on an "AS IS" BASIS,
  11 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 + * See the License for the specific language governing permissions and
  13 + * limitations under the License.
  14 + *
  15 + */
  16 +
  17 +{
  18 + "styles":
  19 + {
  20 + //
  21 + // Simple Visuals Application styling
  22 + //
  23 + "BasicLightButton":
  24 + {
  25 + "states":
  26 + {
  27 + "NORMAL":
  28 + {
  29 + "unselectedBackgroundVisual":
  30 + {
  31 + "url":"{APPLICATION_RESOURCE_PATH}/images/button-white-up.9.png"
  32 + }
  33 + },
  34 + "FOCUSED":
  35 + {
  36 + "unselectedBackgroundVisual":
  37 + {
  38 + "url":"{APPLICATION_RESOURCE_PATH}/images/button-white-up.9.png"
  39 + }
  40 + }
  41 + }
  42 + }
  43 + }
  44 +}
... ...
shared/dali-demo-strings.h
... ... @@ -34,6 +34,7 @@ extern &quot;C&quot;
34 34  
35 35 #define DALI_DEMO_STR_TITLE_ANIMATED_IMAGES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_IMAGES")
36 36 #define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_ANIMATED_SHAPES")
  37 +#define DALI_DEMO_STR_TITLE_BASIC_LIGHT dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BASIC_LIGHT")
37 38 #define DALI_DEMO_STR_TITLE_BLOCKS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BLOCKS")
38 39 #define DALI_DEMO_STR_TITLE_BUBBLES dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BUBBLES")
39 40 #define DALI_DEMO_STR_TITLE_BUTTONS dgettext(DALI_DEMO_DOMAIN_LOCAL, "DALI_DEMO_STR_TITLE_BUTTONS")
... ... @@ -95,6 +96,7 @@ extern &quot;C&quot;
95 96  
96 97 #define DALI_DEMO_STR_TITLE_ANIMATED_IMAGES "Animated Images"
97 98 #define DALI_DEMO_STR_TITLE_ANIMATED_SHAPES "Animated Shapes"
  99 +#define DALI_DEMO_STR_TITLE_BASIC_LIGHT "Basic Light"
98 100 #define DALI_DEMO_STR_TITLE_BLOCKS "Blocks"
99 101 #define DALI_DEMO_STR_TITLE_BUBBLES "Bubbles"
100 102 #define DALI_DEMO_STR_TITLE_BUTTONS "Buttons"
... ...