DirectRendering demo
[platform/core/uifw/dali-demo.git] / examples / rendering-basic-light / rendering-basic-light-example.cpp
index 85588c6..0be89a7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -18,8 +18,8 @@
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali/dali.h>
 
-#include "generated/rendering-basic-light-vert.h"
 #include "generated/rendering-basic-light-frag.h"
+#include "generated/rendering-basic-light-vert.h"
 
 using namespace Dali;
 using namespace Toolkit;
@@ -295,13 +295,14 @@ public:
   void CreateActor()
   {
     Window window = mApplication.GetWindow();
+    const auto windowSize = window.GetSize();
 
-    float quarterWindowWidth = window.GetSize().GetWidth() * 0.25f;
-    mActor                   = Actor::New();
+    const float quarterWindowSize = std::min(windowSize.GetWidth(), windowSize.GetHeight()) * 0.25f;
+    mActor                        = Actor::New();
     mActor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 1.0f, 0.6f, 1.0f));
     mActor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
     mActor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
-    mActor.SetProperty(Actor::Property::SIZE, Vector3(quarterWindowWidth, quarterWindowWidth, quarterWindowWidth));
+    mActor.SetProperty(Actor::Property::SIZE, Vector3(quarterWindowSize, quarterWindowSize, quarterWindowSize));
     mActor.AddRenderer(mRenderer);
     window.Add(mActor);
   }