From: Stefanos A. <sta...@gm...> - 2008-08-24 02:14:05
|
Την Sun, 24 Aug 2008 04:05:06 +0300,ο(η) Henri Häkkinen <hen...@gm...> έγραψε: > Does anyone have anything to say on this, please? I am currently working > hard on the GLM and I think we should resolve the issue of how we > actually > define the math types. > I'd go for #2 (struct/union), just slightly modified. Why use a struct? Because typing vec.x is cleaner than vec[0]. Why have a union? So you can pass the struct to OpenGL without a cast. Compare: foo(vec.data); // approach #2 (struct/union) vs foo((GLfloat*)vec); // approach #3 (struct) vs foo(&vec.x); // approach #3 (struct) To that end, it might be better to define structs like this: typedef struct GLMFoo_t { union GLMFoo_data { GLfloat data[2]; // Instead of v[] or m[] struct GLMFoo_fields { GLfloat x, y; } } } GLMFoo; This makes clear that the "data" field provides the storage for the vector data - v or m might be somewhat cryptic at first glance. |