luminance 0.4.1 → 0.5
raw patch · 7 files changed
+43/−28 lines, 7 filesdep +vector
Dependencies added: vector
Files
- CHANGELOG.md +15/−0
- luminance.cabal +2/−1
- src/Graphics/Luminance/Core/Cubemap.hs +3/−4
- src/Graphics/Luminance/Core/Texture.hs +14/−11
- src/Graphics/Luminance/Core/Texture1D.hs +3/−4
- src/Graphics/Luminance/Core/Texture2D.hs +3/−4
- src/Graphics/Luminance/Core/Texture3D.hs +3/−4
CHANGELOG.md view
@@ -1,3 +1,18 @@+### 0.5++#### Major changes++- Changed the interface of texels transfer and filling. We dropped the `Foldable` instance and now+ require a `Data.Vector.Storable.Vector` for performance purposes.++#### Minor changes++- Added `MirrorRepeat` constructor to `Wrap`.++#### Patch changes++- Fixed prerequisites in README.+ ## 0.4.1 - Fixed the `sizeOf` implementatiof of `a :. b`.
luminance.cabal view
@@ -1,5 +1,5 @@ name: luminance-version: 0.4.1+version: 0.5 synopsis: Type-safe, dependently-typed and stateless graphics framework description: This package exposes several modules to work with /GPUs/ in a stateless and type-safe way. Currently, it uses __OpenGL__ as backend hardware technology but@@ -121,6 +121,7 @@ , resourcet >= 1.1 && < 1.2 , semigroups >= 0.16 && < 0.17 , transformers >= 0.4 && < 0.5+ , vector >= 0.11 && < 0.12 , void >= 0.7 && < 0.8 hs-source-dirs: src
src/Graphics/Luminance/Core/Cubemap.hs view
@@ -10,9 +10,8 @@ module Graphics.Luminance.Core.Cubemap where -import Data.Foldable ( toList ) import Data.Proxy ( Proxy(..) )-import Foreign.Marshal.Array ( withArray )+import Data.Vector.Storable ( unsafeWith ) import Foreign.Ptr ( castPtr ) import Graphics.Luminance.Core.Texture ( BaseTexture(..), Texture(..) ) import Graphics.Luminance.Core.Pixel ( Pixel(..) )@@ -56,7 +55,7 @@ glTextureStorage2D tid levels (pixelIFormat (Proxy :: Proxy f)) (fromIntegral w) (fromIntegral h) transferTexelsSub _ tid (x,y,f) (w,h) texels =- withArray (toList texels) $ glTextureSubImage3D tid 0 (fromIntegral x) (fromIntegral y)+ unsafeWith texels $ glTextureSubImage3D tid 0 (fromIntegral x) (fromIntegral y) (fromCubeFace f) (fromIntegral w) (fromIntegral h) 1 fmt typ . castPtr where@@ -64,7 +63,7 @@ fmt = pixelFormat proxy typ = pixelType proxy fillTextureSub _ tid (x,y,f) (w,h) filling =- withArray (toList filling) $ glClearTexSubImage tid 0 (fromIntegral x) (fromIntegral y) + unsafeWith filling $ glClearTexSubImage tid 0 (fromIntegral x) (fromIntegral y) (fromCubeFace f) (fromIntegral w) (fromIntegral h) 1 fmt typ . castPtr where
src/Graphics/Luminance/Core/Texture.hs view
@@ -14,6 +14,7 @@ import Control.Monad.IO.Class ( MonadIO(..) ) import Control.Monad.Trans.Resource ( MonadResource, register ) import Data.Proxy ( Proxy(..) )+import Data.Vector.Storable ( Vector ) import Foreign.Marshal.Alloc ( alloca ) import Foreign.Marshal.Utils ( with ) import Foreign.Storable ( Storable(peek) )@@ -36,13 +37,15 @@ = ClampToEdge -- | ClampToBorder | Repeat+ | MirroredRepeat deriving (Eq,Show) fromWrap :: (Eq a,Num a) => Wrap -> a fromWrap w = case w of- ClampToEdge -> GL_CLAMP_TO_EDGE- -- ClampToBorder -> GL_CLAMP_TO_BORDER- Repeat -> GL_REPEAT+ ClampToEdge -> GL_CLAMP_TO_EDGE+ -- ClampToBorder -> GL_CLAMP_TO_BORDER+ Repeat -> GL_REPEAT+ MirroredRepeat -> GL_MIRRORED_REPEAT -- |Sampling filter. 'Nearest' will sample the nearest texel at the sampling coordinates whilst -- 'Linear' will perform linear interpolation with the texels nearby.@@ -100,19 +103,19 @@ -> GLint -- levels -> TextureSize t -- size of the texture -> IO ()- transferTexelsSub :: forall a f proxy. (Foldable f,Storable a)+ transferTexelsSub :: (Storable a) => proxy t -> GLuint -- texture ID -> TextureOffset t -- offset -> TextureSize t -- size- -> f a+ -> Vector a -> IO ()- fillTextureSub :: forall a f proxy. (Foldable f,Storable a)+ fillTextureSub :: (Storable a) => proxy t -> GLuint -> TextureOffset t -- offset -> TextureSize t -- size- -> f a+ -> Vector a -> IO () -- OpenGL texture.@@ -227,12 +230,12 @@ -- |@'uploadSub' tex offset size autolvl texels@ uploads data to a subpart of the texture’s storage. -- The offset is given with origin at upper-left corner, and @size@ is the size of the area -- to upload to. @autolvl@ is a 'Bool' that can be used to automatically generate mipmaps.-uploadSub :: forall a f m t. (Foldable f,MonadIO m,Storable a,Texture t)+uploadSub :: forall a m t. (MonadIO m,Storable a,Texture t) => t -> TextureOffset t -> TextureSize t -> Bool- -> f a+ -> Vector a -> m () uploadSub tex offset size autolvl texels = liftIO $ do transferTexelsSub (Proxy :: Proxy t) tid offset size texels@@ -241,12 +244,12 @@ tid = baseTextureID (toBaseTexture tex) -- |Fill a subpart of the texture’s storage with a given value.-fillSub :: forall a f m t. (Foldable f,MonadIO m,Storable a,Texture t)+fillSub :: forall a m t. (MonadIO m,Storable a,Texture t) => t -> TextureOffset t -> TextureSize t -> Bool- -> f a+ -> Vector a -> m () fillSub tex offset size autolvl filling = liftIO $ do fillTextureSub (Proxy :: Proxy t) tid offset size filling
src/Graphics/Luminance/Core/Texture1D.hs view
@@ -10,9 +10,8 @@ module Graphics.Luminance.Core.Texture1D where -import Data.Foldable ( toList ) import Data.Proxy ( Proxy(..) )-import Foreign.Marshal.Array ( withArray )+import Data.Vector.Storable ( unsafeWith ) import Foreign.Ptr ( castPtr ) import Graphics.Luminance.Core.Texture ( BaseTexture(..), Texture(..) ) import Graphics.Luminance.Core.Pixel ( Pixel(..) )@@ -35,14 +34,14 @@ textureStorage _ tid levels w = glTextureStorage1D tid levels (pixelIFormat (Proxy :: Proxy f)) (fromIntegral w) transferTexelsSub _ tid x w texels =- withArray (toList texels) $ glTextureSubImage1D tid 0 (fromIntegral x) (fromIntegral w) fmt+ unsafeWith texels $ glTextureSubImage1D tid 0 (fromIntegral x) (fromIntegral w) fmt typ . castPtr where proxy = Proxy :: Proxy f fmt = pixelFormat proxy typ = pixelType proxy fillTextureSub _ tid x w filling =- withArray (toList filling) $ glClearTexSubImage tid 0 (fromIntegral x) 0 0 (fromIntegral w) 1 1+ unsafeWith filling $ glClearTexSubImage tid 0 (fromIntegral x) 0 0 (fromIntegral w) 1 1 fmt typ . castPtr where proxy = Proxy :: Proxy f
src/Graphics/Luminance/Core/Texture2D.hs view
@@ -10,9 +10,8 @@ module Graphics.Luminance.Core.Texture2D where -import Data.Foldable ( toList ) import Data.Proxy ( Proxy(..) )-import Foreign.Marshal.Array ( withArray )+import Data.Vector.Storable ( unsafeWith ) import Foreign.Ptr ( castPtr ) import Graphics.Luminance.Core.Texture ( BaseTexture(..), Texture(..) ) import Graphics.Luminance.Core.Pixel ( Pixel(..) )@@ -36,14 +35,14 @@ textureStorage _ tid levels (w,h) = glTextureStorage2D tid levels (pixelIFormat (Proxy :: Proxy f)) (fromIntegral w) (fromIntegral h) transferTexelsSub _ tid (x,y) (w,h) texels =- withArray (toList texels) $ glTextureSubImage2D tid 0 (fromIntegral x) (fromIntegral y)+ unsafeWith texels $ glTextureSubImage2D tid 0 (fromIntegral x) (fromIntegral y) (fromIntegral w) (fromIntegral h) fmt typ . castPtr where proxy = Proxy :: Proxy f fmt = pixelFormat proxy typ = pixelType proxy fillTextureSub _ tid (x,y) (w,h) filling =- withArray (toList filling) $ glClearTexSubImage tid 0 (fromIntegral x)+ unsafeWith filling $ glClearTexSubImage tid 0 (fromIntegral x) (fromIntegral y) 0 (fromIntegral w) (fromIntegral h) 1 fmt typ . castPtr where proxy = Proxy :: Proxy f
src/Graphics/Luminance/Core/Texture3D.hs view
@@ -10,9 +10,8 @@ module Graphics.Luminance.Core.Texture3D where -import Data.Foldable ( toList ) import Data.Proxy ( Proxy(..) )-import Foreign.Marshal.Array ( withArray )+import Data.Vector.Storable ( unsafeWith ) import Foreign.Ptr ( castPtr ) import Graphics.Luminance.Core.Texture ( BaseTexture(..), Texture(..) ) import Graphics.Luminance.Core.Pixel ( Pixel(..) )@@ -38,14 +37,14 @@ glTextureStorage3D tid levels (pixelIFormat (Proxy :: Proxy f)) (fromIntegral w) (fromIntegral h) (fromIntegral d) transferTexelsSub _ tid (x,y,z) (w,h,d) texels =- withArray (toList texels) $ glTextureSubImage3D tid 0 (fromIntegral x) (fromIntegral y)+ unsafeWith texels $ glTextureSubImage3D tid 0 (fromIntegral x) (fromIntegral y) (fromIntegral z) (fromIntegral w) (fromIntegral h) (fromIntegral d) fmt typ . castPtr where proxy = Proxy :: Proxy f fmt = pixelFormat proxy typ = pixelType proxy fillTextureSub _ tid (x,y,z) (w,h,d) filling =- withArray (toList filling) $ glClearTexSubImage tid 0 (fromIntegral x) (fromIntegral y)+ unsafeWith filling $ glClearTexSubImage tid 0 (fromIntegral x) (fromIntegral y) (fromIntegral z) (fromIntegral w) (fromIntegral h) (fromIntegral d) fmt typ . castPtr where proxy = Proxy :: Proxy f