new projection
This commit is contained in:
parent
33b1ec5534
commit
42e7bd65ac
@ -25,5 +25,6 @@ executable Pioneers
|
|||||||
pretty >=1.1,
|
pretty >=1.1,
|
||||||
transformers >=0.3.0 && <0.4,
|
transformers >=0.3.0 && <0.4,
|
||||||
mtl >=2.1.2,
|
mtl >=2.1.2,
|
||||||
stm >=2.4.2
|
stm >=2.4.2,
|
||||||
|
vector >=0.10.9 && <0.11
|
||||||
|
|
||||||
|
17
src/Main.hs
17
src/Main.hs
@ -11,7 +11,9 @@ import Data.Maybe (catMaybes)
|
|||||||
import Text.PrettyPrint
|
import Text.PrettyPrint
|
||||||
|
|
||||||
import qualified Graphics.Rendering.OpenGL.GL as GL
|
import qualified Graphics.Rendering.OpenGL.GL as GL
|
||||||
|
import qualified Graphics.Rendering.OpenGL.Raw as GL
|
||||||
import qualified Graphics.UI.GLFW as GLFW
|
import qualified Graphics.UI.GLFW as GLFW
|
||||||
|
import qualified Data.Vector.Storable as V
|
||||||
|
|
||||||
import Map.Map
|
import Map.Map
|
||||||
import Render.Render (initShader)
|
import Render.Render (initShader)
|
||||||
@ -215,9 +217,7 @@ run = do
|
|||||||
draw
|
draw
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
GLFW.swapBuffers win
|
GLFW.swapBuffers win
|
||||||
GL.flush -- not necessary, but someone recommended it
|
|
||||||
GLFW.pollEvents
|
GLFW.pollEvents
|
||||||
GL.finish
|
|
||||||
-- getEvents & process
|
-- getEvents & process
|
||||||
processEvents
|
processEvents
|
||||||
|
|
||||||
@ -379,7 +379,18 @@ draw = do
|
|||||||
map' = stateMap state
|
map' = stateMap state
|
||||||
frust = stateFrustum state
|
frust = stateFrustum state
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
lookAtUniformMatrix4fv (0.0,0.0,0.0) (0, 15, 0) up frust proj 1
|
GL.clear [GL.ColorBuffer]
|
||||||
|
let fov = 90
|
||||||
|
s = recip (tan $ fov * 0.5 * pi / 180)
|
||||||
|
f = 1000
|
||||||
|
n = 1
|
||||||
|
|
||||||
|
let perspective = V.fromList [ s, 0, 0, 0
|
||||||
|
, 0, s, 0, 0
|
||||||
|
, 0, 0, -(f/(f - n)), -1
|
||||||
|
, 0, 0, -((f*n)/(f-n)), 0
|
||||||
|
]
|
||||||
|
V.unsafeWith perspective $ \ptr -> GL.glUniformMatrix4fv proj 1 0 ptr
|
||||||
GL.bindBuffer GL.ArrayBuffer GL.$= Just map'
|
GL.bindBuffer GL.ArrayBuffer GL.$= Just map'
|
||||||
GL.vertexAttribPointer vi GL.$= fgVertexIndex
|
GL.vertexAttribPointer vi GL.$= fgVertexIndex
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user