- Fix DX11 color issue

This commit is contained in:
EricPlayZ
2024-02-18 17:05:40 +02:00
parent 6accb5f43d
commit 3d85e480e1
3 changed files with 20 additions and 2 deletions

View File

@ -6,6 +6,7 @@ namespace impl {
namespace d3d11 {
ID3D11Device* d3d11Device = nullptr;
static ID3D11DeviceContext* d3d11DeviceContext = nullptr;
static ID3D11RenderTargetView* d3d11RenderTargetView = nullptr;
HRESULT(__stdcall* oPresent)(IDXGISwapChain*, UINT, UINT);
HRESULT __stdcall hkPresent11(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags) {
@ -18,6 +19,19 @@ namespace impl {
pSwapChain->GetDevice(__uuidof(ID3D11Device), (void**)&d3d11Device);
d3d11Device->GetImmediateContext(&d3d11DeviceContext);
ID3D11Texture2D* renderTargetTexture = nullptr;
// Create custom render target view because DX11 color space issue with ImGui bruh
if (SUCCEEDED(pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<LPVOID*>(&renderTargetTexture)))) {
D3D11_RENDER_TARGET_VIEW_DESC desc{};
memset(&desc, 0, sizeof(desc));
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
d3d11Device->CreateRenderTargetView(renderTargetTexture, &desc, &d3d11RenderTargetView);
renderTargetTexture->Release();
}
#ifndef LLMH_IMPL_DISABLE_DEBUG
std::thread([&desc]() { impl::win32::init(desc.OutputWindow); }).detach();
#else
@ -35,6 +49,8 @@ namespace impl {
init = true;
}
d3d11DeviceContext->OMSetRenderTargets(1, &d3d11RenderTargetView, nullptr);
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();

View File

@ -269,6 +269,8 @@ namespace Menu {
io.FontDefault = io.Fonts->AddFontFromMemoryTTF((void*)g_FontRudaBold, sizeof(g_FontRudaBold), 12.0f + 6.0f, &fontConfig);
io.Fonts->Build();
spdlog::warn("Loading EGameTools logo texture");
EGTLogoTexture = Utils::Texture::LoadImGuiTexture(g_EGTWhiteLogo, sizeof(g_EGTWhiteLogo));
spdlog::info("Loaded EGameTools logo");
}
}

View File

@ -19,7 +19,7 @@ namespace Utils {
namespace Texture {
static int descriptor_index = 1;
ImTextureID LoadImGuiTextureD3D11(const unsigned char* rawData, const int rawSize) {
static ImTextureID LoadImGuiTextureD3D11(const unsigned char* rawData, const int rawSize) {
int image_width = 0;
int image_height = 0;
unsigned char* image_data = stbi_load_from_memory(rawData, rawSize, &image_width, &image_height, nullptr, 4);
@ -62,7 +62,7 @@ namespace Utils {
return static_cast<ImTextureID>(my_texture);
}
ImTextureID LoadImGuiTextureD3D12(const unsigned char* rawData, const int rawSize) {
static ImTextureID LoadImGuiTextureD3D12(const unsigned char* rawData, const int rawSize) {
int image_width = 0;
int image_height = 0;
unsigned char* image_data = stbi_load_from_memory(rawData, rawSize, &image_width, &image_height, nullptr, 4);