Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!ames!sgi!tarolli@dragon.wpd.sgi.com From: tarolli@dragon.wpd.sgi.com (Gary Tarolli) Newsgroups: comp.sys.sgi Subject: Re: subroutines perpec and lookat Summary: a little help Message-ID: <37007@sgi.SGI.COM> Date: 27 Jun 89 21:54:56 GMT References: <8906250011.AA04052@prism> Sender: daemon@sgi.SGI.COM Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 26 In article <8906250011.AA04052@prism>, ccsupos%prism@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.