我正在开发一个在C ++上使用OpenGL和GLUT创建绘画程序的项目。
到目前为止,我在左侧有一个颜色菜单,现在我正在尝试在右侧创建一个工具菜单,但我无法弄清楚如何在右侧获得它。
这是我到目前为止所做的:
int inwindow(int x, int y)
{
return (x > WLEFT && x < WRIGHT && y > WBOTTOM && y < WTOP);
}
static float colormenu[][8] = {{Red}, {Orange}, {Yellow}, {Green}, {Cyan}, {Blue}, {Purple}, {Black}};
int incolormenu(int x, int y)
{
return (x >= 0 && x <= MENUWIDTH && y >= 0 && y <= HEIGHT);
}
int colormenuindex(int x, int y)
{
if(!incolormenu(x, y))
return -1;
else
return(y / BOXHEIGHT);
}
static float toolmenu[][6] = {{Pencil}, {Line}, {Box}, {Rectangle}, {Circle}, {FCircle}};
int intoolmenu(int x, int y)
{
return (x >= 0 && x <= MENUWIDTH && y >= 0 && y <= HEIGHT);
}
int toolmenuindex(int x, int y)
{
if(!intoolmenu(x, y))
return -1;
else
return(y / BOXHEIGHT);
}
void drawSketch()
{
int i;
glClearColor(Grey, 1);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(Black);
for(i = 0; i < NCOLORS; i++)
{
glColor3f(colormenu[i][R], colormenu[i][G], colormenu[i][B]);
glRecti(1, BOXHEIGHT * i + 1, MENUWIDTH - 1, BOXHEIGHT * (i + 1) - 1);
}
for(i = 0; i < NCOLORS; i++)
{
glColor3f(toolmenu[i][Pencil], toolmenu[i][Line], toolmenu[i][Box]);
glRasterPos3f(0.2, -0.8, -1.5);
}
glFlush();
}