Haskell和GtkGL - LookAt和Rotation

时间:2014-10-09 04:43:31

标签: opengl haskell gtk gtk2hs

我正在查看GtkGL教程here,我正在做一些修改。具体来说,当我引入轮换时:

Gtk.timeoutAddFull (do
      preservingMatrix $ do -- from here
        matrixMode $= Modelview 0
        rotate 10 (Vector3 0.0 1.0 (0.0 :: GLfloat)) -- to here
      Gtk.widgetQueueDraw canvas
      return True)
    Gtk.priorityDefaultIdle animationWaitTime

很好用。但是,当我在显示功能中引入lookAt时:

display = do
  loadIdentity
  color (Color3 1 1 1 :: Color3 GLfloat)

  renderPrimitive Polygon $ do
    vertex (Vertex3 0.0 0.0 0.0 :: Vertex3 GLfloat)
    vertex (Vertex3 1.0 0.0 0.0 :: Vertex3 GLfloat)
    vertex (Vertex3 1.0 1.0 0.0 :: Vertex3 GLfloat)
    vertex (Vertex3 0.0 1.0 0.0 :: Vertex3 GLfloat)

  preservingMatrix $ do -- from here
    matrixMode $= Modelview 0
    loadIdentity
    lookAt (Vertex3 0 1 0) (Vertex3 1 1 0) (Vector3 0 1 0) -- to here
  flush

相机改变其位置,但不会发生旋转。

0 个答案:

没有答案