[glu3-devel] Matrix stack

Ian Romanick idr at freedesktop.org
Mon Apr 19 10:57:06 PDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ian Romanick wrote:
> Thanks to the thread on Phoronix[1], I was reminded about the matrix
> stack implementation.  In glu3.h there is a structure definition for
> GLUmat4Stack, but there is no supporting code.  I put this in as a
> placeholder back in the early days of GLU3 thinking that I would come
> back to it eventually.  There are a couple issues that I never resolved,
> and these prevented me from finishing the implementation.
> 
> In "classic" OpenGL, the matrix stack was the only way to operate on
> matrices.  Performing an operation on a matrix and performing an
> operation on the top of a matrix stack looked the same to the
> application developer.  I want to do the same with the GLU3 matrix
> stack, but I'm not sure how to do that.  Specifically, I want someone to
> be able to take code written to use a GLUmat4 and convert it to using a
> GLUmat4Stack by just changing the types and vice versa.
> 
> Also in "classic" OpenGL the matrix stack has a fixed size.  I always
> had mixed feelings about that.  On the one hand you don't really want
> the matrix stack to grow without bound.  That's almost always a sign of
> an application bug.  On the flip side, whatever bound is chosen is going
> to be insufficient for some legitimate use and will waste memory for
> some other legitimate use.
> 
> Thoughts or opinions?
> 
> 1: http://www.phoronix.com/forums/showthread.php?t=22289

I've pushed some code to a GLUmat4Stack branch.  The C++ interface is
below.  I think this achieves most of my goals, but writing code like
'ms.top() = projection_matrix * view_matrix * ms.top()' seems weird.

struct GLUmat4Stack {
	struct GLUmat4 stack[GLU_MAX_STACK_DEPTH];
	unsigned size;

	GLUmat4Stack();

	void push();
	void pop();

	GLUmat4 &top();
	const GLUmat4 &top() const;
};

I'll probably merge this pretty soon.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkvMmXAACgkQX1gOwKyEAw8QKgCcDbthb5EpmErJ1jheOqAMl4Gt
YNYAnixscM+T0GCNJM0c10sm3BFB8lqK
=HKDM
-----END PGP SIGNATURE-----


More information about the GLU3-devel mailing list