CmTextureManager.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmTexture.h"
  4. #include "CmModule.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Defines interface for creation of textures. Render systems
  9. * provide their own implementations.
  10. *
  11. * @note Thread safe.
  12. */
  13. class CM_EXPORT TextureManager : public Module<TextureManager>
  14. {
  15. public:
  16. TextureManager();
  17. virtual ~TextureManager();
  18. /**
  19. * @copydoc Texture::create(TextureType, UINT32, UINT32, UINT32, int, PixelFormat, int, bool, UINT32, const String&)
  20. */
  21. TexturePtr createTexture(TextureType texType, UINT32 width, UINT32 height, UINT32 depth,
  22. int numMips, PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false,
  23. UINT32 fsaa = 0, const String& fsaaHint = StringUtil::BLANK);
  24. /**
  25. * @copydoc Texture::create(TextureType, UINT32, UINT32, int, PixelFormat, int, bool, UINT32, const String&)
  26. */
  27. TexturePtr createTexture(TextureType texType, UINT32 width, UINT32 height, int numMips,
  28. PixelFormat format, int usage = TU_DEFAULT, bool hwGammaCorrection = false, UINT32 fsaa = 0,
  29. const String& fsaaHint = StringUtil::BLANK)
  30. {
  31. return createTexture(texType, width, height, 1,
  32. numMips, format, usage, hwGammaCorrection, fsaa, fsaaHint);
  33. }
  34. /**
  35. * @brief Creates a completely empty and uninitialized Texture.
  36. *
  37. * @note Internal method. Should only be used for very specific purposes, like deserialization,
  38. * as it requires additional manual initialization that is not required normally.
  39. */
  40. TexturePtr _createEmpty();
  41. /**
  42. * @brief Creates a new RenderTexture and automatically generates a color surface
  43. * and (optionally) a depth/stencil surface.
  44. *
  45. * @param texType Type of the texture.
  46. * @param width Width of the texture in pixels.
  47. * @param height Height of the texture in pixels.
  48. * @param format Format of the pixels.
  49. * @param hwGamma If true, any color data will be gamma corrected before being written
  50. * into the texture.
  51. * @param fsaa If higher than 1, texture containing multiple samples per pixel is created.
  52. * @param fsaaHint Hint about what kind of multisampling to use. Render system specific.
  53. * @param createDepth Determines will a depth/stencil buffer of the same size as the color buffer be created
  54. * for the render texture.
  55. * @param depthStencilFormat Format of the depth/stencil buffer if enabled.
  56. */
  57. virtual RenderTexturePtr createRenderTexture(TextureType textureType, UINT32 width, UINT32 height,
  58. PixelFormat format = PF_R8G8B8A8, bool hwGamma = false, UINT32 fsaa = 0, const String& fsaaHint = "",
  59. bool createDepth = true, PixelFormat depthStencilFormat = PF_D24S8);
  60. /**
  61. * @brief Creates a RenderTexture using the description struct.
  62. */
  63. virtual RenderTexturePtr createRenderTexture(const RENDER_TEXTURE_DESC& desc);
  64. /**
  65. * @brief Creates a new multi render texture. You may use this type of texture
  66. * to render to multiple output textures at once.
  67. */
  68. virtual MultiRenderTexturePtr createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
  69. /**
  70. * @brief Gets the format which will be natively used for a requested format given the
  71. * constraints of the current device.
  72. *
  73. * @note Thread safe.
  74. */
  75. virtual PixelFormat getNativeFormat(TextureType ttype, PixelFormat format, int usage) = 0;
  76. const HTexture& getDummyTexture() const { return mDummyTexture; }
  77. protected:
  78. /**
  79. * @brief Creates an empty and uninitialized texture of a specific type. This is to be implemented
  80. * by render systems with their own implementations.
  81. */
  82. virtual TexturePtr createTextureImpl() = 0;
  83. /**
  84. * @brief Creates an empty and uninitialized render texture of a specific type. This
  85. * is to be implemented by render systems with their own implementations.
  86. */
  87. virtual RenderTexturePtr createRenderTextureImpl() = 0;
  88. /**
  89. * @brief Creates an empty and uninitialized multi render texture of a specific type. This is
  90. * to be implemented by render systems with their own implementations.
  91. */
  92. virtual MultiRenderTexturePtr createMultiRenderTextureImpl() = 0;
  93. /**
  94. * @copydoc Module::onStartUp
  95. */
  96. virtual void onStartUp();
  97. protected:
  98. HTexture mDummyTexture;
  99. };
  100. }