graphics-drawingcombinators 1.1.0 → 1.1.1
raw patch · 2 files changed
+49/−9 lines, 2 filesdep +GLUTdep −mtldep ~basedep ~bitmap-openglPVP ok
version bump matches the API change (PVP)
Dependencies added: GLUT
Dependencies removed: mtl
Dependency ranges changed: base, bitmap-opengl
API changes (from Hackage documentation)
Files
Graphics/DrawingCombinators.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE CPP #-}+ -------------------------------------------------------------- -- | -- Module : Graphics.DrawingCombinators@@ -71,17 +73,22 @@ import Graphics.DrawingCombinators.Affine import Control.Applicative (Applicative(..), liftA2, (*>), (<$>)) import Data.Maybe(fromMaybe)-import Control.Monad (forM_)+import Control.Monad (forM_, unless) import Data.Monoid (Monoid(..), Any(..))-import System.Mem.Weak (addFinalizer) import qualified Data.Set as Set import qualified Graphics.Rendering.OpenGL.GL as GL import qualified Graphics.Rendering.OpenGL.GLU as GLU import qualified Codec.Image.STB as Image import qualified Data.Bitmap.OpenGL as Bitmap-import qualified Graphics.Rendering.FTGL as FTGL import System.IO.Unsafe (unsafePerformIO) -- for pure textWidth +#ifdef LAME_FONTS+import qualified Graphics.UI.GLUT as GLUT+#else+import qualified Graphics.Rendering.FTGL as FTGL+import System.Mem.Weak (addFinalizer)+#endif+ type Renderer = Affine -> Color -> IO () type Picker a = Affine -> GL.GLuint -> IO (GL.GLuint, Set.Set GL.GLuint -> a) @@ -354,6 +361,28 @@ Text ---------} +#ifdef LAME_FONTS++data Font = Font++openFont :: String -> IO Font+openFont _ = do+ inited <- GLUT.get GLUT.initState+ unless inited $ GLUT.initialize "" [] >> return ()+ return Font++text :: Font -> String -> Image Any+text Font str = rendererImage $ \tr _ -> do+ GL.preservingMatrix $ do+ multGLmatrix tr+ GL.scale (1/64 :: GL.GLdouble) (1/64) 1+ GLUT.renderString GLUT.Roman str++textWidth :: Font -> String -> R+textWidth Font str = (1/64) * fromIntegral (unsafePerformIO (GLUT.stringWidth GLUT.Roman str))++#else+ data Font = Font { getFont :: FTGL.Font } -- | Load a TTF font from a file.@@ -380,3 +409,5 @@ textWidth font str = (/36) . realToFrac . unsafePerformIO $ do _ <- FTGL.setFontFaceSize (getFont font) 72 72 FTGL.getFontAdvance (getFont font) str++#endif
graphics-drawingcombinators.cabal view
@@ -4,7 +4,7 @@ have to go into the deep, dark world of imperative stateful programming just to draw stuff. It supports 2D only (for now), with support drawing geometry, images, and text.-Version: 1.1.0+Version: 1.1.1 Stability: experimental Synopsis: A functional interface to 2D drawing in OpenGL License: BSD3@@ -14,10 +14,19 @@ Maintainer: lrpalmer@gmail.com Build-Type: Simple Extra-Source-Files: example.hs-cabal-Version: >= 1.2+cabal-Version: >= 1.6 +Flag ftgl+ Description: Does the system have FTGL, thus we could use not sucky fonts+ Library- Build-Depends: base < 5, mtl, containers, OpenGL >= 2.4 && < 2.5, stb-image >= 0.2 && < 0.3, bitmap-opengl < 0.1, FTGL- Exposed-Modules: Graphics.DrawingCombinators, Graphics.DrawingCombinators.Affine- ghc-options : -Wall - Ghc-Prof-Options: -prof -auto-all+ Build-Depends: base == 4.*, containers, OpenGL == 2.4.*, stb-image == 0.2.*, bitmap-opengl == 0.0.*+ Exposed-Modules: Graphics.DrawingCombinators, Graphics.DrawingCombinators.Affine+ ghc-options : -Wall + Ghc-Prof-Options: -prof -auto-all++ if flag(ftgl)+ Build-Depends: FTGL+ else+ Build-Depends: GLUT+ CPP-Options: -DLAME_FONTS