typedef union {
float flts[4];
struct {
GLfloat r;
GLfloat theta;
GLfloat phi;
GLfloat w;
};
struct {
GLfloat x;
GLfloat y;
GLfloat z;
GLfloat w;
};
} FltVector;
好的,所以我想我得到如何使用這個,(或者,這是我如何看到它使用)ie。尋求C Union清晰度
FltVector fltVec1 = {{1.0f, 1.0f, 1.0f, 1.0f}};
float aaa = fltVec1.x;
etc.
但我真的不groking多少存儲已經由工會宣佈(4輛花車?8輛花車?12個浮點?),怎麼樣?爲什麼?另外爲什麼兩套花括號使用FltVector {{}}?
爲什麼要使用聯合?爲什麼不這樣做..
struct FltVector {
GLfloat x;
GLfloat y;
GLfloat z;
GLfloat w;
}
?
任何指針讚賞(抱歉的雙關語)
這就是在這種情況下:4浮點數(如果GLfloat等於浮點數) – tur1ng 2010-05-20 11:42:21