I'm having a hard time understanding the difference between those two commands
char name[0x36];
sprintf_s(name, "Some Text (%d%% Water) [%dm]", amount, dist);
Drawing::RenderText(const_cast<char*>(name), screen, cfg.visuals.ships.textCol);
and
char name[0x36];
sprintf_s(name, "Some Text (%d%% Water) [%dm]", amount, dist);
Drawing::RenderText(name, screen, cfg.visuals.ships.textCol);
and here's the RenderText func:
void xD::Renderer::Drawing::RenderText(const char* text, const FVector2D& pos, const ImVec4& color, const bool outlined = true, const bool centered = true)
{
if (!text) return;
auto ImScreen = *reinterpret_cast<const ImVec2*>(&pos);
if (centered)
{
auto size = ImGui::CalcTextSize(text);
ImScreen.x -= size.x * 0.5f;
ImScreen.y -= size.y;
}
auto window = ImGui::GetCurrentWindow();
if (outlined)
{
window->DrawList->AddText(nullptr, 0.f, ImVec2(ImScreen.x - 1.f, ImScreen.y 1.f), ImGui::GetColorU32(IM_COL32_BLACK), text);
}
window->DrawList->AddText(nullptr, 0.f, ImScreen, ImGui::GetColorU32(color), text);
}
Im working with ImGui
CodePudding user response:
What's the difference between (const_cast<char*> and without?
The difference is that in one case the conversion is implicit and in the other case the conversion is explicit. There is no other difference.