Can't find equivalent for GLTOOLs library PopMatrix() and PushMatrix() functions

Started by OverBlob, September 04, 2012, 17:24:20

Previous topic - Next topic

OverBlob

Hello,

As the glPushMatrix() and the glPopMatrix() functions are now deprecated in the OpenGl compatibility profile(confer OpenGL superbible 5th edition), I tried to search equivalent of:

-void GLMatrixStack::PopMatrix(void);
-void GLMatrixStack::PushMatrix(void);

of the C++ GLTOOLs library in LWJGL library, but I didn't find it in the supposed most appropriated location (ie:org.lwjgl.util.vector package).

Could you please help me know how should I do to make matrix stacks? :)

ra4king

As GLTOOLS isn't part of OpenGL, it has no business being in LWJGL. You are supposed to implement your own matrix stack. LWJGL provides a Matrix4f in its util.vector package, and it's up to you to implement push and pop :)

Here's a basic implementation:
import java.util.Stack;
import org.lwjgl.util.vector.Matrix4f;

public class MatrixStack {
	private Stack<Matrix4f> stack;
	private Matrix4f current;
	
	public MatrixStack() {
		current = new Matrix4f();
		stack = new Stack<Matrix4f>();
	}
	
	public Matrix4f getTop() {
		return current;
	}
	
	public void setTop(Matrix4f m) {
		current = m;
	}
	
	public void pushMatrix() {
		stack.push(current);
		current = new Matrix4f(current);
	}
	
	public void popMatrix() {
		current = stack.pop();
	}
}
-Roi