summaryrefslogtreecommitdiffstats
path: root/TextureLoader/interface
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-04-28 21:32:59 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-04-28 21:32:59 +0000
commit450a6606cedbf45aa888637058af4742d5491b01 (patch)
tree820210d82c58b39f42323f23ada328c919effe60 /TextureLoader/interface
parentUpdated GLTF loader to use Diligent file system functions (diff)
downloadDiligentTools-450a6606cedbf45aa888637058af4742d5491b01.tar.gz
DiligentTools-450a6606cedbf45aa888637058af4742d5491b01.zip
Implemented loading textures from KTX
Diffstat (limited to 'TextureLoader/interface')
-rw-r--r--TextureLoader/interface/Image.h38
-rw-r--r--TextureLoader/interface/TextureLoader.h24
-rw-r--r--TextureLoader/interface/TextureUtilities.h23
3 files changed, 53 insertions, 32 deletions
diff --git a/TextureLoader/interface/Image.h b/TextureLoader/interface/Image.h
index 5b9860e..a970d77 100644
--- a/TextureLoader/interface/Image.h
+++ b/TextureLoader/interface/Image.h
@@ -47,7 +47,13 @@ enum class EImageFileFormat
png,
/// The image is encoded in TIFF format
- tiff
+ tiff,
+
+ /// DDS file
+ dds,
+
+ /// KTX file
+ ktx
};
/// Image loading information
@@ -106,30 +112,32 @@ public:
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; }
+ 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);
+ 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>
friend class MakeNewRCObj;
- Image(IReferenceCounters *pRefCounters,
- IDataBlob *pFileData,
- const ImageLoadInfo& LoadInfo);
+ 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 );
+ 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;
diff --git a/TextureLoader/interface/TextureLoader.h b/TextureLoader/interface/TextureLoader.h
index ffc86d0..4de89fb 100644
--- a/TextureLoader/interface/TextureLoader.h
+++ b/TextureLoader/interface/TextureLoader.h
@@ -75,10 +75,10 @@ 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 CreateTextureFromImage( Image *pSrcImage,
+ void CreateTextureFromImage( Image* pSrcImage,
const TextureLoadInfo& TexLoadInfo,
- IRenderDevice *pDevice,
- ITexture **ppTexture );
+ IRenderDevice* pDevice,
+ ITexture** ppTexture );
/// Creates a texture from DDS data blob
@@ -86,8 +86,20 @@ 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 CreateTextureFromDDS( IDataBlob *pDDSData,
+ void CreateTextureFromDDS( IDataBlob* pDDSData,
const TextureLoadInfo& TexLoadInfo,
- IRenderDevice *pDevice,
- ITexture **ppTexture );
+ 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 );
};
diff --git a/TextureLoader/interface/TextureUtilities.h b/TextureLoader/interface/TextureUtilities.h
index 82fbf8d..73ba1e0 100644
--- a/TextureLoader/interface/TextureUtilities.h
+++ b/TextureLoader/interface/TextureUtilities.h
@@ -36,13 +36,14 @@ namespace Diligent
/// Creates an image from file
-/// \param [in] FilePath - Source file path
-/// \param [out] ppImage - Memory location where pointer to the created image will be stored
-/// \param [out] ppDDSData - If the file is a dds file, this will contain the pointer to the blob
-/// containing dds data. This parameter can be null.
-void CreateImageFromFile( const Char *FilePath,
- Image **ppImage,
- IDataBlob **ppDDSData = nullptr);
+/// \param [in] FilePath - Source file path
+/// \param [out] ppImage - Memory location where pointer to the created image will be stored
+/// \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);
/// Creates a texture from file
@@ -51,9 +52,9 @@ void CreateImageFromFile( const Char *FilePath,
/// \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 );
}