TextureResource.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright (C) 2009-2015, Panagiotis Christopoulos Charitos.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #ifndef ANKI_RESOURCE_TEXTURE_RESOURCE_H
  6. #define ANKI_RESOURCE_TEXTURE_RESOURCE_H
  7. #include "anki/resource/Common.h"
  8. #include "anki/Gl.h"
  9. namespace anki {
  10. // Forward
  11. class Image;
  12. /// @addtogroup resource
  13. /// @{
  14. /// Texture resource class.
  15. ///
  16. /// It loads or creates an image and then loads it in the GPU. It supports
  17. /// compressed and uncompressed TGAs and AnKi's texture format.
  18. class TextureResource
  19. {
  20. public:
  21. TextureResource(ResourceAllocator<U8>& alloc);
  22. ~TextureResource();
  23. /// Load a texture
  24. ANKI_USE_RESULT Error load(
  25. const CString& filename, ResourceInitializer& init);
  26. /// Get the GL texture
  27. const GlTextureHandle& getGlTexture() const
  28. {
  29. return m_tex;
  30. }
  31. /// Get the GL texture
  32. GlTextureHandle& getGlTexture()
  33. {
  34. return m_tex;
  35. }
  36. U32 getWidth() const
  37. {
  38. return m_size.x();
  39. }
  40. U32 getHeight() const
  41. {
  42. return m_size.y();
  43. }
  44. U32 getDepth() const
  45. {
  46. return m_size.z();
  47. }
  48. private:
  49. GlTextureHandle m_tex;
  50. UVec3 m_size;
  51. };
  52. /// @}
  53. } // end namespace anki
  54. #endif