Merge branch 'tessallation'
This commit is contained in:
		
							
								
								
									
										30
									
								
								src/Main.hs
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								src/Main.hs
									
									
									
									
									
								
							@@ -27,7 +27,7 @@ import           Foreign.Marshal.Alloc                (allocaBytes)
 | 
				
			|||||||
import           Control.Lens                         ((^.), (.~), (%~))
 | 
					import           Control.Lens                         ((^.), (.~), (%~))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- GUI
 | 
					-- GUI
 | 
				
			||||||
import           Graphics.UI.SDL                      as SDL
 | 
					import qualified Graphics.UI.SDL                      as SDL
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Render
 | 
					-- Render
 | 
				
			||||||
import qualified Graphics.Rendering.OpenGL.GL         as GL
 | 
					import qualified Graphics.Rendering.OpenGL.GL         as GL
 | 
				
			||||||
@@ -65,15 +65,15 @@ testParser a = putStrLn . show  =<< parseIQM a
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
main :: IO ()
 | 
					main :: IO ()
 | 
				
			||||||
main =
 | 
					main =
 | 
				
			||||||
    SDL.withInit [InitVideo, InitAudio, InitEvents, InitTimer] $ --also: InitNoParachute -> faster, without parachute!
 | 
					    SDL.withInit [SDL.InitVideo, SDL.InitAudio, SDL.InitEvents, SDL.InitTimer] $ --also: InitNoParachute -> faster, without parachute!
 | 
				
			||||||
      SDL.withWindow "Pioneers" (SDL.Position 100 100) (Size 1024 600) [WindowOpengl     -- we want openGL
 | 
					      SDL.withWindow "Pioneers" (SDL.Position 100 100) (SDL.Size 1024 600) [SDL.WindowOpengl     -- we want openGL
 | 
				
			||||||
                                                                             ,WindowShown      -- window should be visible
 | 
					                                                                             ,SDL.WindowShown      -- window should be visible
 | 
				
			||||||
                                                                             ,WindowResizable  -- and resizable
 | 
					                                                                             ,SDL.WindowResizable  -- and resizable
 | 
				
			||||||
                                                                             ,WindowInputFocus -- focused (=> active)
 | 
					                                                                             ,SDL.WindowInputFocus -- focused (=> active)
 | 
				
			||||||
                                                                             ,WindowMouseFocus -- Mouse into it
 | 
					                                                                             ,SDL.WindowMouseFocus -- Mouse into it
 | 
				
			||||||
                                                                             --,WindowInputGrabbed-- never let go of input (KB/Mouse)
 | 
					                                                                             --,WindowInputGrabbed-- never let go of input (KB/Mouse)
 | 
				
			||||||
                                                                             ] $ \window' -> do
 | 
					                                                                             ] $ \window' -> do
 | 
				
			||||||
       withOpenGL window' $ do
 | 
					       SDL.withOpenGL window' $ do
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        --Create Renderbuffer & Framebuffer
 | 
					        --Create Renderbuffer & Framebuffer
 | 
				
			||||||
        -- We will render to this buffer to copy the result into textures
 | 
					        -- We will render to this buffer to copy the result into textures
 | 
				
			||||||
@@ -82,12 +82,12 @@ main =
 | 
				
			|||||||
        GL.bindFramebuffer GL.Framebuffer GL.$= frameBuffer
 | 
					        GL.bindFramebuffer GL.Framebuffer GL.$= frameBuffer
 | 
				
			||||||
        GL.bindRenderbuffer GL.Renderbuffer GL.$= renderBuffer
 | 
					        GL.bindRenderbuffer GL.Renderbuffer GL.$= renderBuffer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        (Size fbWidth fbHeight) <- glGetDrawableSize window'
 | 
					        (SDL.Size fbWidth fbHeight) <- SDL.glGetDrawableSize window'
 | 
				
			||||||
        initRendering
 | 
					        initRendering
 | 
				
			||||||
        --generate map vertices
 | 
					        --generate map vertices
 | 
				
			||||||
        glMap' <- initMapShader 4 =<< getMapBufferObject
 | 
					        glMap' <- initMapShader 4 =<< getMapBufferObject
 | 
				
			||||||
        print window'
 | 
					        print window'
 | 
				
			||||||
        eventQueue <- newTQueueIO :: IO (TQueue Event)
 | 
					        eventQueue <- newTQueueIO :: IO (TQueue SDL.Event)
 | 
				
			||||||
        putStrLn "foo"
 | 
					        putStrLn "foo"
 | 
				
			||||||
        now <- getCurrentTime
 | 
					        now <- getCurrentTime
 | 
				
			||||||
        putStrLn "foo"
 | 
					        putStrLn "foo"
 | 
				
			||||||
