Код: Выделить всё
#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 раза.
Подробнее здесь: https://stackoverflow.com/questions/786 ... n-ftlg-lib