mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Added DirectXTK to GlitchyEngineHelper
This commit is contained in:
@@ -28,3 +28,6 @@
|
|||||||
[submodule "GlitchyEngine/vendor/bon"]
|
[submodule "GlitchyEngine/vendor/bon"]
|
||||||
path = GlitchyEngine/vendor/bon
|
path = GlitchyEngine/vendor/bon
|
||||||
url = https://github.com/EinScott/bon.git
|
url = https://github.com/EinScott/bon.git
|
||||||
|
[submodule "GlitchyEngineHelper/vendor/DirectXTK"]
|
||||||
|
path = GlitchyEngineHelper/vendor/DirectXTK
|
||||||
|
url = https://github.com/microsoft/DirectXTK.git
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 270 B After Width: | Height: | Size: 258 B |
@@ -1,5 +1,5 @@
|
|||||||
FileVersion = 1
|
FileVersion = 1
|
||||||
Dependencies = {GlitchLog = "*", corlib = "*", DirectX = "*", DirectXTK = "*", FreeType = "*", cgltf-beef = "*", msdfgen-beef = "*", ImGui = "*", ImGuiImplDX11 = "*", ImGuiImplWin32 = "*", ImGuizmo = "*", Beefy2D = "*", LodePng = "*", GlitchyEngineHelper = "*", bon = "*"}
|
Dependencies = {GlitchLog = "*", corlib = "*", DirectX = "*", FreeType = "*", cgltf-beef = "*", msdfgen-beef = "*", ImGui = "*", ImGuiImplDX11 = "*", ImGuiImplWin32 = "*", ImGuizmo = "*", Beefy2D = "*", LodePng = "*", GlitchyEngineHelper = "*", bon = "*"}
|
||||||
|
|
||||||
[Project]
|
[Project]
|
||||||
Name = "GlitchyEngine"
|
Name = "GlitchyEngine"
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
#if GE_GRAPHICS_DX11
|
#if GE_GRAPHICS_DX11
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using DirectX.D3D11;
|
using DirectX.D3D11;
|
||||||
using DirectX.Common;
|
using DirectX.Common;
|
||||||
using DirectXTK;
|
using DirectXTK;
|
||||||
using GlitchyEngine.Math;
|
using GlitchyEngine.Math;
|
||||||
|
using GlitchyEngine.Platform.DX11;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
|
||||||
using internal GlitchyEngine.Renderer;
|
using internal GlitchyEngine.Renderer;
|
||||||
|
|
||||||
typealias NativeTex2DDesc = DirectX.D3D11.Texture2DDescription;
|
|
||||||
|
|
||||||
using GlitchyEngine.Platform.DX11;
|
|
||||||
using internal GlitchyEngine.Platform.DX11;
|
using internal GlitchyEngine.Platform.DX11;
|
||||||
|
|
||||||
namespace GlitchyEngine.Renderer
|
namespace GlitchyEngine.Renderer
|
||||||
{
|
{
|
||||||
|
internal typealias NativeTex2DDesc = DirectX.D3D11.Texture2DDescription;
|
||||||
|
|
||||||
extension Texture
|
extension Texture
|
||||||
{
|
{
|
||||||
protected internal ID3D11ShaderResourceView* nativeResourceView ~ _?.Release();
|
protected internal ID3D11ShaderResourceView* nativeResourceView ~ _?.Release();
|
||||||
@@ -25,19 +25,28 @@ namespace GlitchyEngine.Renderer
|
|||||||
* @param texture The reference to the pointer that will hold the texture.
|
* @param texture The reference to the pointer that will hold the texture.
|
||||||
* @returns true if the texture was loaded successfully; false otherwise.
|
* @returns true if the texture was loaded successfully; false otherwise.
|
||||||
*/
|
*/
|
||||||
protected bool LoadResourcePlatform<T>(StringView path, ref T* texture) where T : ID3D11Resource
|
protected bool LoadDdsResourcePlatform<T>(Stream stream, ref T* texture) where T : ID3D11Resource
|
||||||
{
|
{
|
||||||
Debug.Profiler.ProfileResourceFunction!();
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
|
uint8[] ddsData = new:ScopedAlloc! uint8[stream.Length];
|
||||||
|
|
||||||
|
var result = stream.TryRead(ddsData);
|
||||||
|
|
||||||
|
if (result case .Err(let err))
|
||||||
|
{
|
||||||
|
Log.EngineLogger.Error($"Failed to read texture data from stream. Error: {err}");
|
||||||
|
}
|
||||||
|
|
||||||
((ID3D11Resource*)texture)?.Release();
|
((ID3D11Resource*)texture)?.Release();
|
||||||
nativeResourceView?.Release();
|
nativeResourceView?.Release();
|
||||||
|
|
||||||
HResult loadResult = DDSTextureLoader.CreateDDSTextureFromFile(NativeDevice, path.ToScopedNativeWChar!(),
|
HResult loadResult = DDSTextureLoader.CreateDDSTextureFromMemory(NativeDevice,
|
||||||
(.)&texture, &nativeResourceView);
|
ddsData.Ptr, (uint)ddsData.Count, (.)&texture, &nativeResourceView);
|
||||||
|
|
||||||
if(loadResult.Failed)
|
if(loadResult.Failed)
|
||||||
{
|
{
|
||||||
Log.EngineLogger.Error($"Failed to load texture \"{path}\". Error({(int)loadResult}): {loadResult}");
|
Log.EngineLogger.Error($"Failed to load texture. Error({(int)loadResult}): {loadResult}");
|
||||||
|
|
||||||
ReleaseAndNullify!(texture);
|
ReleaseAndNullify!(texture);
|
||||||
ReleaseAndNullify!(nativeResourceView);
|
ReleaseAndNullify!(nativeResourceView);
|
||||||
@@ -85,11 +94,11 @@ namespace GlitchyEngine.Renderer
|
|||||||
public override uint32 ArraySize => nativeDesc.ArraySize;
|
public override uint32 ArraySize => nativeDesc.ArraySize;
|
||||||
public override uint32 MipLevels => nativeDesc.MipLevels;
|
public override uint32 MipLevels => nativeDesc.MipLevels;
|
||||||
|
|
||||||
protected override void LoadTexturePlatform()
|
protected override void LoadDdsPlatform(Stream stream)
|
||||||
{
|
{
|
||||||
Debug.Profiler.ProfileResourceFunction!();
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
LoadResourcePlatform(_path, ref nativeTexture);
|
LoadDdsResourcePlatform(stream, ref nativeTexture);
|
||||||
|
|
||||||
let resType = nativeTexture.GetResourceType();
|
let resType = nativeTexture.GetResourceType();
|
||||||
Log.EngineLogger.Assert(resType == .Texture2D, scope $"The texture \"{_path}\" is not a 2D texture (it is {resType}).");
|
Log.EngineLogger.Assert(resType == .Texture2D, scope $"The texture \"{_path}\" is not a 2D texture (it is {resType}).");
|
||||||
@@ -259,11 +268,11 @@ namespace GlitchyEngine.Renderer
|
|||||||
public override uint32 ArraySize => nativeDesc.ArraySize / 6;
|
public override uint32 ArraySize => nativeDesc.ArraySize / 6;
|
||||||
public override uint32 MipLevels => nativeDesc.MipLevels;
|
public override uint32 MipLevels => nativeDesc.MipLevels;
|
||||||
|
|
||||||
protected override void LoadTexturePlatform()
|
protected override void LoadTexturePlatform(Stream stream)
|
||||||
{
|
{
|
||||||
Debug.Profiler.ProfileResourceFunction!();
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
LoadResourcePlatform(_path, ref nativeTexture);
|
LoadDdsResourcePlatform(stream, ref nativeTexture);
|
||||||
|
|
||||||
let resType = nativeTexture.GetResourceType();
|
let resType = nativeTexture.GetResourceType();
|
||||||
Log.EngineLogger.Assert(resType == .Texture2D, scope $"The texture \"{_path}\" is not a texture cube (it is {resType}).");
|
Log.EngineLogger.Assert(resType == .Texture2D, scope $"The texture \"{_path}\" is not a texture cube (it is {resType}).");
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
}
|
}
|
||||||
else if (strView.StartsWith(DdsMagicWord))
|
else if (strView.StartsWith(DdsMagicWord))
|
||||||
{
|
{
|
||||||
LoadTexturePlatform();
|
LoadDds(data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -137,6 +137,11 @@ namespace GlitchyEngine.Renderer
|
|||||||
LodePng.LodePng.Free(rawData);
|
LodePng.LodePng.Free(rawData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void LoadDds(Stream stream)
|
||||||
|
{
|
||||||
|
LoadDdsPlatform(stream);
|
||||||
|
}
|
||||||
|
|
||||||
public this(Texture2DDesc desc)
|
public this(Texture2DDesc desc)
|
||||||
{
|
{
|
||||||
PrepareTexturePlatform(desc, false);
|
PrepareTexturePlatform(desc, false);
|
||||||
@@ -157,7 +162,7 @@ namespace GlitchyEngine.Renderer
|
|||||||
uint32 mipLevels = 1, uint32 arraySize = 1, Usage usage = .Default, CPUAccessFlags cpuAccess = .None
|
uint32 mipLevels = 1, uint32 arraySize = 1, Usage usage = .Default, CPUAccessFlags cpuAccess = .None
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected extern void LoadTexturePlatform();
|
protected extern void LoadDdsPlatform(Stream stream);
|
||||||
|
|
||||||
protected extern void CreateTexturePlatform(Texture2DDesc desc, bool isRenderTarget, void* data, uint32 linePitch);
|
protected extern void CreateTexturePlatform(Texture2DDesc desc, bool isRenderTarget, void* data, uint32 linePitch);
|
||||||
|
|
||||||
@@ -195,9 +200,19 @@ namespace GlitchyEngine.Renderer
|
|||||||
public this(String path)
|
public this(String path)
|
||||||
{
|
{
|
||||||
this._path = new String(path);
|
this._path = new String(path);
|
||||||
LoadTexturePlatform();
|
LoadTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadTexture()
|
||||||
|
{
|
||||||
|
Debug.Profiler.ProfileResourceFunction!();
|
||||||
|
|
||||||
|
Stream data = Application.Get().ContentManager.GetFile(_path);
|
||||||
|
defer delete data;
|
||||||
|
|
||||||
|
LoadTexturePlatform(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected extern void LoadTexturePlatform();
|
protected extern void LoadTexturePlatform(Stream stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace GlitchyEngine.World
|
|||||||
|
|
||||||
Entity entity2 = CreateEntity("Red Square");
|
Entity entity2 = CreateEntity("Red Square");
|
||||||
var v = entity2.AddComponent<SpriterRendererComponent>(.(ColorRGBA(0.95f, 0.1f, 0.3f)));
|
var v = entity2.AddComponent<SpriterRendererComponent>(.(ColorRGBA(0.95f, 0.1f, 0.3f)));
|
||||||
v.Sprite = new Texture2D("Textures/rocket.png");
|
v.Sprite = new Texture2D("Textures/rocket.dds");
|
||||||
v.Sprite.SamplerState = SamplerStateManager.PointClamp;
|
v.Sprite.SamplerState = SamplerStateManager.PointClamp;
|
||||||
|
|
||||||
_onComponentAddedHandlers.Add(typeof(CameraComponent), (e, t, c) => {
|
_onComponentAddedHandlers.Add(typeof(CameraComponent), (e, t, c) => {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
FileVersion = 1
|
FileVersion = 1
|
||||||
Dependencies = {corlib = "*", corlib = "*"}
|
Dependencies = {corlib = "*", corlib = "*", DirectX = "*"}
|
||||||
|
|
||||||
[Project]
|
[Project]
|
||||||
Name = "GlitchyEngineHelper"
|
Name = "GlitchyEngineHelper"
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ cmake_minimum_required (VERSION 3.15)
|
|||||||
project ("GlitchyEngineHelper")
|
project ("GlitchyEngineHelper")
|
||||||
|
|
||||||
# Add source to this project's executable.
|
# Add source to this project's executable.
|
||||||
add_library (GlitchyEngineHelper "GlitchyEngineHelper.cpp" "GlitchyEngineHelper.h" "vendor/xxHash/xxhash.c" "vendor/xxHash/xxhash.h")
|
add_library (GlitchyEngineHelper "GlitchyEngineHelper.cpp" "GlitchyEngineHelper.h" "vendor/xxHash/xxhash.c" "vendor/xxHash/xxhash.h" "vendor/DirectXTK/Src/DDSTextureLoader.cpp")
|
||||||
|
|
||||||
|
include_directories("vendor/DirectXTK/Inc")
|
||||||
|
|
||||||
# Use statically linked multithreaded MSVC runtime
|
# Use statically linked multithreaded MSVC runtime
|
||||||
set_property(TARGET GlitchyEngineHelper PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDebug")
|
set_property(TARGET GlitchyEngineHelper PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDebug")
|
||||||
|
|||||||
@@ -14,3 +14,143 @@ GE_EXPORT XXH64_hash_t bla(void* buffer, size_t size, XXH64_hash_t seed)
|
|||||||
{
|
{
|
||||||
return XXH64(buffer, size, seed);
|
return XXH64(buffer, size, seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Standard version
|
||||||
|
GE_EXPORT HRESULT GE_CALLTYPE DirectXTK_CreateDDSTextureFromMemory(
|
||||||
|
_In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||||
|
_In_ size_t ddsDataSize,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_Out_opt_ DirectX::DDS_ALPHA_MODE* alphaMode) noexcept
|
||||||
|
{
|
||||||
|
return DirectX::CreateDDSTextureFromMemory(d3dDevice, ddsData, ddsDataSize, texture, textureView, maxsize, alphaMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
GE_EXPORT HRESULT GE_CALLTYPE DirectXTK_CreateDDSTextureFromFile(
|
||||||
|
_In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_z_ const wchar_t* szFileName,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_Out_opt_ DirectX::DDS_ALPHA_MODE* alphaMode) noexcept
|
||||||
|
{
|
||||||
|
return DirectX::CreateDDSTextureFromFile(d3dDevice, szFileName, texture, textureView, maxsize, alphaMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Standard version with optional auto-gen mipmap support
|
||||||
|
GE_EXPORT HRESULT GE_CALLTYPE DirectXTK_CreateDDSTextureFromMemoryMip(
|
||||||
|
#if defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
|
_In_ ID3D11DeviceX* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContextX* d3dContext,
|
||||||
|
#else
|
||||||
|
_In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||||
|
#endif
|
||||||
|
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||||
|
_In_ size_t ddsDataSize,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_Out_opt_ DirectX::DDS_ALPHA_MODE* alphaMode) noexcept
|
||||||
|
{
|
||||||
|
return DirectX::CreateDDSTextureFromMemory(d3dDevice, d3dContext, ddsData, ddsDataSize, texture, textureView, maxsize, alphaMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
GE_EXPORT HRESULT GE_CALLTYPE DirectXTK_CreateDDSTextureFromFileMip(
|
||||||
|
#if defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
|
_In_ ID3D11DeviceX* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContextX* d3dContext,
|
||||||
|
#else
|
||||||
|
_In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||||
|
#endif
|
||||||
|
_In_z_ const wchar_t* szFileName,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_Out_opt_ DirectX::DDS_ALPHA_MODE* alphaMode) noexcept
|
||||||
|
{
|
||||||
|
return DirectX::CreateDDSTextureFromFile(d3dDevice, d3dContext, szFileName, texture, textureView, maxsize, alphaMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extended version
|
||||||
|
HRESULT __cdecl DirectXTK_CreateDDSTextureFromMemoryEx(
|
||||||
|
_In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||||
|
_In_ size_t ddsDataSize,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_In_ D3D11_USAGE usage,
|
||||||
|
_In_ unsigned int bindFlags,
|
||||||
|
_In_ unsigned int cpuAccessFlags,
|
||||||
|
_In_ unsigned int miscFlags,
|
||||||
|
_In_ bool forceSRGB,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_Out_opt_ DirectX::DDS_ALPHA_MODE* alphaMode) noexcept
|
||||||
|
{
|
||||||
|
return DirectX::CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, maxsize, usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, texture, textureView, alphaMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT __cdecl DirectXTK_CreateDDSTextureFromFileEx(
|
||||||
|
_In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_z_ const wchar_t* szFileName,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_In_ D3D11_USAGE usage,
|
||||||
|
_In_ unsigned int bindFlags,
|
||||||
|
_In_ unsigned int cpuAccessFlags,
|
||||||
|
_In_ unsigned int miscFlags,
|
||||||
|
_In_ bool forceSRGB,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_Out_opt_ DirectX::DDS_ALPHA_MODE* alphaMode) noexcept
|
||||||
|
{
|
||||||
|
return DirectX::CreateDDSTextureFromFileEx(d3dDevice, szFileName, maxsize, usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, texture, textureView, alphaMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extended version with optional auto-gen mipmap support
|
||||||
|
HRESULT __cdecl DirectXTK_CreateDDSTextureFromMemoryExMip(
|
||||||
|
#if defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
|
_In_ ID3D11DeviceX* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContextX* d3dContext,
|
||||||
|
#else
|
||||||
|
_In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||||
|
#endif
|
||||||
|
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||||
|
_In_ size_t ddsDataSize,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_In_ D3D11_USAGE usage,
|
||||||
|
_In_ unsigned int bindFlags,
|
||||||
|
_In_ unsigned int cpuAccessFlags,
|
||||||
|
_In_ unsigned int miscFlags,
|
||||||
|
_In_ bool forceSRGB,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_Out_opt_ DirectX::DDS_ALPHA_MODE* alphaMode) noexcept
|
||||||
|
{
|
||||||
|
return DirectX::CreateDDSTextureFromMemoryEx(d3dDevice, d3dContext, ddsData, ddsDataSize, maxsize, usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, texture, textureView, alphaMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT __cdecl DirectXTK_CreateDDSTextureFromFileExMip(
|
||||||
|
#if defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
|
_In_ ID3D11DeviceX* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContextX* d3dContext,
|
||||||
|
#else
|
||||||
|
_In_ ID3D11Device* d3dDevice,
|
||||||
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||||
|
#endif
|
||||||
|
_In_z_ const wchar_t* szFileName,
|
||||||
|
_In_ size_t maxsize,
|
||||||
|
_In_ D3D11_USAGE usage,
|
||||||
|
_In_ unsigned int bindFlags,
|
||||||
|
_In_ unsigned int cpuAccessFlags,
|
||||||
|
_In_ unsigned int miscFlags,
|
||||||
|
_In_ bool forceSRGB,
|
||||||
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||||
|
_Out_opt_ DirectX::DDS_ALPHA_MODE* alphaMode) noexcept
|
||||||
|
{
|
||||||
|
return DirectX::CreateDDSTextureFromFileEx(d3dDevice, d3dContext, szFileName, maxsize, usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, texture, textureView, alphaMode);
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define GE_EXPORT extern "C" __declspec(dllexport)
|
#define GE_EXPORT extern "C" __declspec(dllexport)
|
||||||
#define GE_CALLTYPE __stdcall
|
#define GE_CALLTYPE __cdecl
|
||||||
|
|
||||||
#include "vendor/xxHash/xxhash.h"
|
#include "vendor/xxHash/xxhash.h"
|
||||||
|
#include "vendor/DirectXTK/Inc/DDSTextureLoader.h"
|
||||||
// TODO: Reference additional headers your program requires here.
|
|
||||||
|
|||||||
@@ -0,0 +1,123 @@
|
|||||||
|
using DirectX.Common;
|
||||||
|
using DirectX.D3D11;
|
||||||
|
using System;
|
||||||
|
using System.Interop;
|
||||||
|
|
||||||
|
namespace DirectXTK
|
||||||
|
{
|
||||||
|
enum DdsAlphaMode : uint32
|
||||||
|
{
|
||||||
|
Unknown = 0,
|
||||||
|
Straight = 1,
|
||||||
|
Premultiplied = 2,
|
||||||
|
Opaque = 3,
|
||||||
|
Custom = 4,
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DDSTextureLoader
|
||||||
|
{
|
||||||
|
// Standard version
|
||||||
|
[LinkName("DirectXTK_CreateDDSTextureFromMemory"), CallingConvention(.Cdecl)]
|
||||||
|
public static extern HResult CreateDDSTextureFromMemory(
|
||||||
|
ID3D11Device* d3dDevice,
|
||||||
|
uint8* ddsData,
|
||||||
|
c_size ddsDataSize,
|
||||||
|
ID3D11Resource** texture,
|
||||||
|
ID3D11ShaderResourceView** textureView,
|
||||||
|
c_size maxsize = 0,
|
||||||
|
DdsAlphaMode* alphaMode = null);
|
||||||
|
|
||||||
|
[LinkName("DirectXTK_CreateDDSTextureFromFile"), CallingConvention(.Cdecl)]
|
||||||
|
public static extern HResult CreateDDSTextureFromFile(
|
||||||
|
ID3D11Device* d3dDevice,
|
||||||
|
c_wchar* szFileName,
|
||||||
|
ID3D11Resource** texture,
|
||||||
|
ID3D11ShaderResourceView** textureView,
|
||||||
|
c_size maxsize = 0,
|
||||||
|
DdsAlphaMode* alphaMode = null);
|
||||||
|
|
||||||
|
// Standard version with optional auto-gen mipmap support
|
||||||
|
[LinkName("DirectXTK_CreateDDSTextureFromMemoryMip"), CallingConvention(.Cdecl)]
|
||||||
|
public static extern HResult CreateDDSTextureFromMemory(
|
||||||
|
ID3D11Device* d3dDevice,
|
||||||
|
ID3D11DeviceContext* d3dContext,
|
||||||
|
uint8* ddsData,
|
||||||
|
c_size ddsDataSize,
|
||||||
|
ID3D11Resource** texture,
|
||||||
|
ID3D11ShaderResourceView** textureView,
|
||||||
|
c_size maxsize = 0,
|
||||||
|
DdsAlphaMode* alphaMode = null);
|
||||||
|
|
||||||
|
[LinkName("DirectXTK_CreateDDSTextureFromFileMip"), CallingConvention(.Cdecl)]
|
||||||
|
public static extern HResult CreateDDSTextureFromFile(
|
||||||
|
ID3D11Device* d3dDevice,
|
||||||
|
ID3D11DeviceContext* d3dContext,
|
||||||
|
c_wchar* szFileName,
|
||||||
|
ID3D11Resource** texture,
|
||||||
|
ID3D11ShaderResourceView** textureView,
|
||||||
|
c_size maxsize = 0,
|
||||||
|
DdsAlphaMode* alphaMode = null);
|
||||||
|
|
||||||
|
// Extended version
|
||||||
|
[LinkName("DirectXTK_CreateDDSTextureFromMemoryEx"), CallingConvention(.Cdecl)]
|
||||||
|
public static extern HResult CreateDDSTextureFromMemoryEx(
|
||||||
|
ID3D11Device* d3dDevice,
|
||||||
|
uint8* ddsData,
|
||||||
|
c_size ddsDataSize,
|
||||||
|
c_size maxsize,
|
||||||
|
Usage usage,
|
||||||
|
BindFlags bindFlags,
|
||||||
|
CpuAccessFlags cpuAccessFlags,
|
||||||
|
ResourceMiscFlags miscFlags,
|
||||||
|
bool forceSRGB,
|
||||||
|
ID3D11Resource** texture,
|
||||||
|
ID3D11ShaderResourceView** textureView,
|
||||||
|
DdsAlphaMode* alphaMode = null);
|
||||||
|
|
||||||
|
[LinkName("DirectXTK_CreateDDSTextureFromFileEx"), CallingConvention(.Cdecl)]
|
||||||
|
public static extern HResult CreateDDSTextureFromFileEx(
|
||||||
|
ID3D11Device* d3dDevice,
|
||||||
|
c_wchar* szFileName,
|
||||||
|
c_size maxsize,
|
||||||
|
Usage usage,
|
||||||
|
BindFlags bindFlags,
|
||||||
|
CpuAccessFlags cpuAccessFlags,
|
||||||
|
ResourceMiscFlags miscFlags,
|
||||||
|
bool forceSRGB,
|
||||||
|
ID3D11Resource** texture,
|
||||||
|
ID3D11ShaderResourceView** textureView,
|
||||||
|
DdsAlphaMode* alphaMode = null);
|
||||||
|
|
||||||
|
// Extended version with optional auto-gen mipmap support
|
||||||
|
[LinkName("DirectXTK_CreateDDSTextureFromMemoryExMip"), CallingConvention(.Cdecl)]
|
||||||
|
public static extern HResult CreateDDSTextureFromMemoryEx(
|
||||||
|
ID3D11Device* d3dDevice,
|
||||||
|
ID3D11DeviceContext* d3dContext,
|
||||||
|
uint8* ddsData,
|
||||||
|
c_size ddsDataSize,
|
||||||
|
c_size maxsize,
|
||||||
|
Usage usage,
|
||||||
|
BindFlags bindFlags,
|
||||||
|
CpuAccessFlags cpuAccessFlags,
|
||||||
|
ResourceMiscFlags miscFlags,
|
||||||
|
bool forceSRGB,
|
||||||
|
ID3D11Resource** texture,
|
||||||
|
ID3D11ShaderResourceView** textureView,
|
||||||
|
DdsAlphaMode* alphaMode = null);
|
||||||
|
|
||||||
|
[LinkName("DirectXTK_CreateDDSTextureFromFileExMip"), CallingConvention(.Cdecl)]
|
||||||
|
public static extern HResult CreateDDSTextureFromFileEx(
|
||||||
|
ID3D11Device* d3dDevice,
|
||||||
|
ID3D11DeviceContext* d3dContext,
|
||||||
|
c_wchar* szFileName,
|
||||||
|
c_size maxsize,
|
||||||
|
Usage usage,
|
||||||
|
BindFlags bindFlags,
|
||||||
|
CpuAccessFlags cpuAccessFlags,
|
||||||
|
ResourceMiscFlags miscFlags,
|
||||||
|
bool forceSRGB,
|
||||||
|
ID3D11Resource** texture,
|
||||||
|
ID3D11ShaderResourceView** textureView,
|
||||||
|
DdsAlphaMode* alphaMode = null);
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
Submodule GlitchyEngineHelper/vendor/DirectXTK added at 21980527c8
Reference in New Issue
Block a user