summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <idr@freedesktop.org>2010-04-19 10:27:28 -0700
committerIan Romanick <idr@freedesktop.org>2010-04-19 10:27:28 -0700
commite18c0d3dccd4369dc4498666f98e4a0b097db7f5 (patch)
tree74e4ec1a6d5a41f0d723d0e5fd604c09dbb58538
parent8a3f0d7052bb1d86379a6f9ccc132207d32d057f (diff)
Change the way the top of the matrix stack is accessedGLUmat4Stack
I don't really like this method either, but it's much better than the goofy cast mechanism.
-rw-r--r--include/glu3.h20
-rw-r--r--test/mat4stack-01.cpp5
2 files changed, 18 insertions, 7 deletions
diff --git a/include/glu3.h b/include/glu3.h
index 6730318..f9b98c0 100644
--- a/include/glu3.h
+++ b/include/glu3.h
@@ -238,23 +238,27 @@ struct GLUmat4Stack {
void pop();
/**
- * Cast a matrix stack to a matrix
+ * Access top of matrix stack as a matrix
*
* This allows existing matrix operations to be performed on the
* top of the matrix stack.
+ *
+ * \sa GLU_MATRIX_STACK_TOP
*/
- GLUmat4 &operator() ()
+ GLUmat4 &top()
{
return stack[0];
}
/**
- * Cast a constant matrix stack to a constant matrix
+ * Access top of matrix stack as a constant matrix
*
* This allows existing matrix operations to be performed on the
* top of the matrix stack.
+ *
+ * \sa GLU_MATRIX_STACK_TOP
*/
- const GLUmat4 &operator() () const
+ const GLUmat4 &top() const
{
return stack[0];
}
@@ -262,6 +266,14 @@ struct GLUmat4Stack {
};
+/**
+ * Get a pointer to the matrix at the top of a matrix stack
+ *
+ * \sa GLUmat4Stack::top (C++)
+ */
+#define GLU_MATRIX_STACK_TOP(s) (&(s)->stack[0])
+
+
struct GLUarcball {
/**
* Base location of the viewport.
diff --git a/test/mat4stack-01.cpp b/test/mat4stack-01.cpp
index 1734666..24e75ed 100644
--- a/test/mat4stack-01.cpp
+++ b/test/mat4stack-01.cpp
@@ -20,8 +20,7 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
-
-#include <glu3.h>
+#include "../include/glu3.h"
#include <cmath>
#include <cassert>
@@ -32,7 +31,7 @@ int main(int argc, char **argv)
GLUmat4Stack s;
- GLUmat4(s) = gluIdentityMatrix;
+ s.top() = gluIdentityMatrix;
s.push();
s.pop();