All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
LoadingScreen.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "LoadingScreenConfig.h"
6 #include "GLHelpers.h"
7 #include "VectorMath.h"
8 #include "Rendering.h"
9 #include "Helpers.h"
10 #include "Lighting.h"
11 #include <string>
12 
13 namespace Eegeo
14 {
15  namespace Rendering
16  {
18  {
19  public:
20  ~LoadingScreen();
21 
22  static LoadingScreen* Create(std::string splashScreenImageFilename,
23  LoadingScreenConfig config,
26  Eegeo::Rendering::GlBufferPool& glBufferPool,
29  Eegeo::Helpers::ITextureFileLoader& textureLoader);
30 
31  void Dismiss();
32  void SetProgress(float progress) { m_progress = Math::Clamp01(progress); }
33  void Update(float dt);
34 
35  void NotifyScreenDimensionsChanged(float screenWidth, float screenHeight);
36 
37  bool IsVisible() const { return m_state != Hidden; }
38  bool IsDismissed() const { return m_state != Displayed; }
39 
40  void Draw();
41 
42  private:
44  LoadingScreenRenderablesFactory* pRenderablesFactory,
45  const Eegeo::Helpers::GLHelpers::TextureInfo& imageTextureInfo,
50  LoadingScreenRenderables* pLoadingScreenRenderables,
51  const v4& backgroundColor,
52  bool hasProgressBar,
53  const v4& loadingBarColor,
54  const v4& loadingBarBackgroundColor,
55  const v2& loadingBarOffset,
56  float fadeOutDurationSeconds,
57  bool dismissAfterTimeout,
58  float timeoutSeconds);
59 
60  void DestroyResources();
61 
62  void RecreateRenderables(float screenWidth, float screenHeight);
63 
64 
65  LoadingScreenRenderablesFactory* m_pRenderablesFactory;
66 
67  Eegeo::Helpers::GLHelpers::TextureInfo m_imageTextureInfo;
68 
73 
74  LoadingScreenRenderables* m_pRenderables;
75 
76  enum LoadingScreenState
77  {
78  Displayed,
79  FadeOut,
80  Hidden
81  };
82 
83  LoadingScreenState m_state;
84  const v4 m_backgroundColor;
85  const v4 m_loadingBarColor;
86  const v4 m_loadingBarBackgroundColor;
87  const v2 m_loadingBarOffset;
88 
89  float m_progress;
90  float m_loadingTime;
91  float m_fadeTime;
92 
93  const float m_fadeDuration;
94  const float m_timeoutSeconds;
95 
96  const bool m_hasProgressBar;
97  const bool m_dismissAfterTimeout;
98 
99  void DrawLoadingBar(Rendering::GLState& glState, const float t);
100  };
101  }
102 }