Skip to content

Latest commit

 

History

History
47 lines (43 loc) · 3.2 KB

README.md

File metadata and controls

47 lines (43 loc) · 3.2 KB

Custom Renderer

This projects simply explains how to setup and use DirectX 11 with ImGui.
It's mosty aimed for new people with no prior experience with ImGui + D3D11 combo.

How setup the Project

So, to start you will need to:

  • Download all the necessary dependencies which are: DirectX SDK, ImGui (only if you feel like you ned the lastes version),
  • Download the source code (there is no release binary becasue it would be pointless),
  • Link all the dependencies
    1. Project Settings → Linker → Input → Additional Dependencies → add d3dx11.lib;d3d11.lib;
    2. Project Settings → Linker → System → SubSystem → set to Windows (/SUBSYSTEM:WINDOWS)
    3. (Set Platform to x64) → Project Settings → Configuration Properties → VC++ Directories → Include Directories → set to $(IncludePath);$(DXSDK_DIR)Include
    4. Project Settings → Configuration Properties → VC++ Directories → Library Directories → set to $(LibraryPath);$(DXSDK_DIR)Lib\x86
  • If you have downloaded the latest version of ImGui, update the files located in ..\src\External\ImGui with the new files.

Congratulations! If you are feeling brave you might try building the code.

I probablly forgot about something and you are going to get 1000 linker errors..

Additional Info (things to keep in mind)

The shaders are there just to give you an example on how to set them up.
If you actually want to render some 2D / 3D things you will have to update the vertex buffer (probablly) every frame.

This is a beginner friendly project so here are some important tips about DX11:

  • What Vertex Shader returs generally goes to the Pixel Shader so you might see something like this:

    BasicVertexShader.hlsl
    struct VertexOutput // Pixel Shader Input
    {
        float4 position : SV_Position;
        float3 color : COLOR0;
        float2 uv : TEXCOORD0;
    };
    BasicPixelShader.hlsl
    struct PixelInput
    {
        float4 position : SV_Position;
        float3 color : COLOR0;
        float2 uv : TEXCOORD0;
    };

    Order of the elements in these structures matters!

  • With the flag D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST set, it seems that You can only draw triangles. That's why drawing a rectagle takes 6 vertices rather than 4.
  • Good sources for learning: