summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-01-12 15:01:03 -0800
committerIan Romanick <ian.d.romanick@intel.com>2010-01-12 15:01:03 -0800
commita2357a6c2419437ec74146a750b37e43a4e85327 (patch)
treeefb5a03a815beebb7e4d48a5c684be7e5178632c
parentda3fd3d210b73c665e8b1d3982b861539b6cd020 (diff)
Add missing contructor type and operator overloads
The vec4(float) constructor and several common operators that are available in GLSL were missing. There are probably still some that are missing, but they can be added later.
-rw-r--r--include/glu3.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/glu3.h b/include/glu3.h
index 9f082ce..3d7a10b 100644
--- a/include/glu3.h
+++ b/include/glu3.h
@@ -48,6 +48,15 @@ struct GLUvec4 {
{
}
+ /** Initialize vector from one float value. */
+ inline GLUvec4(GLfloat v)
+ {
+ values[0] = v;
+ values[1] = v;
+ values[2] = v;
+ values[3] = v;
+ }
+
/** Initialize vector from four float values. */
inline GLUvec4(GLfloat x , GLfloat y, GLfloat z, GLfloat w)
{
@@ -97,6 +106,38 @@ struct GLUvec4 {
};
+#ifdef __cplusplus
+inline GLUvec4 operator *(GLfloat f, const GLUvec4 &v)
+{
+ return v * f;
+}
+
+inline GLUvec4 &operator +=(GLUvec4 &l, const GLUvec4 &r)
+{
+ l = l + r;
+ return l;
+}
+
+inline GLUvec4 &operator -=(GLUvec4 &l, const GLUvec4 &r)
+{
+ l = l - r;
+ return l;
+}
+
+inline GLUvec4 &operator *=(GLUvec4 &l, const GLUvec4 &r)
+{
+ l = l * r;
+ return l;
+}
+
+inline GLUvec4 &operator *=(GLUvec4 &l, GLfloat r)
+{
+ l = l * r;
+ return l;
+}
+#endif /* __cplusplus */
+
+
/**
* Basic 4x4 matrix type.
*/