All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
AndroidTextureFileLoader.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "ITextureFileLoader.h"
6 #include "Types.h"
7 #include "Helpers.h"
8 #include "GLHelpers.h"
9 #include "IJpegLoader.h"
10 #include "IPNGDecoder.h"
11 #include "ICallback.h"
12 #include <string>
13 
14 namespace Eegeo
15 {
16  namespace Android
17  {
18  using namespace Eegeo::Helpers;
19 
21  {
22  Eegeo::Helpers::IFileIO* m_pFileIO;
25 
26  bool LoadPng(Eegeo::Helpers::GLHelpers::TextureInfo &textureInfo, const std::string& filename, bool mipmap, bool invertVertically);
27  bool LoadKtx(Eegeo::Helpers::GLHelpers::TextureInfo &textureInfo, const std::string& filename);
28 
29  bool LoadPngFromStream(Eegeo::Helpers::GLHelpers::TextureInfo &textureInfo, std::istream& stream, bool mipmap, bool invertVertically);
30  bool LoadPngFromBuffer(Eegeo::Helpers::GLHelpers::TextureInfo &textureInfo, const void* resourceBuffer, size_t resourceBufferSizeBytes, bool mipmap, bool invertVertically);
31  static GLenum CalcPNGGLPixelFormat(int color_type);
32 
33  bool LoadJpg(Eegeo::Helpers::GLHelpers::TextureInfo& textureInfo, const std::string& filename, bool mipmap, bool invertVertically);
34 
35  public:
36  AndroidTextureFileLoader(IFileIO *pFileIO, Jpeg::IJpegLoader& jpegLoader, PNG::IPNGDecoder& pngDecoder);
37  virtual ~AndroidTextureFileLoader();
38 
39  virtual bool LoadTexture(Eegeo::Helpers::GLHelpers::TextureInfo& info, const std::string& fileName, bool mipmap = false);
40  virtual bool LoadFromBuffer(Eegeo::Helpers::GLHelpers::TextureInfo& textureInfo, const std::string& fileExtension, const Byte* resourceBuffer, size_t bufferSizeBytes, bool mipmap=false);
41  virtual bool LoadFromCubeFaces(Eegeo::Helpers::GLHelpers::TextureInfo& out_textureInfo, const Helpers::CubeFaceFileNames& cubeFaceFileNames);
42  virtual bool LoadFromCubeFaces(Eegeo::Helpers::GLHelpers::TextureInfo& out_textureInfo, const std::vector<const std::vector<Byte>*>& cubeFaceBuffers);
43  virtual bool LoadCubeTexture(Eegeo::Helpers::GLHelpers::TextureInfo& out_textureInfo, const CubeTextureName& textureName);
44 
45  virtual Rendering::AsyncTexturing::IAsyncTextureLoad& LoadFromFileAsync(
47  const std::string& fileName,
48  void* pUserData,
49  bool mipmap = false);
50 
51  virtual Rendering::AsyncTexturing::IAsyncTextureLoad& LoadCubeFromFileAsync(
53  const Helpers::CubeTextureName& textureName,
54  void* pUserData);
55 
56  virtual Rendering::AsyncTexturing::IAsyncTextureLoad& LoadFromBufferAsync(
58  const std::string& fileExtension,
59  const std::vector<Byte>& resourceBuffer,
60  void* pUserData,
61  bool mipmap=false);
62 
63  virtual Rendering::AsyncTexturing::IAsyncTextureLoad& LoadCubeFromBuffersAsync(
65  const std::vector<const std::vector<Byte>*>& cubeFaceBuffers,
66  void* pUserData
67  );
68  };
69  }
70 }