TextureResource.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <anki/resource/ResourceObject.h>
  7. #include <anki/Gr.h>
  8. namespace anki
  9. {
  10. /// @addtogroup resource
  11. /// @{
  12. /// Texture resource class.
  13. ///
  14. /// It loads or creates an image and then loads it in the GPU. It supports
  15. /// compressed and uncompressed TGAs and AnKi's texture format.
  16. class TextureResource : public ResourceObject
  17. {
  18. public:
  19. TextureResource(ResourceManager* manager)
  20. : ResourceObject(manager)
  21. {
  22. }
  23. ~TextureResource();
  24. /// Load a texture
  25. ANKI_USE_RESULT Error load(const ResourceFilename& filename);
  26. /// Get the texture
  27. const TexturePtr& getGrTexture() const
  28. {
  29. return m_tex;
  30. }
  31. /// Get the texture
  32. TexturePtr& getGrTexture()
  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. TexturePtr m_tex;
  50. UVec3 m_size;
  51. };
  52. /// @}
  53. } // end namespace anki