@@ -181,7 +181,7 @@ run = do
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    -- draw Scene
 | 
					    -- draw Scene
 | 
				
			||||||
    draw
 | 
					    draw
 | 
				
			||||||
    liftIO $ glSwapWindow (env ^. windowObject)
 | 
					    liftIO $ SDL.glSwapWindow (env ^. windowObject)
 | 
				
			||||||
    -- getEvents & process
 | 
					    -- getEvents & process
 | 
				
			||||||
    processEvents
 | 
					    processEvents
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -237,7 +237,7 @@ run = do
 | 
				
			|||||||
        now <- getCurrentTime
 | 
					        now <- getCurrentTime
 | 
				
			||||||
        let diff  = diffUTCTime now (state ^. io.clock) -- get time-diffs
 | 
					        let diff  = diffUTCTime now (state ^. io.clock) -- get time-diffs
 | 
				
			||||||
            title = unwords ["Pioneers @ ",show ((round . double $ 1.0/diff)::Int),"fps"]
 | 
					            title = unwords ["Pioneers @ ",show ((round . double $ 1.0/diff)::Int),"fps"]
 | 
				
			||||||
        setWindowTitle (env ^. windowObject) title
 | 
					        SDL.setWindowTitle (env ^. windowObject) title
 | 
				
			||||||
        let 	sleepAmount = floor ((targetFrametime - double diff)*1000000) :: Int -- get time until next frame in microseconds
 | 
					        let 	sleepAmount = floor ((targetFrametime - double diff)*1000000) :: Int -- get time until next frame in microseconds
 | 
				
			||||||
                clockFactor = (state ^. io.tessClockFactor)
 | 
					                clockFactor = (state ^. io.tessClockFactor)
 | 
				
			||||||
		tessChange
 | 
							tessChange
 | 
				
			||||||
@@ -327,14 +327,14 @@ adjustWindow = do
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
processEvents :: Pioneers ()
 | 
					processEvents :: Pioneers ()
 | 
				
			||||||
processEvents = do
 | 
					processEvents = do
 | 
				
			||||||
    me <- liftIO pollEvent
 | 
					    me <- liftIO SDL.pollEvent
 | 
				
			||||||
    case me of
 | 
					    case me of
 | 
				
			||||||
      Just e -> do
 | 
					      Just e -> do
 | 
				
			||||||
          processEvent e
 | 
					          processEvent e
 | 
				
			||||||
          processEvents
 | 
					          processEvents
 | 
				
			||||||
      Nothing -> return ()
 | 
					      Nothing -> return ()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
processEvent :: Event -> Pioneers ()
 | 
					processEvent :: SDL.Event -> Pioneers ()
 | 
				
			||||||
processEvent e = do
 | 
					processEvent e = do
 | 
				
			||||||
    eventCallback e
 | 
					    eventCallback e
 | 
				
			||||||
    -- env <- ask
 | 
					    -- env <- ask
 | 
				
			||||||
@@ -343,7 +343,7 @@ processEvent e = do
 | 
				
			|||||||
            case winEvent of
 | 
					            case winEvent of
 | 
				
			||||||
                SDL.Closing ->
 | 
					                SDL.Closing ->
 | 
				
			||||||
                        modify $ window.shouldClose .~ True
 | 
					                        modify $ window.shouldClose .~ True
 | 
				
			||||||
                SDL.Resized {windowResizedTo=size} -> do
 | 
					                SDL.Resized {SDL.windowResizedTo=size} -> do
 | 
				
			||||||
                        modify $ (window . width .~ SDL.sizeWidth size)
 | 
					                        modify $ (window . width .~ SDL.sizeWidth size)
 | 
				
			||||||
                               . (window . height .~ SDL.sizeHeight size)
 | 
					                               . (window . height .~ SDL.sizeHeight size)
 | 
				
			||||||
                        adjustWindow
 | 
					                        adjustWindow
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user