packages feed

graphics-drawingcombinators 1.4.1 → 1.4.2

raw patch · 3 files changed

+97/−4 lines, 3 filesdep +bitmapdep −bitmap-opengldep ~OpenGLnew-uploaderPVP ok

version bump matches the API change (PVP)

Dependencies added: bitmap

Dependencies removed: bitmap-opengl

Dependency ranges changed: OpenGL

API changes (from Hackage documentation)

Files

Graphics/DrawingCombinators.hs view
@@ -80,15 +80,15 @@  import Graphics.DrawingCombinators.Affine import Control.Applicative (Applicative(..), liftA2, (*>), (<$>))-import Control.Monad (unless) import Data.Monoid (Monoid(..), Any(..))+import qualified Graphics.DrawingCombinators.Bitmap as Bitmap import qualified Graphics.Rendering.OpenGL.GL as GL import qualified Codec.Image.STB as Image-import qualified Data.Bitmap.OpenGL as Bitmap import System.IO.Unsafe (unsafePerformIO)  -- for pure textWidth  #ifdef LAME_FONTS import qualified Graphics.UI.GLUT as GLUT+import Control.Monad (unless) #else import qualified Graphics.Rendering.FTGL as FTGL import System.Mem.Weak (addFinalizer)
+ Graphics/DrawingCombinators/Bitmap.hs view
@@ -0,0 +1,88 @@+-- | OpenGL support for Data.Bitmap++{- Copied from the bitmap-opengl package because maintainer is+   unresponsive about bug-fixes/uploads -}+{- Copyright: (c) 2009 Balazs Komuves -}++{-# LANGUAGE ScopedTypeVariables #-}+module Graphics.DrawingCombinators.Bitmap+  ( makeSimpleBitmapTexture+  , makeTextureFromBitmap+  , texImageFromBitmap+  ) where++--------------------------------------------------------------------------------++import Data.Bitmap++import Graphics.Rendering.OpenGL++--------------------------------------------------------------------------------++-- OpenGL data type+dataType :: PixelComponent t => t -> DataType+dataType t = case pixelComponentType t of+  PctWord8  -> UnsignedByte+  PctWord16 -> UnsignedShort+  PctWord32 -> UnsignedInt+  PctFloat  -> Float++--------------------------------------------------------------------------------++-- | This function guesses the pixel format from the number of channels:+-- +-- * 1 ~> Alpha+--+-- * 2 ~> Luminance, Alpha+--+-- * 3 ~> RGB+--+-- * 4 ~> RGBA+--+-- For more control, use 'makeTextureFromBitmap'.+makeSimpleBitmapTexture :: forall t. PixelComponent t => Bitmap t -> IO TextureObject+makeSimpleBitmapTexture bm = do+  let (pf,pif) = case pixelComponentType (undefined::t) of +        PctWord8 -> case bitmapNChannels bm of+          1 -> (Alpha, Alpha8)+          2 -> (LuminanceAlpha, Luminance8Alpha8)+          3 -> (RGB, RGB8)+          4 -> (RGBA, RGBA8)  +          n -> error $ "Invalid bitmap channel count: " ++ show n+        _ -> case bitmapNChannels bm of+          1 -> (Alpha, Alpha')+          2 -> (LuminanceAlpha, LuminanceAlpha')+          3 -> (RGB, RGB')+          4 -> (RGBA, RGBA')  +          n -> error $ "Invalid bitmap channel count: " ++ show n+  makeTextureFromBitmap bm Nothing 0 pf pif 0 +  +-- | Creates a new OpenGL texture from a bitmap+makeTextureFromBitmap +  :: PixelComponent t +  => Bitmap t -> Maybe CubeMapTarget -> Level -> PixelFormat -> PixelInternalFormat -> Border -> IO TextureObject+makeTextureFromBitmap bm cubemap level pf pif border = do+  old_binding <- get (textureBinding Texture2D)+  [tex] <- genObjectNames 1 +  textureBinding Texture2D $= Just tex +  textureFilter Texture2D $= ((Linear',Nothing),Linear')+  texImageFromBitmap bm cubemap level pf pif border   +  textureBinding Texture2D $= old_binding+  return tex++texImageFromBitmap+  :: forall t. PixelComponent t +  => Bitmap t -> Maybe CubeMapTarget -> Level -> PixelFormat -> PixelInternalFormat -> Border -> IO ()+texImageFromBitmap bm cubemap level pf pif border = do+  withBitmap bm $ \(width,height) _nchn _pad ptr -> do+--    old_rowlength <- get (rowLength Unpack)+    old_alignment <- get (rowAlignment Unpack)+    let pdata = PixelData pf (dataType (undefined::t)) ptr  +        size = TextureSize2D (fromIntegral width) (fromIntegral height) +--    rowLength Unpack $= fromIntegral (bitmapPaddedRowSizeInBytes bm)+    rowAlignment Unpack $= fromIntegral (bitmapRowAlignment bm)+    texImage2D cubemap NoProxy level pif size border pdata+--    rowLength Unpack $= old_rowlength +    rowAlignment Unpack $= old_alignment+  +--------------------------------------------------------------------------------
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.4.1+Version: 1.4.2 Stability: experimental Synopsis: A functional interface to 2D drawing in OpenGL License: BSD3@@ -16,12 +16,17 @@ Extra-Source-Files: example.hs cabal-Version: >= 1.6 +source-repository head+  type:     git+  location: http://github.com/luqui/graphics-drawingcombinators+ Flag ftgl     Description: Does the system have FTGL, thus we could use not sucky fonts  Library-    Build-Depends: base == 4.*, containers, OpenGL == 2.4.*, stb-image == 0.2.*, bitmap-opengl == 0.0.*+    Build-Depends: base == 4.*, containers, OpenGL >= 2.4 && < 2.6, stb-image == 0.2.*, bitmap >= 0.0.2     Exposed-Modules: Graphics.DrawingCombinators, Graphics.DrawingCombinators.Affine+    Other-Modules: Graphics.DrawingCombinators.Bitmap     ghc-options : -Wall      Ghc-Prof-Options:  -prof -auto-all