CmTextureST.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmRTTIType.h"
  4. #include "CmTexture.h"
  5. #include "CmTextureData.h"
  6. #include "CmManagedDataBlock.h"
  7. // DEBUG ONLY
  8. #include "CmTextureManager.h"
  9. namespace CamelotEngine
  10. {
  11. class CM_EXPORT TextureST : public RTTIType<Texture, Resource, TextureST>
  12. {
  13. private:
  14. CM_SETGET_MEMBER(mSize, UINT32, Texture)
  15. CM_SETGET_MEMBER(mSourceUUID, UUID, Texture);
  16. CM_SETGET_MEMBER(mHeight, UINT32, Texture)
  17. CM_SETGET_MEMBER(mWidth, UINT32, Texture)
  18. CM_SETGET_MEMBER(mDepth, UINT32, Texture)
  19. CM_SETGET_MEMBER(mNumRequestedMipmaps, UINT32, Texture)
  20. CM_SETGET_MEMBER(mNumMipmaps, UINT32, Texture)
  21. CM_SETGET_MEMBER(mMipmapsHardwareGenerated, bool, Texture)
  22. CM_SETGET_MEMBER(mGamma, float, Texture)
  23. CM_SETGET_MEMBER(mHwGamma, bool, Texture)
  24. CM_SETGET_MEMBER(mFSAA, UINT32, Texture)
  25. CM_SETGET_MEMBER(mFSAAHint, String, Texture)
  26. CM_SETGET_MEMBER(mTextureType, TextureType, Texture)
  27. CM_SETGET_MEMBER(mFormat, PixelFormat, Texture)
  28. CM_SETGET_MEMBER(mUsage, INT32, Texture)
  29. CM_SETGET_MEMBER(mDesiredFormat, PixelFormat, Texture)
  30. CM_SETGET_MEMBER(mDesiredIntegerBitDepth, UINT16, Texture)
  31. CM_SETGET_MEMBER(mDesiredFloatBitDepth, UINT16, Texture)
  32. std::shared_ptr<TextureData> getTextureData(Texture* obj, UINT32 face)
  33. {
  34. return obj->getTextureData(face);
  35. }
  36. void setTextureData(Texture* obj, UINT32 face, TextureDataPtr data)
  37. {
  38. return obj->setTextureData(face, data);
  39. }
  40. UINT32 getTextureDataArraySize(Texture* obj)
  41. {
  42. return obj->getNumFaces();
  43. }
  44. void setTextureDataArraySize(Texture* obj, UINT32 size)
  45. {
  46. // Not allowed to change size this way
  47. }
  48. public:
  49. TextureST()
  50. {
  51. CM_ADD_PLAINFIELD(mSize, 0, TextureST)
  52. CM_ADD_PLAINFIELD(mSourceUUID, 1, TextureST)
  53. CM_ADD_PLAINFIELD(mHeight, 2, TextureST)
  54. CM_ADD_PLAINFIELD(mWidth, 3, TextureST)
  55. CM_ADD_PLAINFIELD(mDepth, 4, TextureST)
  56. CM_ADD_PLAINFIELD(mNumRequestedMipmaps, 5, TextureST)
  57. CM_ADD_PLAINFIELD(mNumMipmaps, 6, TextureST)
  58. CM_ADD_PLAINFIELD(mMipmapsHardwareGenerated, 7, TextureST)
  59. CM_ADD_PLAINFIELD(mGamma, 8, TextureST)
  60. CM_ADD_PLAINFIELD(mHwGamma, 9, TextureST)
  61. CM_ADD_PLAINFIELD(mFSAA, 10, TextureST)
  62. CM_ADD_PLAINFIELD(mFSAAHint, 11, TextureST)
  63. CM_ADD_PLAINFIELD(mTextureType, 12, TextureST)
  64. CM_ADD_PLAINFIELD(mFormat, 13, TextureST)
  65. CM_ADD_PLAINFIELD(mUsage, 14, TextureST)
  66. CM_ADD_PLAINFIELD(mDesiredFormat, 15, TextureST)
  67. CM_ADD_PLAINFIELD(mDesiredIntegerBitDepth, 16, TextureST)
  68. CM_ADD_PLAINFIELD(mDesiredFloatBitDepth, 17, TextureST)
  69. addReflectablePtrArrayField("mTextureData", 18, &TextureST::getTextureData, &TextureST::getTextureDataArraySize,
  70. &TextureST::setTextureData, &TextureST::setTextureDataArraySize);
  71. }
  72. virtual const String& getRTTIName()
  73. {
  74. static String name = "Texture";
  75. return name;
  76. }
  77. virtual UINT32 getRTTIId()
  78. {
  79. return 101;
  80. }
  81. virtual std::shared_ptr<IReflectable> newRTTIObject()
  82. {
  83. // DEBUG ONLY - Remove this after I implement RTTI types for specific texture types
  84. return TextureManager::instance().create(TEX_TYPE_2D, 128, 128, 1, PF_A8B8G8R8);
  85. //CM_EXCEPT(InternalErrorException, "Cannot instantiate abstract class!");
  86. }
  87. };
  88. }