-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added DDSTextureLoader wrapper. Added new formats to ContainerFormat. Updated read-me. Renamed TextureHelper to WICTextureHelper. Updated sample program.
- Loading branch information
unknown
committed
Dec 1, 2024
1 parent
551bb4d
commit bae73e2
Showing
16 changed files
with
291 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include "DDSTextureHelper.h" | ||
|
||
using namespace System; | ||
using namespace System::Runtime::InteropServices; | ||
|
||
HRESULT DirectXTK::DDSTextureHelper::CreateDDSTextureFromFile(Silk::NET::Direct3D11::ID3D11Device* device, String^ filePath, Silk::NET::Direct3D11::ID3D11Resource** texture, Silk::NET::Direct3D11::ID3D11ShaderResourceView** textureView, UINT maxSize, DDSAlphaMode alphaMode) | ||
{ | ||
auto chars = (wchar_t*)Marshal::StringToHGlobalUni(filePath).ToPointer(); | ||
auto nativeAlphaMode = static_cast<DirectX::DDS_ALPHA_MODE>(alphaMode); | ||
|
||
HRESULT result = DirectX::CreateDDSTextureFromFile((ID3D11Device*)device, chars, (ID3D11Resource**)texture, (ID3D11ShaderResourceView**)textureView, maxSize, &nativeAlphaMode); | ||
|
||
Marshal::FreeHGlobal(IntPtr(chars)); | ||
return result; | ||
} | ||
|
||
HRESULT DirectXTK::DDSTextureHelper::CreateDDSTextureFromFile(Silk::NET::Direct3D11::ID3D11Device* device, Silk::NET::Direct3D11::ID3D11DeviceContext* deviceContext, String^ filePath, Silk::NET::Direct3D11::ID3D11Resource** texture, Silk::NET::Direct3D11::ID3D11ShaderResourceView** textureView, UINT maxSize, DDSAlphaMode alphaMode) | ||
{ | ||
auto chars = (wchar_t*)Marshal::StringToHGlobalUni(filePath).ToPointer(); | ||
auto nativeAlphaMode = static_cast<DirectX::DDS_ALPHA_MODE>(alphaMode); | ||
|
||
HRESULT result = DirectX::CreateDDSTextureFromFile((ID3D11Device*)device, (ID3D11DeviceContext*)deviceContext, chars, (ID3D11Resource**)texture, (ID3D11ShaderResourceView**)textureView, maxSize, &nativeAlphaMode); | ||
|
||
Marshal::FreeHGlobal(IntPtr(chars)); | ||
return result; | ||
} | ||
|
||
HRESULT DirectXTK::DDSTextureHelper::CreateDDSTextureFromFile(Silk::NET::Direct3D11::ID3D11Device* device, String^ filePath, UINT maxSize, Silk::NET::Direct3D11::Usage usage, UINT bindFlags, UINT cpuAccessFlags, Silk::NET::Direct3D11::ResourceMiscFlag miscFlags, DDSLoaderFlag loadFlags, Silk::NET::Direct3D11::ID3D11Resource** texture, Silk::NET::Direct3D11::ID3D11ShaderResourceView** textureView, DDSAlphaMode alphaMode) | ||
{ | ||
auto chars = (wchar_t*)Marshal::StringToHGlobalUni(filePath).ToPointer(); | ||
auto nativeAlphaMode = static_cast<DirectX::DDS_ALPHA_MODE>(alphaMode); | ||
auto nativeLoadFlags = static_cast<DirectX::DDS_LOADER_FLAGS>(loadFlags); | ||
|
||
HRESULT result = DirectX::CreateDDSTextureFromFileEx((ID3D11Device*)device, chars, maxSize, (D3D11_USAGE)usage, bindFlags, cpuAccessFlags, (UINT)miscFlags, nativeLoadFlags, (ID3D11Resource**)texture, (ID3D11ShaderResourceView**)textureView, &nativeAlphaMode); | ||
|
||
Marshal::FreeHGlobal(IntPtr(chars)); | ||
return result; | ||
} | ||
|
||
HRESULT DirectXTK::DDSTextureHelper::CreateDDSTextureFromFile(Silk::NET::Direct3D11::ID3D11Device* device, Silk::NET::Direct3D11::ID3D11DeviceContext* deviceContext, String^ filePath, UINT maxSize, Silk::NET::Direct3D11::Usage usage, UINT bindFlags, UINT cpuAccessFlags, Silk::NET::Direct3D11::ResourceMiscFlag miscFlags, DDSLoaderFlag loadFlags, Silk::NET::Direct3D11::ID3D11Resource** texture, Silk::NET::Direct3D11::ID3D11ShaderResourceView** textureView, DDSAlphaMode alphaMode) | ||
{ | ||
auto chars = (wchar_t*)Marshal::StringToHGlobalUni(filePath).ToPointer(); | ||
auto nativeAlphaMode = static_cast<DirectX::DDS_ALPHA_MODE>(alphaMode); | ||
auto nativeLoadFlags = static_cast<DirectX::DDS_LOADER_FLAGS>(loadFlags); | ||
|
||
HRESULT result = DirectX::CreateDDSTextureFromFileEx((ID3D11Device*)device, (ID3D11DeviceContext*)deviceContext, chars, maxSize, (D3D11_USAGE)usage, bindFlags, cpuAccessFlags, (UINT)miscFlags, nativeLoadFlags, (ID3D11Resource**)texture, (ID3D11ShaderResourceView**)textureView, &nativeAlphaMode); | ||
|
||
Marshal::FreeHGlobal(IntPtr(chars)); | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#include "DDSTextureLoader.h" | ||
|
||
using namespace System; | ||
|
||
namespace DirectXTK | ||
{ | ||
public enum class DDSAlphaMode { | ||
Unknown, | ||
Straight, | ||
Premltiplied, | ||
Opaque, | ||
Custom | ||
}; | ||
|
||
public enum class DDSLoaderFlag { | ||
Default = 0, | ||
ForceSRGB = 1, | ||
IgnoreSRGB = 2, | ||
}; | ||
|
||
public ref class DDSTextureHelper | ||
{ | ||
public: | ||
static HRESULT CreateDDSTextureFromFile( | ||
Silk::NET::Direct3D11::ID3D11Device* device, | ||
String^ filePath, | ||
Silk::NET::Direct3D11::ID3D11Resource** texture, | ||
Silk::NET::Direct3D11::ID3D11ShaderResourceView** textureView, | ||
[Runtime::InteropServices::OptionalAttribute] UINT maxsize, | ||
[Runtime::InteropServices::OptionalAttribute] DDSAlphaMode alphaMode); | ||
|
||
static HRESULT CreateDDSTextureFromFile( | ||
Silk::NET::Direct3D11::ID3D11Device* device, | ||
Silk::NET::Direct3D11::ID3D11DeviceContext* deviceContext, | ||
String^ filePath, | ||
Silk::NET::Direct3D11::ID3D11Resource** texture, | ||
Silk::NET::Direct3D11::ID3D11ShaderResourceView** textureView, | ||
[Runtime::InteropServices::OptionalAttribute] UINT maxSize, | ||
[Runtime::InteropServices::OptionalAttribute] DDSAlphaMode alphaMode); | ||
|
||
static HRESULT CreateDDSTextureFromFile( | ||
Silk::NET::Direct3D11::ID3D11Device* device, | ||
String^ filePath, | ||
UINT maxsize, | ||
Silk::NET::Direct3D11::Usage usage, | ||
UINT bindFlags, | ||
UINT cpuAccessFlags, | ||
Silk::NET::Direct3D11::ResourceMiscFlag miscFlags, | ||
DDSLoaderFlag loadFlags, | ||
Silk::NET::Direct3D11::ID3D11Resource** texture, | ||
Silk::NET::Direct3D11::ID3D11ShaderResourceView** textureView, | ||
DDSAlphaMode alphaMode); | ||
|
||
static HRESULT CreateDDSTextureFromFile( | ||
Silk::NET::Direct3D11::ID3D11Device* device, | ||
Silk::NET::Direct3D11::ID3D11DeviceContext* deviceContext, | ||
String^ filePath, | ||
UINT maxsize, | ||
Silk::NET::Direct3D11::Usage usage, | ||
UINT bindFlags, | ||
UINT cpuAccessFlags, | ||
Silk::NET::Direct3D11::ResourceMiscFlag miscFlags, | ||
DDSLoaderFlag loadFlags, | ||
Silk::NET::Direct3D11::ID3D11Resource** texture, | ||
Silk::NET::Direct3D11::ID3D11ShaderResourceView** textureView, | ||
DDSAlphaMode alphaMode); | ||
|
||
//static HRESULT CreateDDSTextureFromFileEx( | ||
// Silk::NET::Direct3D11::ID3D11Device* d3dDevice, | ||
// Silk::NET::Direct3D11::ID3D11DeviceContext* d3dContext, | ||
// System::String^ filePath, | ||
// size_t maxsize, | ||
// D3D11_USAGE usage, | ||
// unsigned int bindFlags, | ||
// unsigned int cpuAccessFlags, | ||
// unsigned int miscFlags, | ||
// DDS_LOADER_FLAGS loadFlags, | ||
// Silk::NET::Direct3D11::ID3D11Resource** texture, | ||
// Silk::NET::Direct3D11::ID3D11ShaderResourceView** textureView, | ||
// DDS_ALPHA_MODE* alphaMode = nullptr); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.