cleaned up
This commit is contained in:
parent
9c33af543c
commit
c2dc6e28f1
@ -368,6 +368,17 @@ render = do
|
|||||||
projmo = shdrMOProjMatIndex dmo
|
projmo = shdrMOProjMatIndex dmo
|
||||||
nmatmo = shdrMONormalMatIndex dmo
|
nmatmo = shdrMONormalMatIndex dmo
|
||||||
vmatmo = shdrMOViewMatIndex dmo
|
vmatmo = shdrMOViewMatIndex dmo
|
||||||
|
suncam = getCam camPos 1 0.7 0 --TODO: Fix position of sun
|
||||||
|
sunnormal' = (case L.inv33 (fmap (^. L._xyz) suncam ^. L._xyz) of
|
||||||
|
(Just a) -> a
|
||||||
|
Nothing -> L.eye3) :: L.M33 CFloat
|
||||||
|
sunnmap = collect id sunnormal' :: L.M33 CFloat --transpose...
|
||||||
|
cam' = getCam camPos zDist' xa ya
|
||||||
|
normal' = (case L.inv33 (fmap (^. L._xyz) cam' ^. L._xyz) of
|
||||||
|
(Just a) -> a
|
||||||
|
Nothing -> L.eye3) :: L.M33 CFloat
|
||||||
|
nmap = collect id normal' :: L.M33 CFloat --transpose...
|
||||||
|
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
|
|
||||||
bindFramebuffer Framebuffer $= (state ^. gl.glFramebuffer)
|
bindFramebuffer Framebuffer $= (state ^. gl.glFramebuffer)
|
||||||
@ -399,20 +410,11 @@ render = do
|
|||||||
--set up projection (= copy from state)
|
--set up projection (= copy from state)
|
||||||
--TODO: Fix width/depth
|
--TODO: Fix width/depth
|
||||||
mat44ToGPU (createFrustumOrtho 20 20 0 100) proj "shadowmap-projection"
|
mat44ToGPU (createFrustumOrtho 20 20 0 100) proj "shadowmap-projection"
|
||||||
|
|
||||||
--set up camera
|
--set up camera
|
||||||
--TODO: Fix magic constants... and camPos
|
mat44ToGPU suncam vmat "shadowmap-cam"
|
||||||
let ! cam = getCam camPos 1 0.7 0
|
|
||||||
mat44ToGPU cam vmat "shadowmap-cam"
|
|
||||||
|
|
||||||
--set up normal--Mat transpose((model*camera)^-1)
|
--set up normal--Mat transpose((model*camera)^-1)
|
||||||
--needed?
|
--TODO: needed?
|
||||||
let normal' = (case L.inv33 (fmap (^. L._xyz) cam ^. L._xyz) of
|
mat33ToGPU sunnmap nmat "nmat"
|
||||||
(Just a) -> a
|
|
||||||
Nothing -> L.eye3) :: L.M33 CFloat
|
|
||||||
nmap = collect id normal' :: L.M33 CFloat --transpose...
|
|
||||||
|
|
||||||
mat33ToGPU nmap nmat "nmat"
|
|
||||||
|
|
||||||
drawMap
|
drawMap
|
||||||
|
|
||||||
@ -427,17 +429,11 @@ render = do
|
|||||||
|
|
||||||
--set up camera
|
--set up camera
|
||||||
--TODO: Fix magic constants... and camPos
|
--TODO: Fix magic constants... and camPos
|
||||||
let ! cam = getCam camPos 1 0.7 0
|
mat44ToGPU suncam vmatmo "shadowmap-camera"
|
||||||
mat44ToGPU cam vmatmo "shadowmap-camera"
|
|
||||||
|
|
||||||
--set up normal--Mat transpose((model*camera)^-1)
|
--set up normal--Mat transpose((model*camera)^-1)
|
||||||
--needed?
|
--needed?
|
||||||
let normal' = (case L.inv33 (fmap (^. L._xyz) cam ^. L._xyz) of
|
mat33ToGPU sunnmap nmatmo "nmat"
|
||||||
(Just a) -> a
|
|
||||||
Nothing -> L.eye3) :: L.M33 CFloat
|
|
||||||
nmap = collect id normal' :: L.M33 CFloat --transpose...
|
|
||||||
|
|
||||||
mat33ToGPU nmap nmatmo "nmat"
|
|
||||||
|
|
||||||
mapM_ renderObject (state ^. gl.glMap.mapObjects)
|
mapM_ renderObject (state ^. gl.glMap.mapObjects)
|
||||||
checkError "draw mapobjects"
|
checkError "draw mapobjects"
|
||||||
@ -461,41 +457,25 @@ render = do
|
|||||||
clear [ColorBuffer, DepthBuffer]
|
clear [ColorBuffer, DepthBuffer]
|
||||||
checkError "clear buffer"
|
checkError "clear buffer"
|
||||||
|
|
||||||
|
|
||||||
currentProgram $= Just (state ^. gl.glMap.mapProgram)
|
currentProgram $= Just (state ^. gl.glMap.mapProgram)
|
||||||
|
|
||||||
checkError "setting up buffer"
|
checkError "setting up buffer"
|
||||||
--set up projection (= copy from state)
|
--set up projection (= copy from state)
|
||||||
mat44ToGPU frust proj "projection"
|
mat44ToGPU frust proj "projection"
|
||||||
|
|
||||||
--set up camera
|
--set up camera
|
||||||
let ! cam = getCam camPos zDist' xa ya
|
mat44ToGPU cam' vmat "camera"
|
||||||
mat44ToGPU cam vmat "camera"
|
|
||||||
|
|
||||||
--set up normal--Mat transpose((model*camera)^-1)
|
--set up normal--Mat transpose((model*camera)^-1)
|
||||||
let normal' = (case L.inv33 (fmap (^. L._xyz) cam ^. L._xyz) of
|
|
||||||
(Just a) -> a
|
|
||||||
Nothing -> L.eye3) :: L.M33 CFloat
|
|
||||||
nmap = collect id normal' :: L.M33 CFloat --transpose...
|
|
||||||
|
|
||||||
mat33ToGPU nmap nmat "nmat"
|
mat33ToGPU nmap nmat "nmat"
|
||||||
|
|
||||||
drawMap --draw map -> put to another function for readability
|
drawMap
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
---- RENDER MAPOBJECTS --------------------------------------------
|
---- RENDER MAPOBJECTS --------------------------------------------
|
||||||
currentProgram $= Just (state ^. gl.glMap.objectProgram)
|
currentProgram $= Just (state ^. gl.glMap.objectProgram)
|
||||||
checkError "setting up shadowmap-program"
|
checkError "setting up shadowmap-program"
|
||||||
|
|
||||||
--set up projection (= copy from state)
|
--set up projection (= copy from state)
|
||||||
mat44ToGPU frust projmo "mapObjects-projection"
|
mat44ToGPU frust projmo "mapObjects-projection"
|
||||||
--set up camera
|
--set up camera
|
||||||
let ! cam = getCam camPos zDist' xa ya
|
mat44ToGPU cam' vmatmo "mapObjects-cam"
|
||||||
mat44ToGPU cam vmatmo "mapObjects-cam"
|
|
||||||
--set up normal
|
--set up normal
|
||||||
let normal' = (case L.inv33 (fmap (^. L._xyz) cam ^. L._xyz) of
|
|
||||||
(Just a) -> a
|
|
||||||
Nothing -> L.eye3) :: L.M33 CFloat
|
|
||||||
nmap = collect id normal' :: L.M33 CFloat --transpose...
|
|
||||||
mat33ToGPU nmap nmatmo "mapObjects-nmat"
|
mat33ToGPU nmap nmatmo "mapObjects-nmat"
|
||||||
|
|
||||||
mapM_ renderObject (state ^. gl.glMap.mapObjects)
|
mapM_ renderObject (state ^. gl.glMap.mapObjects)
|
||||||
@ -529,11 +509,3 @@ render = do
|
|||||||
bindBuffer ElementArrayBuffer $= Just (hud ^. hudEBO)
|
bindBuffer ElementArrayBuffer $= Just (hud ^. hudEBO)
|
||||||
drawElements TriangleStrip 4 UnsignedInt offset0
|
drawElements TriangleStrip 4 UnsignedInt offset0
|
||||||
|
|
||||||
|
|
||||||
{-let winRenderer = env ^. renderer
|
|
||||||
tryWithTexture
|
|
||||||
(state ^. hudTexture) --maybe tex
|
|
||||||
(\tex -> renderCopy winRenderer tex Nothing Nothing) --function with "hole"
|
|
||||||
--Nothing == whole source-tex, whole dest-tex
|
|
||||||
(return ()) --fail-case-}
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user