You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both OpenGL's old matrix model and GLM provide matrix stacks. I think this is worthing putting in a new package. A Matrix stack is, in essence, a fully-persistent data structure that keeps track of matrix mutations and allows you to roll back and arbitrary number of operations. This is extremely useful for, e.g., scenegraphs.. A sketch of push, for instance:
type MatrixStack []Mat4
func (ms *MatrixStack) Push(m Mat4) error {
if len(*ms) == 0 {
return errors.New("Matrix stack is empty, create a new stack or use MatrixStack.Load to add the first matrix")
}
prev := (*ms)[len(*ms)-1]
(*ms) = append(*ms, prev.Mul4(m))
return nil
}
The biggest question is whether the stack should be Mat4 only (I believe OpenGL took this approach?) or whether there should be support for Mat3 and Mat2 as well. I suspect the basic (push/pop/peek/load) implementation will be fewer than 200 lines per matrix type, so it may be worth just doing all 3.
The text was updated successfully, but these errors were encountered:
I'll note that I somehow got off my gourd and totally misremembered how the matrix stack works. The previous implementation has been named the TransformStack, and the new MatrixStack should work like GL's which is an explicit state COPYING stack.
Both OpenGL's old matrix model and GLM provide matrix stacks. I think this is worthing putting in a new package. A Matrix stack is, in essence, a fully-persistent data structure that keeps track of matrix mutations and allows you to roll back and arbitrary number of operations. This is extremely useful for, e.g., scenegraphs.. A sketch of push, for instance:
The biggest question is whether the stack should be Mat4 only (I believe OpenGL took this approach?) or whether there should be support for Mat3 and Mat2 as well. I suspect the basic (push/pop/peek/load) implementation will be fewer than 200 lines per matrix type, so it may be worth just doing all 3.
The text was updated successfully, but these errors were encountered: