如何在中心的按鈕上繪製正方形(如停止按鈕)?如何使用OpenGL在中心按鈕上繪製正方形?
在這段代碼中,我嘗試像按鈕的矩形,全:
void ButtonDraw(Button *b)
{
if(b)
{
/*
* We will indicate that the mouse cursor is over the button by changing its
* colour.
*/
if (b->highlighted)
glColor3f(0.7f,0.7f,0.8f);
else
glColor3f(0.6f,0.6f,0.6f);
/*
* draw background for the button.
*/
glBegin(GL_QUADS);
glVertex2i(b->x , b->y );
glVertex2i(b->x , b->y+b->h);
glVertex2i(b->x+b->w, b->y+b->h);
glVertex2i(b->x+b->w, b->y );
glEnd();
/*draw red square on the button*/
glBegin(GL_QUADS);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex2i(b->x, b->y);
glVertex2i(b->x+b->w, b->y);
glVertex2i(b->x+b->w, b->y + b->h);
glVertex2i(b->x, b->y + b->h);
glEnd();
/*
* Draw an outline around the button with width 3
*/
glLineWidth(3);
}
}
請將代碼作爲代碼發佈,而不是截圖。 –
謝謝你的建議唐老鴨。 – Melo234