[glu3-devel] [PATCH] Add a division-by-scalar operator to GLUvec4.

Kenneth Graunke kenneth at whitecape.org
Thu Mar 17 10:08:13 PDT 2011


---
 include/glu3.h        |    7 +++++++
 include/glu3_scalar.h |    9 +++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/include/glu3.h b/include/glu3.h
index 210f713..5679812 100644
--- a/include/glu3.h
+++ b/include/glu3.h
@@ -120,6 +120,13 @@ struct GLUvec4 {
 	 */
 	GLUvec4 operator *(GLfloat) const;
 
+	/**
+	 * Divide by a scalar.
+	 *
+	 * \sa gluDiv4v_f
+	 */
+	GLUvec4 operator /(GLfloat) const;
+
 	/** Component-wise addition with a vec4. */
 	GLUvec4 operator +(const GLUvec4 &) const;
 
diff --git a/include/glu3_scalar.h b/include/glu3_scalar.h
index 11107d5..4f7c289 100644
--- a/include/glu3_scalar.h
+++ b/include/glu3_scalar.h
@@ -339,6 +339,15 @@ INLINE GLUvec4 GLUvec4::operator*(GLfloat f) const
 }
 
 
+INLINE GLUvec4 GLUvec4::operator/(GLfloat f) const
+{
+	return GLUvec4(values[0] / f,
+		       values[1] / f,
+		       values[2] / f,
+		       values[3] / f);
+}
+
+
 INLINE GLUvec4 GLUvec4::operator*(const GLUmat4 &m) const
 {
 	return GLUvec4(gluDot4(*this, m.col[0]),
-- 
1.7.4.1



More information about the GLU3-devel mailing list