packages feed

sdl-try-drivers (empty) → 0.0.0.1

raw patch · 4 files changed

+87/−0 lines, 4 filesdep +basedep +pretty-simpledep +sdl2

Dependencies added: base, pretty-simple, sdl2, text

Files

+ LICENSE view
@@ -0,0 +1,9 @@+MIT License++Copyright (c) <year> <copyright holders>++Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Main.hs view
@@ -0,0 +1,48 @@+{-# LANGUAGE OverloadedStrings #-}+module Main where++import Foreign.C.Types (CInt)+import Control.Monad.IO.Class (MonadIO)+import Control.Exception (catch, SomeException)++import Text.Pretty.Simple (pPrintNoColor)+import SDL++myPPrint :: (Show a, MonadIO m) => a -> m ()+myPPrint = pPrintNoColor++checkRenderDriver :: Window -> (CInt, RendererInfo) -> IO ()+checkRenderDriver window driver = do+  maybeRenderer <- tryRenderDriver window driver+  case maybeRenderer of+    (Just renderer) -> destroyRenderer renderer+    Nothing -> return ()++tryRenderDriver :: Window -> (CInt, RendererInfo) -> IO (Maybe Renderer)+tryRenderDriver window (idx, info) = catch (do+        putStrLn "== trying driver:"+        myPPrint info+        -- if idx is given, defaultRenderer is ignored+        -- the documentation of the haskell packages sdl2 doesn't mention this+        -- but the sdl2 documentation itself does, see: https://wiki.libsdl.org/SDL_CreateRenderer+        renderer <- createRenderer window idx defaultRenderer+        putStrLn "** success"+        return (Just renderer))+        (\e -> do+                  putStrLn ("-- couldn't load driver number "  ++ show idx ++ ":")+                  myPPrint (e :: SomeException)+                  return Nothing)++checkRenderDrivers :: Window -> IO ()+checkRenderDrivers window = do+  drivers <- zip [0 ..] <$> getRenderDriverInfo+  putStrLn ("there are " ++ show (length drivers) ++ " drivers to check")+  mapM_ (checkRenderDriver window) drivers++main :: IO ()+main = do+  initializeAll+  window <- createWindow "sdl-try-drivers" defaultWindow {windowResizable = True}+  checkRenderDrivers window+  destroyWindow window+
+ README.md view
@@ -0,0 +1,4 @@+# sdl-try-drivers++For each reported driver sdl-try-drivers tries to create a renderer+and reports success or failure with the catched exception.
+ sdl-try-drivers.cabal view
@@ -0,0 +1,26 @@+name: sdl-try-drivers+author: Eric Wolf+version: 0.0.0.1+cabal-version: >=1.10+build-type: Simple+synopsis: small testing tool for sdl2 and accelerated drivers+license: MIT+license-file: LICENSE+category: graphics+maintainer: Eric Wolf <ericwolf42@gmail.com>+extra-source-files: README.md+description:+  For each reported driver sdl-try-drivers tries to create a renderer+  and reports success or failure with the catched exception.+++executable sdl-try-drivers+        hs-source-dirs: .+        main-is: Main.hs+        default-language: Haskell2010+        ghc-options: -fwarn-tabs -Wall+        build-depends:+                base == 4.*+              , sdl2+              , pretty-simple+              , text