ImGui::Text не показывает строку моего ImVectorC++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 ImGui::Text не показывает строку моего ImVector

Сообщение Anonymous »

Я пытаюсь напечатать на экране название пина, но он показывает странные символы:
Пин со странными символами
Мой класс такой:

Код: Выделить всё

struct Pin
{
int ID;
char Name[32];

Pin(int id, const char *name)
{
ID = id;
strcpy(Name, name);
}
};

struct Node
{
int ID;
char Name[32];
ImVec2 Pos, Size;
float Value;
ImVector
 Inputs, Outputs;

Node(int id, const char *name, const ImVec2 &pos, const ImVector inputs, const ImVector outputs)
{
ID = id;
strcpy(Name, name);
Pos = pos;
Inputs = inputs;
Outputs = outputs;
}

ImRect GetInputFlowSlotPos(ImVec2 offset) const
{
return ImRect(offset + ImVec2(Pos.x + 24.0f, Pos.y + 44.0f), offset + ImVec2(Pos.x + 4.0f, Pos.y + 24.0f));
}
ImRect GetOutputFlowSlotPos(ImVec2 offset) const
{
return ImRect(offset + ImVec2(Pos.x + Size.x - 24.0f, Pos.y + 24.0f), offset + ImVec2(Pos.x + Size.x - 4.0f, Pos.y + 44.0f));
}
ImVec2 GetInputSlotPos(int slot_no) const { return ImVec2(Pos.x, Pos.y + Size.y * ((float)slot_no + 1) / ((float)Inputs.Size + 1)); }
ImVec2 GetOutputSlotPos(int slot_no) const { return ImVec2(Pos.x + Size.x, Pos.y + Size.y * ((float)slot_no + 1) / ((float)Outputs.Size + 1)); }
};
А я инициализирую так:

Код: Выделить всё

inputsPin.push_back(Pin(0, "X"));
inputsPin.push_back(Pin(1, "Y"));
inputsPin.push_back(Pin(2, "Z"));

nodes.push_back(Node(0, "Di", ImVec2(40, 50), inputsPin, outputsPin));
nodes.push_back(Node(1, "Di", ImVec2(40, 150), inputsPin, outputsPin));
nodes.push_back(Node(2, "Di", ImVec2(270, 80), inputsPin, outputsPin));
Когда я печатаю:

Код: Выделить всё

for (int slot_idx = 0; slot_idx < node->Inputs.Size; slot_idx++)
{
Pin *pin = &node->Inputs[slot_idx];

ImGui::SetCursorScreenPos(offset + node->GetInputSlotPos(slot_idx));
ImGui::Text("%s", pin->Name);
}
*Изменить: после того, как я перешел на std::string, напечатанная строка стала еще более странной:
Еще одна ошибка

Подробнее здесь: https://stackoverflow.com/questions/786 ... mvectorpin
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»