Hi,
The first patch adds the missing homogenize, normalize and norm
functions to GLVector.
The second patch replaces "stdarg.h" and "stdio.h" with their c++
counterparts so that g++ 4.3 doesn't complain. This patch has a
debugging message in it though, feel free to remove it.
Regards,
Sam
--
Sam Spilsbury
From 7fdca40d8ca1d5a9e28405a189d3c95a454bc759 Mon Sep 17 00:00:00 2001
From: Sam Spilsbury <smspil...@xps-fedora.(none)>
Date: Thu, 23 Jul 2009 17:49:16 +0800
Subject: [PATCH 1/2] Add homogenize () normalize () norm () GLVector functions
---
plugins/opengl/include/opengl/vector.h | 1 +
plugins/opengl/src/vector.cpp | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/plugins/opengl/include/opengl/vector.h b/plugins/opengl/include/opengl/vector.h
index 19e2178..20176b7 100644
--- a/plugins/opengl/include/opengl/vector.h
+++ b/plugins/opengl/include/opengl/vector.h
@@ -52,6 +52,7 @@ class GLVector {
float norm ();
GLVector& normalize ();
+ GLVector& homogenize ();
private:
friend GLVector operator+ (const GLVector& lhs,
diff --git a/plugins/opengl/src/vector.cpp b/plugins/opengl/src/vector.cpp
index afb10d2..429f3d9 100644
--- a/plugins/opengl/src/vector.cpp
+++ b/plugins/opengl/src/vector.cpp
@@ -240,3 +240,35 @@ operator^ (const GLVector& lhs,
return result;
}
+
+float
+GLVector::norm ()
+{
+ if (v[3] != 0.0)
+ return 1.0;
+ return sqrt ((v[0] * v[0]) + (v[1] * v[1]) + (v[2] * v[2]));
+}
+
+GLVector &
+GLVector::normalize ()
+{
+ float normal = norm ();
+
+ /* Vector is not homogenous */
+ if (normal == 1.0)
+ return *this;
+
+ for (unsigned int i = 0; i < 3; i++)
+ v[i] /= normal;
+ return *this;
+}
+
+GLVector &
+GLVector::homogenize ()
+{
+ if (v[3] ==0)
+ return *this;
+
+ for (unsigned int i = 0; i < 4; i++)
+ v[i] /= v[3];
+}
--
1.6.2.5
From 3475cfde9f23ec343add85cf8f3005a6219565ed Mon Sep 17 00:00:00 2001
From: Sam Spilsbury <smspil...@xps-fedora.(none)>
Date: Thu, 23 Jul 2009 17:50:08 +0800
Subject: [PATCH 2/2] Include cstdio and others instead of their C counterparts in order to conform to g++ 4.3's stricter includes
---
include/compiz.h | 1 +
plugins/composite/src/screen.cpp | 2 ++
src/string.cpp | 3 ++-
3 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/include/compiz.h b/include/compiz.h
index 08acef4..ab1b5ca 100644
--- a/include/compiz.h
+++ b/include/compiz.h
@@ -30,6 +30,7 @@
#include <string>
#include <list>
+#include <cstdarg>
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY (x)
diff --git a/plugins/composite/src/screen.cpp b/plugins/composite/src/screen.cpp
index ca07a45..cf71205 100644
--- a/plugins/composite/src/screen.cpp
+++ b/plugins/composite/src/screen.cpp
@@ -254,6 +254,8 @@ CompositeScreen::CompositeScreen (CompScreen *s) :
setFailed ();
}
+ fprintf (stderr, "created this\n");
+
}
CompositeScreen::~CompositeScreen ()
diff --git a/src/string.cpp b/src/string.cpp
index 7ec0bec..898a89f 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -26,7 +26,8 @@
#include <compiz.h>
#include <string.h>
-#include <stdarg.h>
+#include <cstdarg>
+#include <cstdio>
CompString compPrintf (const char *format, ...)
{
--
1.6.2.5
_______________________________________________
Dev mailing list
[email protected]
http://lists.compiz-fusion.org/mailman/listinfo/dev