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.
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
- Project Settings → Linker → Input → Additional Dependencies → add
d3dx11.lib;d3d11.lib;
- Project Settings → Linker → System → SubSystem → set to
Windows (/SUBSYSTEM:WINDOWS)
- (Set Platform to x64) → Project Settings → Configuration Properties → VC++ Directories → Include Directories → set to
$(IncludePath);$(DXSDK_DIR)Include
- Project Settings → Configuration Properties → VC++ Directories → Library Directories → set to
$(LibraryPath);$(DXSDK_DIR)Lib\x86
- Project Settings → Linker → Input → Additional Dependencies → add
- 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.
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.
- What Vertex Shader returs generally goes to the Pixel Shader so you might see something like this:
BasicVertexShader.hlslBasicPixelShader.hlslstruct VertexOutput // Pixel Shader Input { float4 position : SV_Position; float3 color : COLOR0; float2 uv : TEXCOORD0; };
struct PixelInput { float4 position : SV_Position; float3 color : COLOR0; float2 uv : TEXCOORD0; };
- 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: