Renamed FontAtlas to Fonts. Further cleanup/comments.

This commit is contained in:
ocornut
2015-01-18 10:46:49 +00:00
parent 1f8d209202
commit 1916a0c78c
6 changed files with 103 additions and 111 deletions

View File

@ -321,7 +321,7 @@ void CleanupDevice()
// InitImGui
if (g_pFontSampler) g_pFontSampler->Release();
if (ID3D11ShaderResourceView* font_texture_view = (ID3D11ShaderResourceView*)ImGui::GetIO().FontAtlas->TexID)
if (ID3D11ShaderResourceView* font_texture_view = (ID3D11ShaderResourceView*)ImGui::GetIO().Fonts->TexID)
font_texture_view->Release();
if (g_pVB) g_pVB->Release();
@ -377,17 +377,17 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
return DefWindowProc(hWnd, msg, wParam, lParam);
}
void LoadFontTexture()
void LoadFontsTexture()
{
// Load one or more font
ImGuiIO& io = ImGui::GetIO();
//ImFont* my_font = io.FontAtlas->AddFontDefault();
//ImFont* my_font2 = io.FontAtlas->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 20.0f, ImFontAtlas::GetGlyphRangesJapanese());
//ImFont* my_font = io.Fonts->AddFontDefault();
//ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 20.0f, io.Fonts->GetGlyphRangesJapanese());
// Build
unsigned char* pixels;
int width, height;
io.FontAtlas->GetTexDataAsRGBA32(&pixels, &width, &height);
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
// Create texture
D3D11_TEXTURE2D_DESC desc;
@ -421,7 +421,7 @@ void LoadFontTexture()
pTexture->Release();
// Store our identifier
io.FontAtlas->TexID = (void *)font_texture_view;
io.Fonts->TexID = (void *)font_texture_view;
}
void InitImGui()
@ -470,7 +470,7 @@ void InitImGui()
}
// Load fonts
LoadFontTexture();
LoadFontsTexture();
// Create texture sampler
{

View File

@ -129,7 +129,7 @@ void CleanupDevice()
if (g_pVB) g_pVB->Release();
// InitDeviceD3D
if (LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)ImGui::GetIO().FontAtlas->TexID)
if (LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)ImGui::GetIO().Fonts->TexID)
tex->Release();
if (g_pd3dDevice) g_pd3dDevice->Release();
if (g_pD3D) g_pD3D->Release();
@ -173,17 +173,17 @@ LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
return DefWindowProc(hWnd, msg, wParam, lParam);
}
void LoadFontTexture()
void LoadFontsTexture()
{
// Load one or more font
ImGuiIO& io = ImGui::GetIO();
//ImFont* my_font = io.FontAtlas->AddFontDefault();
//ImFont* my_font2 = io.FontAtlas->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 20.0f, ImFontAtlas::GetGlyphRangesJapanese());
//ImFont* my_font = io.Fonts->AddFontDefault();
//ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 20.0f, io.Fonts->GetGlyphRangesJapanese());
// Build
unsigned char* pixels;
int width, height, bytes_per_pixel;
io.FontAtlas->GetTexDataAsAlpha8(&pixels, &width, &height, &bytes_per_pixel);
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height, &bytes_per_pixel);
// Create texture
LPDIRECT3DTEXTURE9 pTexture = NULL;
@ -205,7 +205,7 @@ void LoadFontTexture()
pTexture->UnlockRect(0);
// Store our identifier
io.FontAtlas->TexID = (void *)pTexture;
io.Fonts->TexID = (void *)pTexture;
}
void InitImGui()
@ -245,7 +245,7 @@ void InitImGui()
return;
}
LoadFontTexture();
LoadFontsTexture();
}
INT64 ticks_per_second = 0;

View File

@ -235,15 +235,15 @@ void InitGL()
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void LoadFontTexture()
void LoadFontsTexture()
{
ImGuiIO& io = ImGui::GetIO();
//ImFont* my_font = io.FontAtlas->AddFontDefault();
//ImFont* my_font2 = io.FontAtlas->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 20.0f, ImFontAtlas::GetGlyphRangesJapanese());
//ImFont* my_font = io.Fonts->AddFontDefault();
//ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 20.0f, io.Fonts->GetGlyphRangesJapanese());
unsigned char* pixels;
int width, height;
io.FontAtlas->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits for OpenGL3 demo because it is more likely to be compatible with user's existing shader.
GLuint tex_id;
glGenTextures(1, &tex_id);
@ -253,7 +253,7 @@ void LoadFontTexture()
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
// Store our identifier
io.FontAtlas->TexID = (void *)(intptr_t)tex_id;
io.Fonts->TexID = (void *)(intptr_t)tex_id;
}
void InitImGui()
@ -282,7 +282,7 @@ void InitImGui()
io.SetClipboardTextFn = ImImpl_SetClipboardTextFn;
io.GetClipboardTextFn = ImImpl_GetClipboardTextFn;
LoadFontTexture();
LoadFontsTexture();
}
void UpdateImGui()

View File

@ -145,15 +145,15 @@ void InitGL()
glewInit();
}
void LoadFontTexture()
void LoadFontsTexture()
{
ImGuiIO& io = ImGui::GetIO();
//ImFont* my_font = io.FontAtlas->AddFontDefault();
//ImFont* my_font2 = io.FontAtlas->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 20.0f, ImFontAtlas::GetGlyphRangesJapanese());
//ImFont* my_font = io.Fonts->AddFontDefault();
//ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 20.0f, io.Fonts->GetGlyphRangesJapanese());
unsigned char* pixels;
int width, height;
io.FontAtlas->GetTexDataAsAlpha8(&pixels, &width, &height);
io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height);
GLuint tex_id;
glGenTextures(1, &tex_id);
@ -163,7 +163,7 @@ void LoadFontTexture()
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pixels);
// Store our identifier
io.FontAtlas->TexID = (void *)(intptr_t)tex_id;
io.Fonts->TexID = (void *)(intptr_t)tex_id;
}
void InitImGui()
@ -191,6 +191,8 @@ void InitImGui()
io.RenderDrawListsFn = ImImpl_RenderDrawLists;
io.SetClipboardTextFn = ImImpl_SetClipboardTextFn;
io.GetClipboardTextFn = ImImpl_GetClipboardTextFn;
LoadFontsTexture();
}
void UpdateImGui()