All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WindowsTextureFileLoader.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 <string>
12 
13 namespace Eegeo
14 {
15  namespace Windows
16  {
17  using namespace Eegeo::Helpers;
18 
20  {
21  Eegeo::Helpers::IFileIO* m_pFileIO;
24 
25  bool LoadPng(Eegeo::Helpers::GLHelpers::TextureInfo &textureInfo, const std::string& filename, bool mipmap, bool invertVertically);
26 
27  bool LoadDDS(Eegeo::Helpers::GLHelpers::TextureInfo& textureInfo, const std::string& filename);
28  bool LoadDDSFromStream(Eegeo::Helpers::GLHelpers::TextureInfo &textureInfo, std::istream& stream);
29  bool LoadDDSFromBuffer(Eegeo::Helpers::GLHelpers::TextureInfo &textureInfo, const void* resourceBuffer, size_t resourceBufferSizeBytes);
30 
31  bool LoadPngFromStream(Eegeo::Helpers::GLHelpers::TextureInfo &textureInfo, std::istream& stream, bool mipmap, bool invertVertically);
32  bool LoadPngFromBuffer(Eegeo::Helpers::GLHelpers::TextureInfo &textureInfo, const void* resourceBuffer, size_t resourceBufferSizeBytes, bool mipmap, bool invertVertically);
33  static GLenum CalcPNGGLPixelFormat(int color_type);
34 
35  bool LoadJpg(Eegeo::Helpers::GLHelpers::TextureInfo& textureInfo, const std::string& filename, bool mipmap, bool invertVertically);
36  Byte *CreateImageDataFromPngStream(std::istream& stream, u32& width, u32& height, int& colorType, bool invertVertically);
37 
38  public:
40  virtual ~WindowsTextureFileLoader();
41 
42  virtual bool LoadTexture(Eegeo::Helpers::GLHelpers::TextureInfo& info, const std::string& fileName, bool mipmap = false);
43  virtual bool LoadCubeTexture(Eegeo::Helpers::GLHelpers::TextureInfo& out_textureInfo, const CubeTextureName& cubeTextureName);
44  virtual bool LoadFromBuffer(Eegeo::Helpers::GLHelpers::TextureInfo& textureInfo, const std::string& fileExtension, const Byte* resourceBuffer, size_t bufferSizeBytes, bool mipmap=false);
45  virtual bool LoadFromCubeFaces(Eegeo::Helpers::GLHelpers::TextureInfo& out_textureInfo, const Helpers::CubeFaceFileNames& cubeFaceFileNames);
46  virtual bool LoadFromCubeFaces(Eegeo::Helpers::GLHelpers::TextureInfo& out_textureInfo, const std::vector<const std::vector<Byte>*>& cubeFaceBuffers);
47 
48  virtual Rendering::AsyncTexturing::IAsyncTextureLoad& LoadFromFileAsync(
50  const std::string& fileName,
51  void* pUserData,
52  bool mipmap = false);
53 
54  virtual Rendering::AsyncTexturing::IAsyncTextureLoad& LoadCubeFromFileAsync(
56  const Helpers::CubeTextureName& textureName,
57  void* pUserData);
58 
59  virtual Rendering::AsyncTexturing::IAsyncTextureLoad& LoadFromBufferAsync(
61  const std::string& fileExtension,
62  const std::vector<Byte>& resourceBuffer,
63  void* pUserData,
64  bool mipmap = false
65  );
66 
67  virtual Rendering::AsyncTexturing::IAsyncTextureLoad& LoadCubeFromBuffersAsync(
69  const std::vector<const std::vector<Byte>*>& cubeFaceBuffers,
70  void* pUserData
71  );
72  };
73  }
74 }