Lisp HUG Maillist Archive

RE: openGL question

RE: openGL question

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))
>

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))
> >
>


Updated at: 2020-12-10 08:57 UTC