cameraaaaaaa -.-

This commit is contained in:
Stefan Dresselhaus
2014-01-04 23:47:07 +01:00
parent 6cc9177082
commit df9b37429c
3 changed files with 50 additions and 26 deletions

View File

@ -128,23 +128,24 @@ infixl 5 ><
_ >< _ = error "non-conformat matrix-multiplication"
-- from vmath.h
lookAt :: V3 CFloat -> V3 CFloat -> V3 CFloat -> M44 CFloat
lookAt at eye@(V3 ex ey ez) up =
lookAt eye@(V3 ex ey ez) center up =
V4
(V4 xx yx zx 0)
(V4 xy yy zy 0)
(V4 xz yz zz 0)
(V4 xx yx (-zx) 0)
(V4 xy yy (-zy) 0)
(V4 xz yz (-zz) 0)
(V4 0 0 0 1)
!*!
!*!
V4
(V4 1 0 0 (-ex))
(V4 0 1 0 (-ey))
(V4 0 0 1 (-ez))
(V4 0 0 0 1)
where
z@(V3 zx zy zz) = normalize (eye ^-^ at)
x@(V3 xx xy xz) = normalize (cross up z)
y@(V3 yx yy yz) = cross z x
z@(V3 zx zy zz) = normalize (center ^-^ eye)
x@(V3 xx xy xz) = cross z (normalize up)
y@(V3 yx yy yz) = cross x z
-- generates 4x4-Projection-Matrix
lookAt_ :: (Double, Double, Double) -> (Double, Double, Double) -> (Double, Double, Double) -> [GLfloat]

View File

@ -7,12 +7,13 @@ import Foreign.Storable (sizeOf)
import Graphics.Rendering.OpenGL.GL.BufferObjects
import Graphics.Rendering.OpenGL.GL.Framebuffer (clearColor)
import Graphics.Rendering.OpenGL.GL.ObjectName
import Graphics.Rendering.OpenGL.GL.PerFragment
import Graphics.Rendering.OpenGL.GL.Shaders
import Graphics.Rendering.OpenGL.GL.StateVar
import Graphics.Rendering.OpenGL.GL.VertexArrays (Capability (..),
vertexAttribArray)
import Graphics.Rendering.OpenGL.GL.VertexSpec
import Graphics.Rendering.OpenGL.Raw.Core31.Types (GLfloat)
import Graphics.Rendering.OpenGL.Raw.Core31
import Render.Misc
vertexShaderFile :: String
@ -75,4 +76,6 @@ initShader = do
initRendering :: IO ()
initRendering = do
clearColor $= Color4 0 0 0 0
depthFunc $= Just Less
glCullFace gl_BACK
checkError "initRendering"