Вопрос ImGui drawing wrong color!

Начинающий
Статус
Оффлайн
Регистрация
16 Авг 2022
Сообщения
31
Реакции[?]
3
Поинты[?]
3K
I'm using imgui for my internal cheat.

C++:
    D3D_FEATURE_LEVEL FeatureLevel;
    const D3D_FEATURE_LEVEL FeatureLevels[] = { D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_11_0 };

    DXGI_RATIONAL RefreshRate;
    RefreshRate.Numerator = 60;
    RefreshRate.Denominator = 1;

    DXGI_MODE_DESC BufferDesc;
    BufferDesc.Width = 100;
    BufferDesc.Height = 100;
    BufferDesc.RefreshRate = RefreshRate;
    BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
    BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;

    DXGI_SAMPLE_DESC SampleDesc;
    SampleDesc.Count = 1;
    SampleDesc.Quality = 0;

    DXGI_SWAP_CHAIN_DESC SwapChainDesc;
    SwapChainDesc.BufferDesc = BufferDesc;
    SwapChainDesc.SampleDesc = SampleDesc;
    SwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    SwapChainDesc.BufferCount = 1;
    SwapChainDesc.OutputWindow = WindowHwnd;
    SwapChainDesc.Windowed = 1;
    SwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
    SwapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;

    IDXGISwapChain* SwapChain;
    ID3D11Device* Device;
    ID3D11DeviceContext*Context;
    if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, FeatureLevels, 1, D3D11_SDK_VERSION, &SwapChainDesc, &SwapChain, &Device, &FeatureLevel, &Context) < 0)
    {
        DeleteWindow();
        return FALSE;
    }
C++:
        ImGui_ImplDX11_NewFrame();
        ImGui_ImplWin32_NewFrame();
        ImGui::NewFrame();
        ImGui::GetIO().MouseDrawCursor = g_GameVariables->m_ShowMenu;

        ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(px - 10, py + 65), ImVec2(px + 65, py + 450), ImColor(19, 20, 22);


        ImGui::EndFrame();

        ImGui::Render();
        m_DeviceContext->OMSetRenderTargets(1, &m_RenderTargetView, NULL);

        ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());

My problem is, it's rendering RGB( 77 79 83 ) instead of RGB( 19 20 22 ).
Any idea why?
 
Последнее редактирование:
Начинающий
Статус
Оффлайн
Регистрация
16 Авг 2022
Сообщения
31
Реакции[?]
3
Поинты[?]
3K
Okay, I found out that it is because Dota 2 uses BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;


fix:
On Init:
C++:
            m_DeviceContext->OMGetRenderTargets(1, &cached_render, nullptr);

            D3D11_RENDER_TARGET_VIEW_DESC desc = {};
            memset(&desc, 0, sizeof(desc));
            desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
            desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;

            ID3D11Texture2D* BackBuffer;
            swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&BackBuffer);
            m_Device->CreateRenderTargetView(BackBuffer, &desc, &m_RenderTargetView);
            BackBuffer->Release();

            ImGui_ImplWin32_Init(g_GameVariables->g_GameWindow);
            ImGui_ImplDX11_Init(m_Device, m_DeviceContext);

After drawing:

C++:
 m_DeviceContext->OMSetRenderTargets(1, &cached_render, nullptr);
 
Последнее редактирование:
Ревёрсер среднего звена
Пользователь
Статус
Оффлайн
Регистрация
24 Ноя 2022
Сообщения
303
Реакции[?]
108
Поинты[?]
57K
And I just converted all my colors by raising their float representations to the power of 2.2
 
Сверху Снизу