diff --git a/examples/directx11_example/main.cpp b/examples/directx11_example/main.cpp index 3e3a265..4f6c4b7 100644 --- a/examples/directx11_example/main.cpp +++ b/examples/directx11_example/main.cpp @@ -137,7 +137,7 @@ { const ImDrawCmd* pcmd = &cmd_list->commands[cmd_i]; const D3D11_RECT r = { (LONG)pcmd->clip_rect.x, (LONG)pcmd->clip_rect.y, (LONG)pcmd->clip_rect.z, (LONG)pcmd->clip_rect.w }; - g_pd3dDeviceImmediateContext->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->texture_id); + g_pd3dDeviceImmediateContext->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->texture_id); g_pd3dDeviceImmediateContext->RSSetScissorRects(1, &r); g_pd3dDeviceImmediateContext->Draw(pcmd->vtx_count, vtx_offset); vtx_offset += pcmd->vtx_count; @@ -323,8 +323,8 @@ // InitImGui if (g_pFontSampler) g_pFontSampler->Release(); - if (ID3D11ShaderResourceView* font_texture_view = (ID3D11ShaderResourceView*)ImGui::GetIO().Font->TexID) - font_texture_view->Release(); + if (ID3D11ShaderResourceView* font_texture_view = (ID3D11ShaderResourceView*)ImGui::GetIO().Font->TexID) + font_texture_view->Release(); if (g_pVB) g_pVB->Release(); // InitDeviceD3D @@ -381,41 +381,41 @@ void LoadFontTexture(ImFont* font) { - IM_ASSERT(font && font->IsLoaded()); + IM_ASSERT(font && font->IsLoaded()); - // Create texture - D3D11_TEXTURE2D_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.Width = font->TexWidth; - desc.Height = font->TexHeight; - desc.MipLevels = 1; - desc.ArraySize = 1; - desc.Format = DXGI_FORMAT_A8_UNORM; - desc.SampleDesc.Count = 1; - desc.Usage = D3D11_USAGE_DEFAULT; - desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; - desc.CPUAccessFlags = 0; + // Create texture + D3D11_TEXTURE2D_DESC desc; + ZeroMemory(&desc, sizeof(desc)); + desc.Width = font->TexWidth; + desc.Height = font->TexHeight; + desc.MipLevels = 1; + desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_A8_UNORM; + desc.SampleDesc.Count = 1; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + desc.CPUAccessFlags = 0; - ID3D11Texture2D *pTexture = NULL; - D3D11_SUBRESOURCE_DATA subResource; - subResource.pSysMem = font->TexPixels; - subResource.SysMemPitch = desc.Width * 1; - subResource.SysMemSlicePitch = 0; - g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture); + ID3D11Texture2D *pTexture = NULL; + D3D11_SUBRESOURCE_DATA subResource; + subResource.pSysMem = font->TexPixels; + subResource.SysMemPitch = desc.Width * 1; + subResource.SysMemSlicePitch = 0; + g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture); - // Create texture view - D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; - ZeroMemory(&srvDesc, sizeof(srvDesc)); - srvDesc.Format = DXGI_FORMAT_A8_UNORM; - srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MipLevels = desc.MipLevels; - srvDesc.Texture2D.MostDetailedMip = 0; - ID3D11ShaderResourceView* font_texture_view = NULL; - g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &font_texture_view); - pTexture->Release(); + // Create texture view + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; + ZeroMemory(&srvDesc, sizeof(srvDesc)); + srvDesc.Format = DXGI_FORMAT_A8_UNORM; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + srvDesc.Texture2D.MipLevels = desc.MipLevels; + srvDesc.Texture2D.MostDetailedMip = 0; + ID3D11ShaderResourceView* font_texture_view = NULL; + g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &font_texture_view); + pTexture->Release(); - // Store ID - font->TexID = (void *)font_texture_view; + // Store ID + font->TexID = (void *)font_texture_view; } void InitImGui() @@ -469,7 +469,7 @@ io.Font->LoadDefault(); //io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault()); //io.Font->DisplayOffset.y += 0.0f; - LoadFontTexture(io.Font); + LoadFontTexture(io.Font); // Create texture sampler { @@ -570,10 +570,10 @@ show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); - static ImFont* font2 = NULL; - if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } - ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); - //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); + static ImFont* font2 = NULL; + if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } + ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); + //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; diff --git a/examples/directx11_example/main.cpp b/examples/directx11_example/main.cpp index 3e3a265..4f6c4b7 100644 --- a/examples/directx11_example/main.cpp +++ b/examples/directx11_example/main.cpp @@ -137,7 +137,7 @@ { const ImDrawCmd* pcmd = &cmd_list->commands[cmd_i]; const D3D11_RECT r = { (LONG)pcmd->clip_rect.x, (LONG)pcmd->clip_rect.y, (LONG)pcmd->clip_rect.z, (LONG)pcmd->clip_rect.w }; - g_pd3dDeviceImmediateContext->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->texture_id); + g_pd3dDeviceImmediateContext->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->texture_id); g_pd3dDeviceImmediateContext->RSSetScissorRects(1, &r); g_pd3dDeviceImmediateContext->Draw(pcmd->vtx_count, vtx_offset); vtx_offset += pcmd->vtx_count; @@ -323,8 +323,8 @@ // InitImGui if (g_pFontSampler) g_pFontSampler->Release(); - if (ID3D11ShaderResourceView* font_texture_view = (ID3D11ShaderResourceView*)ImGui::GetIO().Font->TexID) - font_texture_view->Release(); + if (ID3D11ShaderResourceView* font_texture_view = (ID3D11ShaderResourceView*)ImGui::GetIO().Font->TexID) + font_texture_view->Release(); if (g_pVB) g_pVB->Release(); // InitDeviceD3D @@ -381,41 +381,41 @@ void LoadFontTexture(ImFont* font) { - IM_ASSERT(font && font->IsLoaded()); + IM_ASSERT(font && font->IsLoaded()); - // Create texture - D3D11_TEXTURE2D_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.Width = font->TexWidth; - desc.Height = font->TexHeight; - desc.MipLevels = 1; - desc.ArraySize = 1; - desc.Format = DXGI_FORMAT_A8_UNORM; - desc.SampleDesc.Count = 1; - desc.Usage = D3D11_USAGE_DEFAULT; - desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; - desc.CPUAccessFlags = 0; + // Create texture + D3D11_TEXTURE2D_DESC desc; + ZeroMemory(&desc, sizeof(desc)); + desc.Width = font->TexWidth; + desc.Height = font->TexHeight; + desc.MipLevels = 1; + desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_A8_UNORM; + desc.SampleDesc.Count = 1; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + desc.CPUAccessFlags = 0; - ID3D11Texture2D *pTexture = NULL; - D3D11_SUBRESOURCE_DATA subResource; - subResource.pSysMem = font->TexPixels; - subResource.SysMemPitch = desc.Width * 1; - subResource.SysMemSlicePitch = 0; - g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture); + ID3D11Texture2D *pTexture = NULL; + D3D11_SUBRESOURCE_DATA subResource; + subResource.pSysMem = font->TexPixels; + subResource.SysMemPitch = desc.Width * 1; + subResource.SysMemSlicePitch = 0; + g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture); - // Create texture view - D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; - ZeroMemory(&srvDesc, sizeof(srvDesc)); - srvDesc.Format = DXGI_FORMAT_A8_UNORM; - srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MipLevels = desc.MipLevels; - srvDesc.Texture2D.MostDetailedMip = 0; - ID3D11ShaderResourceView* font_texture_view = NULL; - g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &font_texture_view); - pTexture->Release(); + // Create texture view + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; + ZeroMemory(&srvDesc, sizeof(srvDesc)); + srvDesc.Format = DXGI_FORMAT_A8_UNORM; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + srvDesc.Texture2D.MipLevels = desc.MipLevels; + srvDesc.Texture2D.MostDetailedMip = 0; + ID3D11ShaderResourceView* font_texture_view = NULL; + g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &font_texture_view); + pTexture->Release(); - // Store ID - font->TexID = (void *)font_texture_view; + // Store ID + font->TexID = (void *)font_texture_view; } void InitImGui() @@ -469,7 +469,7 @@ io.Font->LoadDefault(); //io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault()); //io.Font->DisplayOffset.y += 0.0f; - LoadFontTexture(io.Font); + LoadFontTexture(io.Font); // Create texture sampler { @@ -570,10 +570,10 @@ show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); - static ImFont* font2 = NULL; - if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } - ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); - //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); + static ImFont* font2 = NULL; + if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } + ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); + //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; diff --git a/examples/directx9_example/main.cpp b/examples/directx9_example/main.cpp index afec7ae..d1939ad 100644 --- a/examples/directx9_example/main.cpp +++ b/examples/directx9_example/main.cpp @@ -69,11 +69,11 @@ g_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); g_pd3dDevice->SetRenderState( D3DRS_SCISSORTESTENABLE, true ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_POINT ); g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT ); @@ -95,7 +95,7 @@ { const ImDrawCmd* pcmd = &cmd_list->commands[cmd_i]; const RECT r = { (LONG)pcmd->clip_rect.x, (LONG)pcmd->clip_rect.y, (LONG)pcmd->clip_rect.z, (LONG)pcmd->clip_rect.w }; - g_pd3dDevice->SetTexture( 0, (LPDIRECT3DTEXTURE9)pcmd->texture_id ); + g_pd3dDevice->SetTexture( 0, (LPDIRECT3DTEXTURE9)pcmd->texture_id ); g_pd3dDevice->SetScissorRect(&r); g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, vtx_offset, pcmd->vtx_count/3); vtx_offset += pcmd->vtx_count; @@ -130,8 +130,8 @@ if (g_pVB) g_pVB->Release(); // InitDeviceD3D - if (LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)ImGui::GetIO().Font->TexID) - tex->Release(); + if (LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)ImGui::GetIO().Font->TexID) + tex->Release(); if (g_pd3dDevice) g_pd3dDevice->Release(); if (g_pD3D) g_pD3D->Release(); } @@ -176,27 +176,27 @@ void LoadFontTexture(ImFont* font) { - IM_ASSERT(font && font->IsLoaded()); + IM_ASSERT(font && font->IsLoaded()); - LPDIRECT3DTEXTURE9 pTexture = NULL; - if (D3DXCreateTexture(g_pd3dDevice, font->TexWidth, font->TexHeight, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_DEFAULT, &pTexture) < 0) - { - IM_ASSERT(0); - return; - } + LPDIRECT3DTEXTURE9 pTexture = NULL; + if (D3DXCreateTexture(g_pd3dDevice, font->TexWidth, font->TexHeight, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_DEFAULT, &pTexture) < 0) + { + IM_ASSERT(0); + return; + } - // Copy pixels - D3DLOCKED_RECT tex_locked_rect; - if (pTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) - { - IM_ASSERT(0); - return; - } - for (int y = 0; y < font->TexHeight; y++) - memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, font->TexPixels + font->TexWidth * y, font->TexWidth); - pTexture->UnlockRect(0); + // Copy pixels + D3DLOCKED_RECT tex_locked_rect; + if (pTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) + { + IM_ASSERT(0); + return; + } + for (int y = 0; y < font->TexHeight; y++) + memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, font->TexPixels + font->TexWidth * y, font->TexWidth); + pTexture->UnlockRect(0); - font->TexID = (void *)pTexture; + font->TexID = (void *)pTexture; } void InitImGui() @@ -242,7 +242,7 @@ io.Font->LoadDefault(); //io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault()); //io.Font->DisplayOffset.y += 0.0f; - LoadFontTexture(io.Font); + LoadFontTexture(io.Font); } INT64 ticks_per_second = 0; @@ -328,10 +328,10 @@ show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); - static ImFont* font2 = NULL; - if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } - ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); - //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); + static ImFont* font2 = NULL; + if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } + ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); + //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; diff --git a/examples/directx11_example/main.cpp b/examples/directx11_example/main.cpp index 3e3a265..4f6c4b7 100644 --- a/examples/directx11_example/main.cpp +++ b/examples/directx11_example/main.cpp @@ -137,7 +137,7 @@ { const ImDrawCmd* pcmd = &cmd_list->commands[cmd_i]; const D3D11_RECT r = { (LONG)pcmd->clip_rect.x, (LONG)pcmd->clip_rect.y, (LONG)pcmd->clip_rect.z, (LONG)pcmd->clip_rect.w }; - g_pd3dDeviceImmediateContext->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->texture_id); + g_pd3dDeviceImmediateContext->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->texture_id); g_pd3dDeviceImmediateContext->RSSetScissorRects(1, &r); g_pd3dDeviceImmediateContext->Draw(pcmd->vtx_count, vtx_offset); vtx_offset += pcmd->vtx_count; @@ -323,8 +323,8 @@ // InitImGui if (g_pFontSampler) g_pFontSampler->Release(); - if (ID3D11ShaderResourceView* font_texture_view = (ID3D11ShaderResourceView*)ImGui::GetIO().Font->TexID) - font_texture_view->Release(); + if (ID3D11ShaderResourceView* font_texture_view = (ID3D11ShaderResourceView*)ImGui::GetIO().Font->TexID) + font_texture_view->Release(); if (g_pVB) g_pVB->Release(); // InitDeviceD3D @@ -381,41 +381,41 @@ void LoadFontTexture(ImFont* font) { - IM_ASSERT(font && font->IsLoaded()); + IM_ASSERT(font && font->IsLoaded()); - // Create texture - D3D11_TEXTURE2D_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.Width = font->TexWidth; - desc.Height = font->TexHeight; - desc.MipLevels = 1; - desc.ArraySize = 1; - desc.Format = DXGI_FORMAT_A8_UNORM; - desc.SampleDesc.Count = 1; - desc.Usage = D3D11_USAGE_DEFAULT; - desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; - desc.CPUAccessFlags = 0; + // Create texture + D3D11_TEXTURE2D_DESC desc; + ZeroMemory(&desc, sizeof(desc)); + desc.Width = font->TexWidth; + desc.Height = font->TexHeight; + desc.MipLevels = 1; + desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_A8_UNORM; + desc.SampleDesc.Count = 1; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + desc.CPUAccessFlags = 0; - ID3D11Texture2D *pTexture = NULL; - D3D11_SUBRESOURCE_DATA subResource; - subResource.pSysMem = font->TexPixels; - subResource.SysMemPitch = desc.Width * 1; - subResource.SysMemSlicePitch = 0; - g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture); + ID3D11Texture2D *pTexture = NULL; + D3D11_SUBRESOURCE_DATA subResource; + subResource.pSysMem = font->TexPixels; + subResource.SysMemPitch = desc.Width * 1; + subResource.SysMemSlicePitch = 0; + g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture); - // Create texture view - D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; - ZeroMemory(&srvDesc, sizeof(srvDesc)); - srvDesc.Format = DXGI_FORMAT_A8_UNORM; - srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MipLevels = desc.MipLevels; - srvDesc.Texture2D.MostDetailedMip = 0; - ID3D11ShaderResourceView* font_texture_view = NULL; - g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &font_texture_view); - pTexture->Release(); + // Create texture view + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; + ZeroMemory(&srvDesc, sizeof(srvDesc)); + srvDesc.Format = DXGI_FORMAT_A8_UNORM; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + srvDesc.Texture2D.MipLevels = desc.MipLevels; + srvDesc.Texture2D.MostDetailedMip = 0; + ID3D11ShaderResourceView* font_texture_view = NULL; + g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &font_texture_view); + pTexture->Release(); - // Store ID - font->TexID = (void *)font_texture_view; + // Store ID + font->TexID = (void *)font_texture_view; } void InitImGui() @@ -469,7 +469,7 @@ io.Font->LoadDefault(); //io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault()); //io.Font->DisplayOffset.y += 0.0f; - LoadFontTexture(io.Font); + LoadFontTexture(io.Font); // Create texture sampler { @@ -570,10 +570,10 @@ show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); - static ImFont* font2 = NULL; - if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } - ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); - //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); + static ImFont* font2 = NULL; + if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } + ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); + //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; diff --git a/examples/directx9_example/main.cpp b/examples/directx9_example/main.cpp index afec7ae..d1939ad 100644 --- a/examples/directx9_example/main.cpp +++ b/examples/directx9_example/main.cpp @@ -69,11 +69,11 @@ g_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); g_pd3dDevice->SetRenderState( D3DRS_SCISSORTESTENABLE, true ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_POINT ); g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT ); @@ -95,7 +95,7 @@ { const ImDrawCmd* pcmd = &cmd_list->commands[cmd_i]; const RECT r = { (LONG)pcmd->clip_rect.x, (LONG)pcmd->clip_rect.y, (LONG)pcmd->clip_rect.z, (LONG)pcmd->clip_rect.w }; - g_pd3dDevice->SetTexture( 0, (LPDIRECT3DTEXTURE9)pcmd->texture_id ); + g_pd3dDevice->SetTexture( 0, (LPDIRECT3DTEXTURE9)pcmd->texture_id ); g_pd3dDevice->SetScissorRect(&r); g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, vtx_offset, pcmd->vtx_count/3); vtx_offset += pcmd->vtx_count; @@ -130,8 +130,8 @@ if (g_pVB) g_pVB->Release(); // InitDeviceD3D - if (LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)ImGui::GetIO().Font->TexID) - tex->Release(); + if (LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)ImGui::GetIO().Font->TexID) + tex->Release(); if (g_pd3dDevice) g_pd3dDevice->Release(); if (g_pD3D) g_pD3D->Release(); } @@ -176,27 +176,27 @@ void LoadFontTexture(ImFont* font) { - IM_ASSERT(font && font->IsLoaded()); + IM_ASSERT(font && font->IsLoaded()); - LPDIRECT3DTEXTURE9 pTexture = NULL; - if (D3DXCreateTexture(g_pd3dDevice, font->TexWidth, font->TexHeight, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_DEFAULT, &pTexture) < 0) - { - IM_ASSERT(0); - return; - } + LPDIRECT3DTEXTURE9 pTexture = NULL; + if (D3DXCreateTexture(g_pd3dDevice, font->TexWidth, font->TexHeight, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_DEFAULT, &pTexture) < 0) + { + IM_ASSERT(0); + return; + } - // Copy pixels - D3DLOCKED_RECT tex_locked_rect; - if (pTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) - { - IM_ASSERT(0); - return; - } - for (int y = 0; y < font->TexHeight; y++) - memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, font->TexPixels + font->TexWidth * y, font->TexWidth); - pTexture->UnlockRect(0); + // Copy pixels + D3DLOCKED_RECT tex_locked_rect; + if (pTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) + { + IM_ASSERT(0); + return; + } + for (int y = 0; y < font->TexHeight; y++) + memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, font->TexPixels + font->TexWidth * y, font->TexWidth); + pTexture->UnlockRect(0); - font->TexID = (void *)pTexture; + font->TexID = (void *)pTexture; } void InitImGui() @@ -242,7 +242,7 @@ io.Font->LoadDefault(); //io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault()); //io.Font->DisplayOffset.y += 0.0f; - LoadFontTexture(io.Font); + LoadFontTexture(io.Font); } INT64 ticks_per_second = 0; @@ -328,10 +328,10 @@ show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); - static ImFont* font2 = NULL; - if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } - ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); - //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); + static ImFont* font2 = NULL; + if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } + ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); + //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; diff --git a/examples/opengl3_example/main.cpp b/examples/opengl3_example/main.cpp index f124d10..c8fe320 100644 --- a/examples/opengl3_example/main.cpp +++ b/examples/opengl3_example/main.cpp @@ -92,7 +92,7 @@ const ImDrawCmd* pcmd_end = cmd_list->commands.end(); for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end; pcmd++) { - glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->texture_id); + glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->texture_id); glScissor((int)pcmd->clip_rect.x, (int)(height - pcmd->clip_rect.w), (int)(pcmd->clip_rect.z - pcmd->clip_rect.x), (int)(pcmd->clip_rect.w - pcmd->clip_rect.y)); glDrawArrays(GL_TRIANGLES, vtx_offset, pcmd->vtx_count); vtx_offset += pcmd->vtx_count; @@ -241,15 +241,15 @@ void LoadFontTexture(ImFont* font) { - IM_ASSERT(font && font->IsLoaded()); + IM_ASSERT(font && font->IsLoaded()); - GLuint tex_id; - glGenTextures(1, &tex_id); - glBindTexture(GL_TEXTURE_2D, tex_id); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, font->TexWidth, font->TexHeight, 0, GL_RED, GL_UNSIGNED_BYTE, font->TexPixels); - font->TexID = (void *)(intptr_t)tex_id; + GLuint tex_id; + glGenTextures(1, &tex_id); + glBindTexture(GL_TEXTURE_2D, tex_id); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, font->TexWidth, font->TexHeight, 0, GL_RED, GL_UNSIGNED_BYTE, font->TexPixels); + font->TexID = (void *)(intptr_t)tex_id; } void InitImGui() @@ -284,7 +284,7 @@ io.Font->LoadDefault(); //io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault()); //io.Font->DisplayOffset.y += 0.0f; - LoadFontTexture(io.Font); + LoadFontTexture(io.Font); } void UpdateImGui() @@ -344,10 +344,10 @@ show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); - static ImFont* font2 = NULL; - if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } - ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (float)font2->TexHeight)); - //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); + static ImFont* font2 = NULL; + if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } + ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (float)font2->TexHeight)); + //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; diff --git a/examples/directx11_example/main.cpp b/examples/directx11_example/main.cpp index 3e3a265..4f6c4b7 100644 --- a/examples/directx11_example/main.cpp +++ b/examples/directx11_example/main.cpp @@ -137,7 +137,7 @@ { const ImDrawCmd* pcmd = &cmd_list->commands[cmd_i]; const D3D11_RECT r = { (LONG)pcmd->clip_rect.x, (LONG)pcmd->clip_rect.y, (LONG)pcmd->clip_rect.z, (LONG)pcmd->clip_rect.w }; - g_pd3dDeviceImmediateContext->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->texture_id); + g_pd3dDeviceImmediateContext->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->texture_id); g_pd3dDeviceImmediateContext->RSSetScissorRects(1, &r); g_pd3dDeviceImmediateContext->Draw(pcmd->vtx_count, vtx_offset); vtx_offset += pcmd->vtx_count; @@ -323,8 +323,8 @@ // InitImGui if (g_pFontSampler) g_pFontSampler->Release(); - if (ID3D11ShaderResourceView* font_texture_view = (ID3D11ShaderResourceView*)ImGui::GetIO().Font->TexID) - font_texture_view->Release(); + if (ID3D11ShaderResourceView* font_texture_view = (ID3D11ShaderResourceView*)ImGui::GetIO().Font->TexID) + font_texture_view->Release(); if (g_pVB) g_pVB->Release(); // InitDeviceD3D @@ -381,41 +381,41 @@ void LoadFontTexture(ImFont* font) { - IM_ASSERT(font && font->IsLoaded()); + IM_ASSERT(font && font->IsLoaded()); - // Create texture - D3D11_TEXTURE2D_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.Width = font->TexWidth; - desc.Height = font->TexHeight; - desc.MipLevels = 1; - desc.ArraySize = 1; - desc.Format = DXGI_FORMAT_A8_UNORM; - desc.SampleDesc.Count = 1; - desc.Usage = D3D11_USAGE_DEFAULT; - desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; - desc.CPUAccessFlags = 0; + // Create texture + D3D11_TEXTURE2D_DESC desc; + ZeroMemory(&desc, sizeof(desc)); + desc.Width = font->TexWidth; + desc.Height = font->TexHeight; + desc.MipLevels = 1; + desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_A8_UNORM; + desc.SampleDesc.Count = 1; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + desc.CPUAccessFlags = 0; - ID3D11Texture2D *pTexture = NULL; - D3D11_SUBRESOURCE_DATA subResource; - subResource.pSysMem = font->TexPixels; - subResource.SysMemPitch = desc.Width * 1; - subResource.SysMemSlicePitch = 0; - g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture); + ID3D11Texture2D *pTexture = NULL; + D3D11_SUBRESOURCE_DATA subResource; + subResource.pSysMem = font->TexPixels; + subResource.SysMemPitch = desc.Width * 1; + subResource.SysMemSlicePitch = 0; + g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture); - // Create texture view - D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; - ZeroMemory(&srvDesc, sizeof(srvDesc)); - srvDesc.Format = DXGI_FORMAT_A8_UNORM; - srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MipLevels = desc.MipLevels; - srvDesc.Texture2D.MostDetailedMip = 0; - ID3D11ShaderResourceView* font_texture_view = NULL; - g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &font_texture_view); - pTexture->Release(); + // Create texture view + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; + ZeroMemory(&srvDesc, sizeof(srvDesc)); + srvDesc.Format = DXGI_FORMAT_A8_UNORM; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + srvDesc.Texture2D.MipLevels = desc.MipLevels; + srvDesc.Texture2D.MostDetailedMip = 0; + ID3D11ShaderResourceView* font_texture_view = NULL; + g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &font_texture_view); + pTexture->Release(); - // Store ID - font->TexID = (void *)font_texture_view; + // Store ID + font->TexID = (void *)font_texture_view; } void InitImGui() @@ -469,7 +469,7 @@ io.Font->LoadDefault(); //io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault()); //io.Font->DisplayOffset.y += 0.0f; - LoadFontTexture(io.Font); + LoadFontTexture(io.Font); // Create texture sampler { @@ -570,10 +570,10 @@ show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); - static ImFont* font2 = NULL; - if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } - ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); - //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); + static ImFont* font2 = NULL; + if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } + ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); + //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; diff --git a/examples/directx9_example/main.cpp b/examples/directx9_example/main.cpp index afec7ae..d1939ad 100644 --- a/examples/directx9_example/main.cpp +++ b/examples/directx9_example/main.cpp @@ -69,11 +69,11 @@ g_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); g_pd3dDevice->SetRenderState( D3DRS_SCISSORTESTENABLE, true ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_POINT ); g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT ); @@ -95,7 +95,7 @@ { const ImDrawCmd* pcmd = &cmd_list->commands[cmd_i]; const RECT r = { (LONG)pcmd->clip_rect.x, (LONG)pcmd->clip_rect.y, (LONG)pcmd->clip_rect.z, (LONG)pcmd->clip_rect.w }; - g_pd3dDevice->SetTexture( 0, (LPDIRECT3DTEXTURE9)pcmd->texture_id ); + g_pd3dDevice->SetTexture( 0, (LPDIRECT3DTEXTURE9)pcmd->texture_id ); g_pd3dDevice->SetScissorRect(&r); g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, vtx_offset, pcmd->vtx_count/3); vtx_offset += pcmd->vtx_count; @@ -130,8 +130,8 @@ if (g_pVB) g_pVB->Release(); // InitDeviceD3D - if (LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)ImGui::GetIO().Font->TexID) - tex->Release(); + if (LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)ImGui::GetIO().Font->TexID) + tex->Release(); if (g_pd3dDevice) g_pd3dDevice->Release(); if (g_pD3D) g_pD3D->Release(); } @@ -176,27 +176,27 @@ void LoadFontTexture(ImFont* font) { - IM_ASSERT(font && font->IsLoaded()); + IM_ASSERT(font && font->IsLoaded()); - LPDIRECT3DTEXTURE9 pTexture = NULL; - if (D3DXCreateTexture(g_pd3dDevice, font->TexWidth, font->TexHeight, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_DEFAULT, &pTexture) < 0) - { - IM_ASSERT(0); - return; - } + LPDIRECT3DTEXTURE9 pTexture = NULL; + if (D3DXCreateTexture(g_pd3dDevice, font->TexWidth, font->TexHeight, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_DEFAULT, &pTexture) < 0) + { + IM_ASSERT(0); + return; + } - // Copy pixels - D3DLOCKED_RECT tex_locked_rect; - if (pTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) - { - IM_ASSERT(0); - return; - } - for (int y = 0; y < font->TexHeight; y++) - memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, font->TexPixels + font->TexWidth * y, font->TexWidth); - pTexture->UnlockRect(0); + // Copy pixels + D3DLOCKED_RECT tex_locked_rect; + if (pTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) + { + IM_ASSERT(0); + return; + } + for (int y = 0; y < font->TexHeight; y++) + memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, font->TexPixels + font->TexWidth * y, font->TexWidth); + pTexture->UnlockRect(0); - font->TexID = (void *)pTexture; + font->TexID = (void *)pTexture; } void InitImGui() @@ -242,7 +242,7 @@ io.Font->LoadDefault(); //io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault()); //io.Font->DisplayOffset.y += 0.0f; - LoadFontTexture(io.Font); + LoadFontTexture(io.Font); } INT64 ticks_per_second = 0; @@ -328,10 +328,10 @@ show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); - static ImFont* font2 = NULL; - if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } - ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); - //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); + static ImFont* font2 = NULL; + if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } + ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); + //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; diff --git a/examples/opengl3_example/main.cpp b/examples/opengl3_example/main.cpp index f124d10..c8fe320 100644 --- a/examples/opengl3_example/main.cpp +++ b/examples/opengl3_example/main.cpp @@ -92,7 +92,7 @@ const ImDrawCmd* pcmd_end = cmd_list->commands.end(); for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end; pcmd++) { - glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->texture_id); + glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->texture_id); glScissor((int)pcmd->clip_rect.x, (int)(height - pcmd->clip_rect.w), (int)(pcmd->clip_rect.z - pcmd->clip_rect.x), (int)(pcmd->clip_rect.w - pcmd->clip_rect.y)); glDrawArrays(GL_TRIANGLES, vtx_offset, pcmd->vtx_count); vtx_offset += pcmd->vtx_count; @@ -241,15 +241,15 @@ void LoadFontTexture(ImFont* font) { - IM_ASSERT(font && font->IsLoaded()); + IM_ASSERT(font && font->IsLoaded()); - GLuint tex_id; - glGenTextures(1, &tex_id); - glBindTexture(GL_TEXTURE_2D, tex_id); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, font->TexWidth, font->TexHeight, 0, GL_RED, GL_UNSIGNED_BYTE, font->TexPixels); - font->TexID = (void *)(intptr_t)tex_id; + GLuint tex_id; + glGenTextures(1, &tex_id); + glBindTexture(GL_TEXTURE_2D, tex_id); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, font->TexWidth, font->TexHeight, 0, GL_RED, GL_UNSIGNED_BYTE, font->TexPixels); + font->TexID = (void *)(intptr_t)tex_id; } void InitImGui() @@ -284,7 +284,7 @@ io.Font->LoadDefault(); //io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault()); //io.Font->DisplayOffset.y += 0.0f; - LoadFontTexture(io.Font); + LoadFontTexture(io.Font); } void UpdateImGui() @@ -344,10 +344,10 @@ show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); - static ImFont* font2 = NULL; - if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } - ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (float)font2->TexHeight)); - //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); + static ImFont* font2 = NULL; + if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } + ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (float)font2->TexHeight)); + //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; diff --git a/examples/opengl_example/main.cpp b/examples/opengl_example/main.cpp index 005dfa5..cc3fae3 100644 --- a/examples/opengl_example/main.cpp +++ b/examples/opengl_example/main.cpp @@ -252,10 +252,10 @@ show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); - static ImFont* font2 = NULL; - if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } - ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (float)font2->TexHeight)); - //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); + static ImFont* font2 = NULL; + if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } + ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (float)font2->TexHeight)); + //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; diff --git a/examples/directx11_example/main.cpp b/examples/directx11_example/main.cpp index 3e3a265..4f6c4b7 100644 --- a/examples/directx11_example/main.cpp +++ b/examples/directx11_example/main.cpp @@ -137,7 +137,7 @@ { const ImDrawCmd* pcmd = &cmd_list->commands[cmd_i]; const D3D11_RECT r = { (LONG)pcmd->clip_rect.x, (LONG)pcmd->clip_rect.y, (LONG)pcmd->clip_rect.z, (LONG)pcmd->clip_rect.w }; - g_pd3dDeviceImmediateContext->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->texture_id); + g_pd3dDeviceImmediateContext->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->texture_id); g_pd3dDeviceImmediateContext->RSSetScissorRects(1, &r); g_pd3dDeviceImmediateContext->Draw(pcmd->vtx_count, vtx_offset); vtx_offset += pcmd->vtx_count; @@ -323,8 +323,8 @@ // InitImGui if (g_pFontSampler) g_pFontSampler->Release(); - if (ID3D11ShaderResourceView* font_texture_view = (ID3D11ShaderResourceView*)ImGui::GetIO().Font->TexID) - font_texture_view->Release(); + if (ID3D11ShaderResourceView* font_texture_view = (ID3D11ShaderResourceView*)ImGui::GetIO().Font->TexID) + font_texture_view->Release(); if (g_pVB) g_pVB->Release(); // InitDeviceD3D @@ -381,41 +381,41 @@ void LoadFontTexture(ImFont* font) { - IM_ASSERT(font && font->IsLoaded()); + IM_ASSERT(font && font->IsLoaded()); - // Create texture - D3D11_TEXTURE2D_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.Width = font->TexWidth; - desc.Height = font->TexHeight; - desc.MipLevels = 1; - desc.ArraySize = 1; - desc.Format = DXGI_FORMAT_A8_UNORM; - desc.SampleDesc.Count = 1; - desc.Usage = D3D11_USAGE_DEFAULT; - desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; - desc.CPUAccessFlags = 0; + // Create texture + D3D11_TEXTURE2D_DESC desc; + ZeroMemory(&desc, sizeof(desc)); + desc.Width = font->TexWidth; + desc.Height = font->TexHeight; + desc.MipLevels = 1; + desc.ArraySize = 1; + desc.Format = DXGI_FORMAT_A8_UNORM; + desc.SampleDesc.Count = 1; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + desc.CPUAccessFlags = 0; - ID3D11Texture2D *pTexture = NULL; - D3D11_SUBRESOURCE_DATA subResource; - subResource.pSysMem = font->TexPixels; - subResource.SysMemPitch = desc.Width * 1; - subResource.SysMemSlicePitch = 0; - g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture); + ID3D11Texture2D *pTexture = NULL; + D3D11_SUBRESOURCE_DATA subResource; + subResource.pSysMem = font->TexPixels; + subResource.SysMemPitch = desc.Width * 1; + subResource.SysMemSlicePitch = 0; + g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture); - // Create texture view - D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; - ZeroMemory(&srvDesc, sizeof(srvDesc)); - srvDesc.Format = DXGI_FORMAT_A8_UNORM; - srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MipLevels = desc.MipLevels; - srvDesc.Texture2D.MostDetailedMip = 0; - ID3D11ShaderResourceView* font_texture_view = NULL; - g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &font_texture_view); - pTexture->Release(); + // Create texture view + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; + ZeroMemory(&srvDesc, sizeof(srvDesc)); + srvDesc.Format = DXGI_FORMAT_A8_UNORM; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + srvDesc.Texture2D.MipLevels = desc.MipLevels; + srvDesc.Texture2D.MostDetailedMip = 0; + ID3D11ShaderResourceView* font_texture_view = NULL; + g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &font_texture_view); + pTexture->Release(); - // Store ID - font->TexID = (void *)font_texture_view; + // Store ID + font->TexID = (void *)font_texture_view; } void InitImGui() @@ -469,7 +469,7 @@ io.Font->LoadDefault(); //io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault()); //io.Font->DisplayOffset.y += 0.0f; - LoadFontTexture(io.Font); + LoadFontTexture(io.Font); // Create texture sampler { @@ -570,10 +570,10 @@ show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); - static ImFont* font2 = NULL; - if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } - ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); - //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); + static ImFont* font2 = NULL; + if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } + ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); + //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; diff --git a/examples/directx9_example/main.cpp b/examples/directx9_example/main.cpp index afec7ae..d1939ad 100644 --- a/examples/directx9_example/main.cpp +++ b/examples/directx9_example/main.cpp @@ -69,11 +69,11 @@ g_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); g_pd3dDevice->SetRenderState( D3DRS_SCISSORTESTENABLE, true ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); - g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); + g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_POINT ); g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT ); @@ -95,7 +95,7 @@ { const ImDrawCmd* pcmd = &cmd_list->commands[cmd_i]; const RECT r = { (LONG)pcmd->clip_rect.x, (LONG)pcmd->clip_rect.y, (LONG)pcmd->clip_rect.z, (LONG)pcmd->clip_rect.w }; - g_pd3dDevice->SetTexture( 0, (LPDIRECT3DTEXTURE9)pcmd->texture_id ); + g_pd3dDevice->SetTexture( 0, (LPDIRECT3DTEXTURE9)pcmd->texture_id ); g_pd3dDevice->SetScissorRect(&r); g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST, vtx_offset, pcmd->vtx_count/3); vtx_offset += pcmd->vtx_count; @@ -130,8 +130,8 @@ if (g_pVB) g_pVB->Release(); // InitDeviceD3D - if (LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)ImGui::GetIO().Font->TexID) - tex->Release(); + if (LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)ImGui::GetIO().Font->TexID) + tex->Release(); if (g_pd3dDevice) g_pd3dDevice->Release(); if (g_pD3D) g_pD3D->Release(); } @@ -176,27 +176,27 @@ void LoadFontTexture(ImFont* font) { - IM_ASSERT(font && font->IsLoaded()); + IM_ASSERT(font && font->IsLoaded()); - LPDIRECT3DTEXTURE9 pTexture = NULL; - if (D3DXCreateTexture(g_pd3dDevice, font->TexWidth, font->TexHeight, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_DEFAULT, &pTexture) < 0) - { - IM_ASSERT(0); - return; - } + LPDIRECT3DTEXTURE9 pTexture = NULL; + if (D3DXCreateTexture(g_pd3dDevice, font->TexWidth, font->TexHeight, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8, D3DPOOL_DEFAULT, &pTexture) < 0) + { + IM_ASSERT(0); + return; + } - // Copy pixels - D3DLOCKED_RECT tex_locked_rect; - if (pTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) - { - IM_ASSERT(0); - return; - } - for (int y = 0; y < font->TexHeight; y++) - memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, font->TexPixels + font->TexWidth * y, font->TexWidth); - pTexture->UnlockRect(0); + // Copy pixels + D3DLOCKED_RECT tex_locked_rect; + if (pTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) + { + IM_ASSERT(0); + return; + } + for (int y = 0; y < font->TexHeight; y++) + memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, font->TexPixels + font->TexWidth * y, font->TexWidth); + pTexture->UnlockRect(0); - font->TexID = (void *)pTexture; + font->TexID = (void *)pTexture; } void InitImGui() @@ -242,7 +242,7 @@ io.Font->LoadDefault(); //io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault()); //io.Font->DisplayOffset.y += 0.0f; - LoadFontTexture(io.Font); + LoadFontTexture(io.Font); } INT64 ticks_per_second = 0; @@ -328,10 +328,10 @@ show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); - static ImFont* font2 = NULL; - if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } - ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); - //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); + static ImFont* font2 = NULL; + if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } + ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (FLOAT)font2->TexHeight)); + //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; diff --git a/examples/opengl3_example/main.cpp b/examples/opengl3_example/main.cpp index f124d10..c8fe320 100644 --- a/examples/opengl3_example/main.cpp +++ b/examples/opengl3_example/main.cpp @@ -92,7 +92,7 @@ const ImDrawCmd* pcmd_end = cmd_list->commands.end(); for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end; pcmd++) { - glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->texture_id); + glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->texture_id); glScissor((int)pcmd->clip_rect.x, (int)(height - pcmd->clip_rect.w), (int)(pcmd->clip_rect.z - pcmd->clip_rect.x), (int)(pcmd->clip_rect.w - pcmd->clip_rect.y)); glDrawArrays(GL_TRIANGLES, vtx_offset, pcmd->vtx_count); vtx_offset += pcmd->vtx_count; @@ -241,15 +241,15 @@ void LoadFontTexture(ImFont* font) { - IM_ASSERT(font && font->IsLoaded()); + IM_ASSERT(font && font->IsLoaded()); - GLuint tex_id; - glGenTextures(1, &tex_id); - glBindTexture(GL_TEXTURE_2D, tex_id); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, font->TexWidth, font->TexHeight, 0, GL_RED, GL_UNSIGNED_BYTE, font->TexPixels); - font->TexID = (void *)(intptr_t)tex_id; + GLuint tex_id; + glGenTextures(1, &tex_id); + glBindTexture(GL_TEXTURE_2D, tex_id); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, font->TexWidth, font->TexHeight, 0, GL_RED, GL_UNSIGNED_BYTE, font->TexPixels); + font->TexID = (void *)(intptr_t)tex_id; } void InitImGui() @@ -284,7 +284,7 @@ io.Font->LoadDefault(); //io.Font->LoadFromFileTTF("myfont.ttf", font_size_px, ImFont::GetGlyphRangesDefault()); //io.Font->DisplayOffset.y += 0.0f; - LoadFontTexture(io.Font); + LoadFontTexture(io.Font); } void UpdateImGui() @@ -344,10 +344,10 @@ show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); - static ImFont* font2 = NULL; - if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } - ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (float)font2->TexHeight)); - //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); + static ImFont* font2 = NULL; + if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } + ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (float)font2->TexHeight)); + //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; diff --git a/examples/opengl_example/main.cpp b/examples/opengl_example/main.cpp index 005dfa5..cc3fae3 100644 --- a/examples/opengl_example/main.cpp +++ b/examples/opengl_example/main.cpp @@ -252,10 +252,10 @@ show_test_window ^= ImGui::Button("Test Window"); show_another_window ^= ImGui::Button("Another Window"); - static ImFont* font2 = NULL; - if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } - ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (float)font2->TexHeight)); - //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); + static ImFont* font2 = NULL; + if (!font2) { font2 = new ImFont(); font2->LoadFromFileTTF("../../extra_fonts/ArialUni.ttf", 30.0f); LoadFontTexture(font2); } + ImGui::Image(font2->TexID, ImVec2((float)font2->TexWidth, (float)font2->TexHeight)); + //ImGui::GetWindowDrawList()->AddText(font2, 30.0f, ImGui::GetCursorScreenPos(), 0xFFFFFFFF, "Another font"); // Calculate and show frame rate static float ms_per_frame[120] = { 0 }; diff --git a/imgui.cpp b/imgui.cpp index 9747f60..5b55770 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7358,7 +7358,7 @@ if (ImGui::TreeNode("Images")) { - ImGui::TextWrapped("Below we are displaying the font texture (which is the only texture we have access to in this demo). Use the 'ImTextureID' type as storage to pass pointers or identifier to your own texture data.\nHover the texture for a zoomed view."); + ImGui::TextWrapped("Below we are displaying the font texture (which is the only texture we have access to in this demo). Use the 'ImTextureID' type as storage to pass pointers or identifier to your own texture data. Hover the texture for a zoomed view!"); ImVec2 tex_screen_pos = ImGui::GetCursorScreenPos(); float tex_w = (float)ImGui::GetIO().Font->TexWidth; float tex_h = (float)ImGui::GetIO().Font->TexHeight;