所以我有以下内容:
//at file scope
GLfloat point_colour[3] = {1.0, 0.5, 0.0};
...
void menu_colour(int index){
switch(index){
case RED: point_colour = {1.0, 0.0, 0.0}; break;
case GREEN: point_colour = {0.0, 1.0, 0.0}; break;
case BLUE: point_colour = {0.0, 0.0, 1.0}; break;
case ORANGE: point_colour = {1.0, 0.5, 0.0}; break;
case PURPLE: point_colour = {1.0, 0.0, 0.8}; break;
default: point_colour = {1.0, 0.0, 0.0};
}
}
但我得到error: expected expression before '{' token
每个案例行。
我正在尝试为数组分配一个新的值point_colour
数组 - 有帮助吗?我怀疑我的做法完全错误......