ibis/src/Main.hs

51 lines
1.4 KiB
Haskell
Raw Normal View History

2019-01-29 22:55:45 +00:00
module Main where
import qualified SDL
2019-01-30 22:10:00 +00:00
import qualified SDL.Raw.Video as SDL (glSetAttribute)
import qualified SDL.Raw.Enum as SDL
2019-01-29 22:55:45 +00:00
import Linear
import Options.Applicative
2019-01-30 05:08:38 +00:00
import Control.Monad
2019-01-30 22:10:00 +00:00
import qualified Data.Text as T
2019-01-29 22:55:45 +00:00
-- internal imports
import Util
2019-01-30 22:10:00 +00:00
import Types
2019-01-29 22:55:45 +00:00
main :: IO ()
main = do
opts <- execParser $ info (options <**> helper)
( fullDesc
<> progDesc "A simple PDF presenter written in Haskell using poppler and SDL2"
)
SDL.initializeAll
SDL.screenSaverEnabled SDL.$= False
disps <- SDL.getDisplays
2019-01-30 05:08:38 +00:00
putStrLn ("Number of displays detected: " ++ show (length disps))
2019-01-29 22:55:45 +00:00
putStrLn ("Passed command line options: " ++ show opts)
2019-01-30 05:08:38 +00:00
-- set Render quality
2019-01-30 22:10:00 +00:00
SDL.HintRenderScaleQuality SDL.$= SDL.ScaleLinear
2019-01-30 05:08:38 +00:00
-- check render quality
renderQuality <- SDL.get SDL.HintRenderScaleQuality
2019-01-30 22:10:00 +00:00
when (renderQuality /= SDL.ScaleLinear) $
2019-01-30 05:08:38 +00:00
putErrLn "Linear texture filtering not enabled!"
putStrLn "Creating window(s)"
2019-01-30 22:10:00 +00:00
wins <- zip ([0 .. ] :: [Word]) <$> mapM (uncurry SDL.createWindow) (
zip
[ "Ibis - " <> optFile opts
, "Ibis - " <> optFile opts <> " - Notes"
2019-01-30 05:08:38 +00:00
]
2019-01-30 22:10:00 +00:00
(map makeWindowConfig disps)
)
when (optFullscreen opts) $
mapM_ (flip SDL.setWindowMode SDL.FullscreenDesktop . snd) wins
void $ SDL.glSetAttribute SDL.SDL_GL_SHARE_WITH_CURRENT_CONTEXT 1
contexts <- zip (map fst wins) <$> mapM (SDL.glCreateContext . snd) wins
mapM_ (SDL.showWindow . snd) wins