BsTextureManager.h 4.8 KB

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