RE: openGL question
From
The OpenGL (tm) Graphics System Utility Library"
Norman Chin
Chris Frazier
Paul Ho
Zicheng Liu
Kevin P. Smith
Silicon Graphics
Copyright © 1992-1997 Silicon Graphics, Inc.
"gluLookAt creates a commonly-used viewing matrix:
void gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez,
GLdouble centerx, GLdouble centery, GLdouble centerz,
GLdouble upx, GLdouble upy, GLdouble upz);
The viewing matrix created is based on an eye point (eyex, eyey, eyez), a reference
point that represents the center of the scene (centerx, centery, centerz), and an up
vector (upx, upy, upz). The matrix is designed to map the center of the scene to the
negative Z axis, so that when a typical projection matrix is used, the center of the
scene will map to the center of the viewport. Similarly, the projection of the up
vector on the viewing plane is mapped to the positive Y axis so that it will point
upward in the viewport. The up vector must not be parallel to the line-of-sight
from the eye to the center of the scene."
These document is available on the WEB (the OpenGl spec also). IIRC there are also
some good tutorials out there.
Hth
AHz
P.S: Sorry me for being so short - i'm currently very busy.
A.
>-----Original Message-----
>From: Andrew Shilliday [mailto:shilla@rpi.edu]
>Sent: Thursday, March 18, 2004 4:43 PM
>To: lisp-hug@xanalys.com
>Subject: Re: openGL question
>
>
>Thanks, I just didn't understand exactly how glu-look-at works.
>
>Andreas Hinze wrote:
>
>> Try this (look for the <== to see the changes).
>> Hth
>> AHz
>>
>> (defun redisplay-canvas (canvas &rest ignore)
>> (opengl:rendering-on (canvas)
>> (opengl:gl-clear opengl:*gl-color-buffer-bit*)
>> (opengl:gl-load-identity)
>> (opengl:glu-look-at 0.0 0.0 5.0 ;0.0 <==
>looking in the
>> right direction is helpful
>> 0.0 0.0 0.0
>> 0.0 1.0 0.0)
>> (opengl:gl-begin opengl:*gl-triangles*)
>> (opengl:gl-vertex3-f 0.0 1.0 0.0)
>> (opengl:gl-vertex3-f -1.0 0.0 0.0)
>> (opengl:gl-vertex3-f 1.0 0.0 0.0)
>> (opengl:gl-end)
>> (opengl:gl-flush) ; <== Forcing
>the data to
>> be drawn
>> (opengl:swap-buffers canvas)))
>>
>>
>> >-----Original Message-----
>> >From: Andrew Shilliday [mailto:shilla@rpi.edu]
>> >Sent: Thursday, March 18, 2004 4:02 PM
>> >To: lisp-hug@xanalys.com
>> >Subject: Re: openGL question
>> >
>> >
>> >Uh, I noticed that I forgot to put (opengl:rendering-on... in the
>> >display function. Ignore that, putting it in would get you to
>> >the point
>> >where I have the problem. Here's the modified code, still with the
>> >problem of not displaying the triangle.
>> >
>> >(capi:define-interface opengl-interface () ()
>> > (:panes
>> > (canvas capi:opengl-pane
>> > :configuration (list :rgba t :depth t :double-buffered t)
>> > :min-width 400
>> > :min-height 400
>> > :display-callback 'redisplay-canvas
>> > :resize-callback 'resize-canvas
>> > :reader canvas)))
>> >
>> >(defun resize-canvas (canvas x y width height)
>> > (declare (ignore x y))
>> > (opengl:rendering-on (canvas)
>> > (when (zerop height) (setf height 1))
>> > (opengl:gl-viewport 0 0 width height)
>> > (opengl:gl-matrix-mode opengl:*gl-projection*)
>> > (opengl:gl-load-identity)
>> > (opengl:glu-perspective 45.0d0 1d0 1d0 100d0)
>> > (opengl:gl-matrix-mode opengl:*gl-modelview*)
>> > (opengl:gl-load-identity)))
>> >
>> >(defun redisplay-canvas (canvas &rest ignore)
>> > (opengl:rendering-on (canvas)
>> > (opengl:gl-clear opengl:*gl-color-buffer-bit*)
>> > (opengl:gl-load-identity)
>> > (opengl:glu-look-at 0.0 5.0 0.0
>> > 0.0 0.0 0.0
>> > 0.0 1.0 0.0)
>> > (opengl:gl-begin opengl:*gl-triangles*)
>> > (opengl:gl-vertex3-f 0.0 1.0 0.0)
>> > (opengl:gl-vertex3-f -1.0 0.0 0.0)
>> > (opengl:gl-vertex3-f 1.0 0.0 0.0)
>> > (opengl:gl-end)
>> > (opengl:swap-buffers canvas)))
>> >
>> >(capi:display (make-instance 'opengl-interface))
>> >
>>
>