C++, почему мы используем «button.label» в библиотеке FTLG?C++

Программы на C++. Форум разработчиков
Anonymous
C++, почему мы используем «button.label» в библиотеке FTLG?

Сообщение Anonymous »

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

#include 
#include 
#include 
#include 
#include 

struct Button
{
float x, y, width, height;
bool isHovered = false;
bool isClicked = false;
const char *label;
};

void drawButton(const Button& button, FTGLPixmapFont& font){
if (button.isHovered) {
glColor3f(0.8f, 0.8f, 0.8f);
} else {
glColor3f(0.6f, 0.6f, 0.6f);
}
glBegin(GL_QUADS);
glVertex2f(button.x, button.y);
glVertex2f(button.x + button.width, button.y);
glVertex2f(button.x + button.width, button.y + button.height);
glVertex2f(button.x, button.y + button.height);
glEnd();

if (!font.Error()) {
glColor3f(0.0f, 0.0f, 0.0f);

float textX = button.x + button.width / 2 - (font.Advance(button.label) / 2); //why we use "button.label" here?

float textY = button.y + button.height / 2 - (font.FaceSize() / 2); //and not here?
glRasterPos2f(textX, textY);
font.Render(button.label);
}
}
`

Я использую чат gpt, чтобы помочь мне создать окно и кнопку, он не может это объяснить, я спрашивал его об этом 3 раза, и он ответил о размере шрифта, размере высоты, и все остальное, но не об этом.
скажи пожалуйста, зачем нам это, я не могу этого понять..
спроси в чате gpt 3 раза.

Подробнее здесь: https://stackoverflow.com/questions/786 ... n-ftlg-lib

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