mirror of
https://github.com/Drezil/imgui.git
synced 2025-04-15 15:44:00 +00:00
Examples: DirectX9: tweaks.
This commit is contained in:
parent
698c7cae85
commit
c016f6c171
@ -219,7 +219,7 @@ void ImGui_ImplDX9_Shutdown()
|
|||||||
g_hWnd = 0;
|
g_hWnd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplDX9_CreateFontsTexture()
|
static bool ImGui_ImplDX9_CreateFontsTexture()
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
@ -231,16 +231,10 @@ static void ImGui_ImplDX9_CreateFontsTexture()
|
|||||||
// Create DX9 texture
|
// Create DX9 texture
|
||||||
g_FontTexture = NULL;
|
g_FontTexture = NULL;
|
||||||
if (D3DXCreateTexture(g_pd3dDevice, width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_DEFAULT, &g_FontTexture) < 0)
|
if (D3DXCreateTexture(g_pd3dDevice, width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_DEFAULT, &g_FontTexture) < 0)
|
||||||
{
|
return false;
|
||||||
IM_ASSERT(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
D3DLOCKED_RECT tex_locked_rect;
|
D3DLOCKED_RECT tex_locked_rect;
|
||||||
if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK)
|
if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK)
|
||||||
{
|
return false;
|
||||||
IM_ASSERT(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (int y = 0; y < height; y++)
|
for (int y = 0; y < height; y++)
|
||||||
memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel));
|
memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel));
|
||||||
g_FontTexture->UnlockRect(0);
|
g_FontTexture->UnlockRect(0);
|
||||||
@ -251,14 +245,15 @@ static void ImGui_ImplDX9_CreateFontsTexture()
|
|||||||
// Cleanup (don't clear the input data if you want to append new fonts later)
|
// Cleanup (don't clear the input data if you want to append new fonts later)
|
||||||
io.Fonts->ClearInputData();
|
io.Fonts->ClearInputData();
|
||||||
io.Fonts->ClearTexData();
|
io.Fonts->ClearTexData();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplDX9_CreateDeviceObjects()
|
bool ImGui_ImplDX9_CreateDeviceObjects()
|
||||||
{
|
{
|
||||||
if (!g_pd3dDevice)
|
if (!g_pd3dDevice)
|
||||||
return false;
|
return false;
|
||||||
|
if (!ImGui_ImplDX9_CreateFontsTexture())
|
||||||
ImGui_ImplDX9_CreateFontsTexture();
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user