gloss 1.3.1.2 → 1.3.3.1
raw patch · 3 files changed
+22/−10 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Graphics/Gloss/Internals/Render/Bitmap.hs +13/−6
- Graphics/Gloss/Internals/Render/Picture.hs +8/−3
- gloss.cabal +1/−1
Graphics/Gloss/Internals/Render/Bitmap.hs view
@@ -3,7 +3,9 @@ -- | Helper functions for rendering bitmaps module Graphics.Gloss.Internals.Render.Bitmap ( reverseRGBA- , bitmapPath )+ , bitmapPath+ , freeBitmapData+ ) where import Foreign import qualified Data.ByteString as B@@ -17,16 +19,16 @@ height' = height / 2 --- | This is necessary as openGL reads pixel data as ABGR, rather than RGBA+-- | This is necessary as OpenGL reads pixel data as ABGR, rather than RGBA reverseRGBA :: B.ByteString -> IO (Ptr Word8) reverseRGBA orig = do ptr <- newArray $ B.unpack orig- ptr' <- reverseRGBA' (B.length orig `div` 4) (castPtr ptr) 0- return $ castPtr ptr'+ reverseRGBA' (B.length orig `div` 4) (castPtr ptr) 0+ return ptr -- | Parses through pixel values, shifting the bytes into OpenGL ABGR order-reverseRGBA' :: Int -> Ptr Word32 -> Int -> IO (Ptr Word32)+reverseRGBA' :: Int -> Ptr Word32 -> Int -> IO () reverseRGBA' len ptr count | count < len = do curr <- peekElemOff ptr count@@ -38,7 +40,12 @@ reverseRGBA' len ptr (count + 1) | otherwise - = return ptr+ = return ()++-- | Frees the allocated memory given to OpenGL to avoid a memory leak+freeBitmapData :: Ptr Word8 -> IO ()+{-# INLINE freeBitmapData #-}+freeBitmapData p = free p -- | These functions work as bit masks to isolate the Word8 components
Graphics/Gloss/Internals/Render/Picture.hs view
@@ -86,12 +86,12 @@ -> renderCircle 0 0 circScale radius thickness -- stroke text- -- text looks wierd when we've got blend on,+ -- text looks weird when we've got blend on, -- so disable it during the renderString call. Text str -> do GL.blend $= GL.Disabled- GLUT.renderString GLUT.Roman str+ GL.preservingMatrix $ GLUT.renderString GLUT.Roman str GL.blend $= GL.Enabled -- colors with float components.@@ -148,7 +148,6 @@ -- each pixel's value needs to be reversed we also need to -- Convert imgData from ByteString to Ptr Word8 imgData' <- reverseRGBA $ imgData- -- Allocate texture handle for texture [texObject] <- GL.genObjectNames 1 GL.textureBinding GL.Texture2D $= Just texObject@@ -191,6 +190,12 @@ -- Disable texturing GL.texture GL.Texture2D $= GL.Disabled++ -- Delete texture+ GL.deleteObjectNames [texObject]++ -- Free image data+ freeBitmapData imgData' Pictures ps -> mapM_ (drawPicture circScale) ps
gloss.cabal view
@@ -1,5 +1,5 @@ Name: gloss-Version: 1.3.1.2+Version: 1.3.3.1 License: MIT License-file: LICENSE Author: Ben Lippmeier