summaryrefslogtreecommitdiffstats
path: root/TextureLoader/interface
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-11-25 03:19:41 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-11-25 03:19:41 +0000
commit942fdb82bb026350f1a27856efbc231e89fcada6 (patch)
tree3769a22f6e52831d2383f99f328e393404c97e37 /TextureLoader/interface
parentclang-formatted NativeApp (diff)
downloadDiligentTools-942fdb82bb026350f1a27856efbc231e89fcada6.tar.gz
DiligentTools-942fdb82bb026350f1a27856efbc231e89fcada6.zip
clang-formatted TextureLoader project
Diffstat (limited to 'TextureLoader/interface')
-rw-r--r--TextureLoader/interface/Image.h58
-rw-r--r--TextureLoader/interface/TextureLoader.h162
-rw-r--r--TextureLoader/interface/TextureUtilities.h10
3 files changed, 116 insertions, 114 deletions
diff --git a/TextureLoader/interface/Image.h b/TextureLoader/interface/Image.h
index 1ea3e38..641518e 100644
--- a/TextureLoader/interface/Image.h
+++ b/TextureLoader/interface/Image.h
@@ -100,46 +100,46 @@ public:
struct EncodeInfo
{
- Uint32 Width = 0;
- Uint32 Height = 0;
- TEXTURE_FORMAT TexFormat = TEX_FORMAT_UNKNOWN;
- bool KeepAlpha = false;
- const void* pData = nullptr;
- Uint32 Stride = 0;
- EImageFileFormat FileFormat = EImageFileFormat::jpeg;
- int JpegQuality = 95;
+ Uint32 Width = 0;
+ Uint32 Height = 0;
+ TEXTURE_FORMAT TexFormat = TEX_FORMAT_UNKNOWN;
+ bool KeepAlpha = false;
+ const void* pData = nullptr;
+ Uint32 Stride = 0;
+ EImageFileFormat FileFormat = EImageFileFormat::jpeg;
+ int JpegQuality = 95;
};
static void Encode(const EncodeInfo& Info, IDataBlob** ppEncodedData);
/// Returns image description
- const ImageDesc& GetDesc(){ return m_Desc; }
+ const ImageDesc& GetDesc() { return m_Desc; }
/// Returns a pointer to the image data
- IDataBlob* GetData(){ return m_pData; }
-
- static std::vector<Uint8> ConvertImageData(Uint32 Width,
- Uint32 Height,
- const Uint8* pData,
- Uint32 Stride,
- TEXTURE_FORMAT SrcFormat,
- TEXTURE_FORMAT DstFormat,
- bool KeepAlpha);
-
+ IDataBlob* GetData() { return m_pData; }
+
+ static std::vector<Uint8> ConvertImageData(Uint32 Width,
+ Uint32 Height,
+ const Uint8* pData,
+ Uint32 Stride,
+ TEXTURE_FORMAT SrcFormat,
+ TEXTURE_FORMAT DstFormat,
+ bool KeepAlpha);
+
static EImageFileFormat GetFileFormat(const Uint8* pData, size_t Size);
private:
- template<typename AllocatorType, typename ObjectType>
+ template <typename AllocatorType, typename ObjectType>
friend class MakeNewRCObj;
Image(IReferenceCounters* pRefCounters,
IDataBlob* pFileData,
const ImageLoadInfo& LoadInfo);
- void LoadPngFile( IDataBlob* pFileData, const ImageLoadInfo& LoadInfo );
- void LoadTiffFile( IDataBlob* pFileData, const ImageLoadInfo& LoadInfo );
- void LoadJpegFile( IDataBlob* pFileData, const ImageLoadInfo& LoadInfo );
-
- ImageDesc m_Desc;
+ void LoadPngFile(IDataBlob* pFileData, const ImageLoadInfo& LoadInfo);
+ void LoadTiffFile(IDataBlob* pFileData, const ImageLoadInfo& LoadInfo);
+ void LoadJpegFile(IDataBlob* pFileData, const ImageLoadInfo& LoadInfo);
+
+ ImageDesc m_Desc;
RefCntAutoPtr<IDataBlob> m_pData;
};
@@ -151,8 +151,8 @@ private:
/// \param [out] ppRawData - If the file format is not recognized by the function, it will load raw bytes
/// and return them in the data blob. This parameter can be null.
/// \return Image file format.
-EImageFileFormat CreateImageFromFile(const Char* FilePath,
- Image** ppImage,
- IDataBlob** ppRawData = nullptr);
+EImageFileFormat CreateImageFromFile(const Char* FilePath,
+ Image** ppImage,
+ IDataBlob** ppRawData = nullptr);
-}
+} // namespace Diligent
diff --git a/TextureLoader/interface/TextureLoader.h b/TextureLoader/interface/TextureLoader.h
index 0c409e6..8b1723d 100644
--- a/TextureLoader/interface/TextureLoader.h
+++ b/TextureLoader/interface/TextureLoader.h
@@ -30,85 +30,87 @@
namespace Diligent
{
- /// Texture loading information
- struct TextureLoadInfo
- {
- /// Texture name passed over to the texture creation method
- const Char* Name = nullptr;
+// clang-format off
+/// Texture loading information
+struct TextureLoadInfo
+{
+ /// Texture name passed over to the texture creation method
+ const Char* Name = nullptr;
- /// Usage
- USAGE Usage = USAGE_STATIC;
-
- /// Bind flags
- BIND_FLAGS BindFlags = BIND_SHADER_RESOURCE;
-
- /// Number of mip levels
- Uint32 MipLevels = 0;
-
- /// CPU access flags
- CPU_ACCESS_FLAGS CPUAccessFlags = CPU_ACCESS_NONE;
-
- /// Flag indicating if this texture uses sRGB gamma encoding
- Bool IsSRGB = False;
-
- /// Flag indicating that the procedure should generate lower mip levels
- Bool GenerateMips = True;
-
- /// Texture format
- TEXTURE_FORMAT Format = TEX_FORMAT_UNKNOWN;
-
- explicit TextureLoadInfo(const Char* _Name,
- USAGE _Usage = TextureLoadInfo{}.Usage,
- BIND_FLAGS _BindFlags = TextureLoadInfo{}.BindFlags,
- Uint32 _MipLevels = TextureLoadInfo{}.MipLevels,
- CPU_ACCESS_FLAGS _CPUAccessFlags = TextureLoadInfo{}.CPUAccessFlags,
- Bool _IsSRGB = TextureLoadInfo{}.IsSRGB,
- Bool _GenerateMips = TextureLoadInfo{}.GenerateMips,
- TEXTURE_FORMAT _Format = TextureLoadInfo{}.Format) :
- Name (_Name),
- Usage (_Usage),
- BindFlags (_BindFlags),
- MipLevels (_MipLevels),
- CPUAccessFlags (_CPUAccessFlags),
- IsSRGB (_IsSRGB),
- GenerateMips (_GenerateMips),
- Format (_Format)
- {}
-
- TextureLoadInfo(){};
- };
-
- /// Creates a texture from 2D image
-
- /// \param [in] pSrcImage - Pointer to the source image data
- /// \param [in] TexLoadInfo - Texture loading information
- /// \param [in] pDevice - Render device that will be used to create the texture
- /// \param [out] ppTexture - Memory location where pointer to the created texture will be stored
- void CreateTextureFromImage( Image* pSrcImage,
- const TextureLoadInfo& TexLoadInfo,
- IRenderDevice* pDevice,
- ITexture** ppTexture );
-
- /// Creates a texture from DDS data blob
-
- /// \param [in] pDDSData - Pointer to the DDS data blob
- /// \param [in] TexLoadInfo - Texture loading information
- /// \param [in] pDevice - Render device that will be used to create the texture
- /// \param [out] ppTexture - Memory location where pointer to the created texture will be stored
- void CreateTextureFromDDS( IDataBlob* pDDSData,
- const TextureLoadInfo& TexLoadInfo,
- IRenderDevice* pDevice,
- ITexture** ppTexture );
-
-
- /// Creates a texture from KTX data blob
-
- /// \param [in] pKTXData - Pointer to the KTX data blob
- /// \param [in] TexLoadInfo - Texture loading information
- /// \param [in] pDevice - Render device that will be used to create the texture
- /// \param [out] ppTexture - Memory location where pointer to the created texture will be stored
- void CreateTextureFromKTX( IDataBlob* pKTXData,
- const TextureLoadInfo& TexLoadInfo,
- IRenderDevice* pDevice,
- ITexture** ppTexture );
+ /// Usage
+ USAGE Usage = USAGE_STATIC;
+
+ /// Bind flags
+ BIND_FLAGS BindFlags = BIND_SHADER_RESOURCE;
+
+ /// Number of mip levels
+ Uint32 MipLevels = 0;
+
+ /// CPU access flags
+ CPU_ACCESS_FLAGS CPUAccessFlags = CPU_ACCESS_NONE;
+
+ /// Flag indicating if this texture uses sRGB gamma encoding
+ Bool IsSRGB = False;
+
+ /// Flag indicating that the procedure should generate lower mip levels
+ Bool GenerateMips = True;
+
+ /// Texture format
+ TEXTURE_FORMAT Format = TEX_FORMAT_UNKNOWN;
+
+ explicit TextureLoadInfo(const Char* _Name,
+ USAGE _Usage = TextureLoadInfo{}.Usage,
+ BIND_FLAGS _BindFlags = TextureLoadInfo{}.BindFlags,
+ Uint32 _MipLevels = TextureLoadInfo{}.MipLevels,
+ CPU_ACCESS_FLAGS _CPUAccessFlags = TextureLoadInfo{}.CPUAccessFlags,
+ Bool _IsSRGB = TextureLoadInfo{}.IsSRGB,
+ Bool _GenerateMips = TextureLoadInfo{}.GenerateMips,
+ TEXTURE_FORMAT _Format = TextureLoadInfo{}.Format) :
+ Name {_Name},
+ Usage {_Usage},
+ BindFlags {_BindFlags},
+ MipLevels {_MipLevels},
+ CPUAccessFlags {_CPUAccessFlags},
+ IsSRGB {_IsSRGB},
+ GenerateMips {_GenerateMips},
+ Format {_Format}
+ {}
+
+ TextureLoadInfo(){};
};
+// clang-format on
+
+/// Creates a texture from 2D image
+
+/// \param [in] pSrcImage - Pointer to the source image data
+/// \param [in] TexLoadInfo - Texture loading information
+/// \param [in] pDevice - Render device that will be used to create the texture
+/// \param [out] ppTexture - Memory location where pointer to the created texture will be stored
+void CreateTextureFromImage(Image* pSrcImage,
+ const TextureLoadInfo& TexLoadInfo,
+ IRenderDevice* pDevice,
+ ITexture** ppTexture);
+
+/// Creates a texture from DDS data blob
+
+/// \param [in] pDDSData - Pointer to the DDS data blob
+/// \param [in] TexLoadInfo - Texture loading information
+/// \param [in] pDevice - Render device that will be used to create the texture
+/// \param [out] ppTexture - Memory location where pointer to the created texture will be stored
+void CreateTextureFromDDS(IDataBlob* pDDSData,
+ const TextureLoadInfo& TexLoadInfo,
+ IRenderDevice* pDevice,
+ ITexture** ppTexture);
+
+
+/// Creates a texture from KTX data blob
+
+/// \param [in] pKTXData - Pointer to the KTX data blob
+/// \param [in] TexLoadInfo - Texture loading information
+/// \param [in] pDevice - Render device that will be used to create the texture
+/// \param [out] ppTexture - Memory location where pointer to the created texture will be stored
+void CreateTextureFromKTX(IDataBlob* pKTXData,
+ const TextureLoadInfo& TexLoadInfo,
+ IRenderDevice* pDevice,
+ ITexture** ppTexture);
+}; // namespace Diligent
diff --git a/TextureLoader/interface/TextureUtilities.h b/TextureLoader/interface/TextureUtilities.h
index 969e9f5..a85a09f 100644
--- a/TextureLoader/interface/TextureUtilities.h
+++ b/TextureLoader/interface/TextureUtilities.h
@@ -40,9 +40,9 @@ namespace Diligent
/// \param [in] TexLoadInfo - Texture loading information
/// \param [in] pDevice - Render device that will be used to create the texture
/// \param [out] ppTexture - Memory location where pointer to the created texture will be stored
-void CreateTextureFromFile( const Char* FilePath,
- const TextureLoadInfo& TexLoadInfo,
- IRenderDevice* pDevice,
- ITexture** ppTexture );
+void CreateTextureFromFile(const Char* FilePath,
+ const TextureLoadInfo& TexLoadInfo,
+ IRenderDevice* pDevice,
+ ITexture** ppTexture);
-}
+} // namespace Diligent