All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
HttpAsyncCubeTexture.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "IAsyncTexture.h"
7 #include "RefcountedAsyncTexture.h"
8 #include "GLHelpers.h"
9 #include "Web.h"
10 #include "AsyncTexturing.h"
11 #include "Rendering.h"
12 #include "Helpers.h"
13 #include "CubeFaceFileNames.h"
14 
15 #include <vector>
16 #include <string>
17 
18 namespace Eegeo
19 {
20  namespace Rendering
21  {
22  namespace AsyncTexturing
23  {
24  class HttpAsyncCubeTexture : protected Eegeo::NonCopyable, public RefcountedAsyncTexture<HttpAsyncCubeTexture>
25  {
26  public:
27  typedef std::vector<Eegeo::Web::IWebLoadRequest*> TFaceRequests;
28  typedef std::vector<const std::vector<Byte>*> TFaceResponseBuffers;
29 
31  const Helpers::CubeTextureName& cubeTextureName,
32  IAsyncTexture& initialTexture,
33  IAsyncTextureObserver* pObserver,
34  bool tryToUpdateIfModified=false);
35 
36  void DestroyTexture();
37  const std::string GetUrl() const;
38  const Helpers::GLHelpers::TextureInfo& GetTextureInfo() const;
39  bool IsLoaded() const;
40  bool IsComplete() const;
41  bool IsTryToUpdateIfModified() const;
42  bool HasMipMaps() const { return false; }
43 
44  void SetWebLoadRequest(int cubeFaceIndex, Web::IWebLoadRequest& webLoadRequest);
45  void ClearWebLoadRequest(int cubeFaceIndex);
46  void AttachBuffer(int cubeFaceIndex, const std::vector<Byte>& buffer);
47  void SetLoadedTexture(Eegeo::Helpers::GLHelpers::TextureInfo& textureInfoToSet);
48  void AbandonLoads();
49  const Helpers::CubeTextureName& GetCubeTextureName() const;
50  bool AllBuffersReady() const;
51  TFaceResponseBuffers TransferOwnershipOfBuffers();
52 
53  private:
55 
56  void ClearBuffers();
57 
58  HttpAsyncCubeTextureLoader& m_asyncTextureLoader;
59  Helpers::CubeTextureName m_cubeTextureName;
60  IAsyncTexture* m_texture;
61  IAsyncTextureObserver* m_pObserver;
62  bool m_isLoaded;
63  bool m_isComplete;
64  bool m_tryToUpdateIfModified;
65  TFaceRequests m_webLoadRequests;
66  TFaceResponseBuffers m_faceResponseBuffers;
67  int m_loadCount;
68  const int m_fileCount;
69  };
70  }
71  }
72 }