BsTextureImportOptions.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "BsImportOptions.h"
  6. #include "BsPixelUtil.h"
  7. namespace bs
  8. {
  9. /** @addtogroup Importer
  10. * @{
  11. */
  12. /** Contains import options you may use to control how is a texture imported. */
  13. class BS_CORE_EXPORT TextureImportOptions : public ImportOptions
  14. {
  15. public:
  16. TextureImportOptions();
  17. /** Sets the pixel format to import as. */
  18. void setFormat(PixelFormat format) { mFormat = format; }
  19. /** Enables or disables mipmap generation for the texture. */
  20. void setGenerateMipmaps(bool generate) { mGenerateMips = generate; }
  21. /**
  22. * Sets the maximum mip level to generate when generating mipmaps. If 0 then maximum amount of mip levels will be
  23. * generated.
  24. */
  25. void setMaxMip(UINT32 maxMip) { mMaxMip = maxMip; }
  26. /** Sets whether the texture data is also stored in main memory, available for fast CPU access. */
  27. void setCPUCached(bool cached) { mCPUCached = cached; }
  28. /** Sets whether the texture data can be read directly from the GPU. */
  29. void setCPUReadable(bool readable) { mCPUReadable = readable; }
  30. /**
  31. * Sets whether the texture data should be treated as if its in sRGB (gamma) space. Such texture will be converted
  32. * by hardware to linear space before use on the GPU.
  33. */
  34. void setSRGB(bool sRGB) { mSRGB = sRGB; }
  35. /** Gets the pixel format to import as. */
  36. PixelFormat getFormat() const { return mFormat; }
  37. /** Checks will be imported texture have automatically generated mipmaps. */
  38. bool getGenerateMipmaps() const { return mGenerateMips; }
  39. /**
  40. * Gets the maximum mip level to generate when generating mipmaps. If 0 then maximum amount of mip levels will be
  41. * generated.
  42. */
  43. UINT32 getMaxMip() const { return mMaxMip; }
  44. /** Retrieves whether the texture data is also stored in main memory, available for fast CPU access. */
  45. bool getCPUCached() const { return mCPUCached; }
  46. /** Retrieves whether the texture data can be read directly from the GPU. */
  47. bool getCPUReadable() const { return mCPUReadable; }
  48. /**
  49. * Retrieves whether the texture data should be treated as if its in sRGB (gamma) space. Such texture will be
  50. * converted by hardware to linear space before use on the GPU.
  51. */
  52. bool getSRGB() const { return mSRGB; }
  53. /** Creates a new import options object that allows you to customize how are textures imported. */
  54. static SPtr<TextureImportOptions> create();
  55. /************************************************************************/
  56. /* SERIALIZATION */
  57. /************************************************************************/
  58. public:
  59. friend class TextureImportOptionsRTTI;
  60. static RTTITypeBase* getRTTIStatic();
  61. RTTITypeBase* getRTTI() const override;
  62. private:
  63. PixelFormat mFormat;
  64. bool mGenerateMips;
  65. UINT32 mMaxMip;
  66. bool mCPUReadable;
  67. bool mCPUCached;
  68. bool mSRGB;
  69. };
  70. /** @} */
  71. }