TextureObject.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 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 _TEXTURE_OBJECT_H_
  23. #define _TEXTURE_OBJECT_H_
  24. #ifndef _PLATFORM_H_
  25. #include "platform/platform.h"
  26. #endif
  27. #ifndef _PLATFORMGL_H_
  28. #include "platform/platformAssert.h"
  29. #include "platform/platformGL.h"
  30. #endif
  31. #ifndef _TEXTURE_HANDLE_H_
  32. #include "graphics/TextureHandle.h"
  33. #endif
  34. #ifndef _GBITMAP_H_
  35. #include "graphics/gBitmap.h"
  36. #endif
  37. //-----------------------------------------------------------------------------
  38. class GBitmap;
  39. //------------------------------------------------------------------------------
  40. class TextureObject
  41. {
  42. friend class TextureManager;
  43. friend class TextureDictionary;
  44. friend class TextureHandle;
  45. private:
  46. TextureObject* next;
  47. TextureObject* prev;
  48. TextureObject* hashNext;
  49. S32 mTextureResidentWasteSize;
  50. S32 mTextureResidentSize;
  51. S32 mBitmapResidentSize;
  52. S32 mRefCount;
  53. StringTableEntry mTextureKey;
  54. GLuint mGLTextureName;
  55. GBitmap* mpBitmap;
  56. U32 mTextureWidth;
  57. U32 mTextureHeight;
  58. U32 mBitmapWidth;
  59. U32 mBitmapHeight;
  60. GLuint mFilter;
  61. bool mClamp;
  62. TextureHandle::TextureHandleType mHandleType;
  63. public:
  64. TextureObject() :
  65. next( NULL ), prev( NULL ), hashNext( NULL ),
  66. mTextureResidentWasteSize( 0 ),
  67. mTextureResidentSize( 0 ),
  68. mBitmapResidentSize( 0 ),
  69. mRefCount( 0 ),
  70. mTextureKey( NULL ),
  71. mGLTextureName( 0 ),
  72. mpBitmap( NULL ),
  73. mTextureWidth( 0 ),
  74. mTextureHeight( 0 ),
  75. mBitmapWidth( 0 ),
  76. mBitmapHeight( 0 ),
  77. mFilter( GL_NEAREST ),
  78. mClamp( false ),
  79. mHandleType( TextureHandle::InvalidTexture )
  80. {
  81. }
  82. inline StringTableEntry getTextureKey( void ) { return mTextureKey; }
  83. inline GLuint getGLTextureName( void ) { return mGLTextureName; }
  84. inline const GBitmap* getBitmap( void ) { return mpBitmap; }
  85. inline U32 getTextureWidth( void ) { return mTextureWidth; }
  86. inline U32 getTextureHeight( void ) { return mTextureHeight; }
  87. inline U32 getBitmapWidth( void ) { return mBitmapWidth; }
  88. inline U32 getBitmapHeight( void ) { return mBitmapHeight; }
  89. inline GLuint getFilter( void ) { return mFilter; }
  90. inline bool getClamp( void ) { return mClamp; }
  91. inline S32 getTextureResidentSize( void ) const { return mTextureResidentSize; }
  92. inline S32 getBitmapResidentSize( void ) const { return mBitmapResidentSize; }
  93. inline TextureHandle::TextureHandleType getHandleType( void ) { return mHandleType; }
  94. };
  95. #endif // _TEXTURE_OBJECT_H_