gfxTextureArray.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GFXTEXTUREARRAY_H_
  23. #define _GFXTEXTUREARRAY_H_
  24. #ifndef _REFBASE_H_
  25. #include "core/util/refBase.h"
  26. #endif
  27. #ifndef _GFXRESOURCE_H_
  28. #include "gfx/gfxResource.h"
  29. #endif
  30. #ifndef _GFXENUMS_H_
  31. #include "gfxEnums.h"
  32. #endif
  33. #ifndef _GFXTEXTUREHANDLE_H_
  34. #include "gfxTextureHandle.h"
  35. #endif
  36. #include "core/util/tVector.h"
  37. class GFXTextureProfile;
  38. class GFXTextureObject;
  39. class GFXTextureArray : public StrongRefBase, public GFXResource
  40. {
  41. public:
  42. GFXTextureArray();
  43. virtual void init() = 0;
  44. virtual void set(U32 width, U32 height, U32 size, GFXFormat format, U32 mipLevels = 0);
  45. virtual bool fromTextureArray(const Vector<GFXTexHandle> &textureArray, U32 capacity = 0);
  46. virtual void setTexture(const GFXTexHandle &texture, U32 slot);
  47. virtual void setToTexUnit(U32 tuNum) = 0;
  48. // GFXResource interface
  49. virtual void zombify() = 0;
  50. virtual void resurrect() = 0;
  51. virtual void Release();
  52. virtual const String describeSelf() const;
  53. GFXFormat mFormat;
  54. bool mIsCompressed;
  55. U32 mWidth;
  56. U32 mHeight;
  57. U32 mArraySize;
  58. U32 mMipLevels;
  59. Vector<GFXTexHandle> mTextures;
  60. protected:
  61. virtual void _setTexture(const GFXTexHandle& texture, U32 slot) = 0;
  62. };
  63. /// A reference counted handle to a texture array resource.
  64. class GFXTextureArrayHandle : public StrongRefPtr<GFXTextureArray>
  65. {
  66. public:
  67. GFXTextureArrayHandle() {}
  68. GFXTextureArrayHandle(GFXTextureArray* textureArray) { StrongRefPtr<GFXTextureArray>::set(textureArray); }
  69. /// Releases the texture handle.
  70. void free() { StrongObjectRef::set(NULL); }
  71. };
  72. #endif // _GFXTEXTUREARRAY_H_