Dear ImGUI 使用指南

时间:2024-04-02 13:03:02

文档

1)Dear IMGui

2) 知乎

组件

1) Com 如何设置动态字符串?

//char*pTest = "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0";  用0 隔开所有的字符串。

        const int iLength = ;
char szTemp[iLength] = {};
//SafeMBSprintf(szTemp,iLength,"%s",pMainUserContainer->GetUser()->GetName().c_str());
int iIndex = ;
int iLefeTempBuffSize = iLength;
char *pTemPointer = szTemp;
auto iSize = vecOppentName.size();
for (int i = ; i < iSize; i++)
{
pTemPointer = szTemp + iIndex;
auto iSize = vecOppentName[i].size();
SafeMemcpy(pTemPointer,iLefeTempBuffSize,vecOppentName[i].c_str(),iSize);
iIndex += iSize;
szTemp[iIndex] = ;
//This space is set to 0 for spilt
iIndex ++;
iLefeTempBuffSize = iLength - iIndex; }
pTemPointer[iIndex++] = ;
pTemPointer[iIndex] = ImGui::Combo(szPosition, &iShowGuardSelectIndex[j], szTemp);

字体

1) 设置默认字体

                ImGui::CreateContext();

                    ImGuiIO& io = ImGui::GetIO();
io.Fonts->AddFontDefault();
ImFont* font = io.Fonts->AddFontFromFileTTF("font\\FounderCN.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesChineseFull());
IM_ASSERT(font != NULL);
ImGui::GetIO().FontDefault = font;
ImGui_ImplDX11_Init(device,context);
ImGui_ImplWin32_Init(window->WndHandle());
ImGui_ImplDX11_CreateDeviceObjects()

2)输入中文必须采用utf8