mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-19 09:39:03 +08:00
Backends: DX10: create sampler outside of ImGui_ImplDX11_CreateFontsTexture().
Some checks failed
Some checks failed
Analoguous to 90dd510
for DX11.
This commit is contained in:
parent
43fbd7ce84
commit
18e5d769fd
@ -341,21 +341,16 @@ static void ImGui_ImplDX10_CreateFontsTexture()
|
|||||||
|
|
||||||
// Store our identifier
|
// Store our identifier
|
||||||
io.Fonts->SetTexID((ImTextureID)bd->pFontTextureView);
|
io.Fonts->SetTexID((ImTextureID)bd->pFontTextureView);
|
||||||
|
}
|
||||||
|
|
||||||
// Create texture sampler
|
static void ImGui_ImplDX10_DestroyFontsTexture()
|
||||||
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
{
|
||||||
|
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
|
||||||
|
if (bd->pFontTextureView)
|
||||||
{
|
{
|
||||||
D3D10_SAMPLER_DESC desc;
|
bd->pFontTextureView->Release();
|
||||||
ZeroMemory(&desc, sizeof(desc));
|
bd->pFontTextureView = nullptr;
|
||||||
desc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR;
|
ImGui::GetIO().Fonts->SetTexID(0); // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||||
desc.AddressU = D3D10_TEXTURE_ADDRESS_CLAMP;
|
|
||||||
desc.AddressV = D3D10_TEXTURE_ADDRESS_CLAMP;
|
|
||||||
desc.AddressW = D3D10_TEXTURE_ADDRESS_CLAMP;
|
|
||||||
desc.MipLODBias = 0.f;
|
|
||||||
desc.ComparisonFunc = D3D10_COMPARISON_ALWAYS;
|
|
||||||
desc.MinLOD = 0.f;
|
|
||||||
desc.MaxLOD = 0.f;
|
|
||||||
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pFontSampler);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -508,6 +503,22 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
|
|||||||
bd->pd3dDevice->CreateDepthStencilState(&desc, &bd->pDepthStencilState);
|
bd->pd3dDevice->CreateDepthStencilState(&desc, &bd->pDepthStencilState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create texture sampler
|
||||||
|
// (Bilinear sampling is required by default. Set 'io.Fonts->Flags |= ImFontAtlasFlags_NoBakedLines' or 'style.AntiAliasedLinesUseTex = false' to allow point/nearest sampling)
|
||||||
|
{
|
||||||
|
D3D10_SAMPLER_DESC desc;
|
||||||
|
ZeroMemory(&desc, sizeof(desc));
|
||||||
|
desc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR;
|
||||||
|
desc.AddressU = D3D10_TEXTURE_ADDRESS_CLAMP;
|
||||||
|
desc.AddressV = D3D10_TEXTURE_ADDRESS_CLAMP;
|
||||||
|
desc.AddressW = D3D10_TEXTURE_ADDRESS_CLAMP;
|
||||||
|
desc.MipLODBias = 0.f;
|
||||||
|
desc.ComparisonFunc = D3D10_COMPARISON_ALWAYS;
|
||||||
|
desc.MinLOD = 0.f;
|
||||||
|
desc.MaxLOD = 0.f;
|
||||||
|
bd->pd3dDevice->CreateSamplerState(&desc, &bd->pFontSampler);
|
||||||
|
}
|
||||||
|
|
||||||
ImGui_ImplDX10_CreateFontsTexture();
|
ImGui_ImplDX10_CreateFontsTexture();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -519,8 +530,9 @@ void ImGui_ImplDX10_InvalidateDeviceObjects()
|
|||||||
if (!bd->pd3dDevice)
|
if (!bd->pd3dDevice)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ImGui_ImplDX10_DestroyFontsTexture();
|
||||||
|
|
||||||
if (bd->pFontSampler) { bd->pFontSampler->Release(); bd->pFontSampler = nullptr; }
|
if (bd->pFontSampler) { bd->pFontSampler->Release(); bd->pFontSampler = nullptr; }
|
||||||
if (bd->pFontTextureView) { bd->pFontTextureView->Release(); bd->pFontTextureView = nullptr; ImGui::GetIO().Fonts->SetTexID(0); } // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
|
||||||
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
|
||||||
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
|
||||||
if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = nullptr; }
|
if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = nullptr; }
|
||||||
@ -582,7 +594,7 @@ void ImGui_ImplDX10_NewFrame()
|
|||||||
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
|
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
|
||||||
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplDX10_Init()?");
|
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplDX10_Init()?");
|
||||||
|
|
||||||
if (!bd->pFontSampler)
|
if (!bd->pVertexShader)
|
||||||
ImGui_ImplDX10_CreateDeviceObjects();
|
ImGui_ImplDX10_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user