subroutines perpec and lookat

Gary Tarolli tarolli at dragon.wpd.sgi.com
Wed Jun 28 07:54:56 AEST 1989


In article <8906250011.AA04052 at prism>, ccsupos%prism at GATECH.EDU writes:
> Hi, I am using the subroutines "perspective" and "lookat" on
> IRIS 4D120GTX. I did not think I needed to push or pop matrices
> in order just change the projection, viewpoint and the point that is
> looked at. However, I cannot get the routines to work correctly
> so I am wondering if I did not miss something. I would appreciate
> any help on this as the user's guide is not very detailed.
> Olivier Schreiber

I cannot guess why your program does not work, I can only help clarify
what perspective and lookat do.  Perspective loads a matrix onto the
matrix stack, destroying what was previously on top of the stack.
Lookat multiplies a "lookat" matrix by the top of the stack and replaces
the top of the stack with the result.  Check the GL User's Guide to see
the exact matrices that perspective and lookat generate.

In general, you probably want to use perspective and lookat together,
doing a perspective without a lookat or a lookat without a perspective
is probably a bug.  However, it is quite normal to load a perspective
matrix, push it, and then apply a lookat.  To apply a new lookat,
do a popmatrix (gets back to the perspetive) do a pushmatrix (copies it
on the stack) and then do another lookat.

Hope this clears things up.  To aid in debugging, write a routine to print
a matrix out to the terminal, then call getmatrix and print the matrix out
when things go awry.



More information about the Comp.sys.sgi mailing list