BsTextureImportOptions.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 "Importer/BsImportOptions.h"
  6. #include "Image/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. /**
  29. * Sets whether the texture data should be treated as if its in sRGB (gamma) space. Such texture will be converted
  30. * by hardware to linear space before use on the GPU.
  31. */
  32. void setSRGB(bool sRGB) { mSRGB = sRGB; }
  33. /** Gets the pixel format to import as. */
  34. PixelFormat getFormat() const { return mFormat; }
  35. /** Checks will be imported texture have automatically generated mipmaps. */
  36. bool getGenerateMipmaps() const { return mGenerateMips; }
  37. /**
  38. * Gets the maximum mip level to generate when generating mipmaps. If 0 then maximum amount of mip levels will be
  39. * generated.
  40. */
  41. UINT32 getMaxMip() const { return mMaxMip; }
  42. /** Retrieves whether the texture data is also stored in main memory, available for fast CPU access. */
  43. bool getCPUCached() const { return mCPUCached; }
  44. /**
  45. * Retrieves whether the texture data should be treated as if its in sRGB (gamma) space. Such texture will be
  46. * converted by hardware to linear space before use on the GPU.
  47. */
  48. bool getSRGB() const { return mSRGB; }
  49. /**
  50. * Determines should the texture be imported as a cubemap. See setCubemapSource to choose how will the source
  51. * texture be converted to a cubemap.
  52. */
  53. void setIsCubemap(bool cubemap) { mCubemap = cubemap; }
  54. /** Checks if the texture will be imported as a cubemap. */
  55. bool getIsCubemap() const { return mCubemap; }
  56. /**
  57. * Sets a value that determines how should the source texture be interpreted when generating a cubemap. Only
  58. * relevant when setIsCubemap() is set to true.
  59. */
  60. void setCubemapSourceType(CubemapSourceType type) { mCubemapSourceType = type; }
  61. /**
  62. * Returns a value that determines how should the source texture be interpreted when generating a cubemap. Only
  63. * relevant when setIsCubemap() is set to true.
  64. */
  65. CubemapSourceType getCubemapSourceType() const { return mCubemapSourceType; }
  66. /** Creates a new import options object that allows you to customize how are textures imported. */
  67. static SPtr<TextureImportOptions> create();
  68. /************************************************************************/
  69. /* SERIALIZATION */
  70. /************************************************************************/
  71. public:
  72. friend class TextureImportOptionsRTTI;
  73. static RTTITypeBase* getRTTIStatic();
  74. RTTITypeBase* getRTTI() const override;
  75. private:
  76. PixelFormat mFormat;
  77. bool mGenerateMips;
  78. UINT32 mMaxMip;
  79. bool mCPUCached;
  80. bool mSRGB;
  81. bool mCubemap;
  82. CubemapSourceType mCubemapSourceType;
  83. };
  84. /** @} */
  85. }