packages feed

luminance 0.5.1 → 0.5.2

raw patch · 6 files changed

+191/−2 lines, 6 files

Files

CHANGELOG.md view
@@ -1,3 +1,12 @@+## 0.5.2++#### Minor changes++- Added texture arrays:+    + `Texture1DArray`+    + `Texture2DArray`+    + `CubemapArray`+ ## 0.5.1  #### Minor changes@@ -26,7 +35,7 @@  ## 0.4.1 -- Fixed the `sizeOf` implementatiof of `a :. b`.+- Fixed the `sizeOf` implementation of `a :. b`. - Added `nubDirect`, which can be used to turn *direct geometry* into *indirect geometry*.  # 0.4
luminance.cabal view
@@ -1,5 +1,5 @@ name:                luminance-version:             0.5.1+version:             0.5.2 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@@ -74,6 +74,7 @@                      , Graphics.Luminance.Core.Buffer                      , Graphics.Luminance.Core.Cmd                      , Graphics.Luminance.Core.Cubemap+                     , Graphics.Luminance.Core.CubemapArray                      , Graphics.Luminance.Core.Debug                      , Graphics.Luminance.Core.Framebuffer                      , Graphics.Luminance.Core.Geometry@@ -87,7 +88,9 @@                      , Graphics.Luminance.Core.Shader.Uniform                      , Graphics.Luminance.Core.Texture                      , Graphics.Luminance.Core.Texture1D+                     , Graphics.Luminance.Core.Texture1DArray                      , Graphics.Luminance.Core.Texture2D+                     , Graphics.Luminance.Core.Texture2DArray                      , Graphics.Luminance.Core.Texture3D                      , Graphics.Luminance.Core.Vertex 
+ src/Graphics/Luminance/Core/CubemapArray.hs view
@@ -0,0 +1,57 @@+-----------------------------------------------------------------------------+-- |+-- Copyright   : (C) 2015 Dimitri Sabadie+-- License     : BSD3+--+-- Maintainer  : Dimitri Sabadie <dimitri.sabadie@gmail.com>+-- Stability   : experimental+-- Portability : portable+-----------------------------------------------------------------------------++module Graphics.Luminance.Core.CubemapArray where++import Data.Proxy ( Proxy(..) )+import Data.Vector.Storable ( unsafeWith )+import Foreign.Ptr ( castPtr )+import GHC.TypeLits ( KnownNat, Nat, natVal )+import Graphics.Luminance.Core.Cubemap ( CubeFace, fromCubeFace )+import Graphics.Luminance.Core.Texture ( BaseTexture(..), Texture(..) )+import Graphics.Luminance.Core.Pixel ( Pixel(..) )+import Graphics.GL+import Numeric.Natural ( Natural )++-- |A cubemap array.+data CubemapArray (n :: Nat) (f :: *) = CubemapArray {+    cubemapArrayBase :: BaseTexture+  , cubemapArrayW    :: Natural+  , cubemapArrayH    :: Natural+  } deriving (Eq,Show)++instance (KnownNat n, Pixel f) => Texture (CubemapArray n f) where+  -- |(w,h)+  type TextureSize (CubemapArray n f) = (Natural,Natural)+  -- |(layer,x,y,face)+  type TextureOffset (CubemapArray n f) = (Natural,Natural,Natural,CubeFace)+  fromBaseTexture bt (w,h) = CubemapArray bt w h+  toBaseTexture = cubemapArrayBase+  textureTypeEnum _ = GL_TEXTURE_CUBE_MAP_ARRAY+  textureSize (CubemapArray _ w h) = (w,h)+  textureStorage _ tid levels (w,h) =+    glTextureStorage3D tid levels (pixelIFormat (Proxy :: Proxy f)) (fromIntegral w)+      (fromIntegral h) (fromIntegral $ natVal (Proxy :: Proxy n))+  transferTexelsSub _ tid (layer,x,y,f) (w,h) texels =+      unsafeWith texels $ glTextureSubImage3D tid 0 (fromIntegral x) (fromIntegral y)+        (fromCubeFace f + fromIntegral layer*6) (fromIntegral w) (fromIntegral h) 1 fmt+        typ . castPtr+    where+      proxy = Proxy :: Proxy f+      fmt = pixelFormat proxy+      typ = pixelType proxy+  fillTextureSub _ tid (layer,x,y,f) (w,h) filling =+      unsafeWith filling $ glClearTexSubImage tid 0 (fromIntegral x) (fromIntegral y) +        (fromCubeFace f + fromIntegral layer*6) (fromIntegral w) (fromIntegral h) 1+        fmt typ . castPtr+    where+      proxy = Proxy :: Proxy f+      fmt = pixelFormat proxy+      typ = pixelType proxy
+ src/Graphics/Luminance/Core/Texture1DArray.hs view
@@ -0,0 +1,53 @@+-----------------------------------------------------------------------------+-- |+-- Copyright   : (C) 2015 Dimitri Sabadie+-- License     : BSD3+--+-- Maintainer  : Dimitri Sabadie <dimitri.sabadie@gmail.com>+-- Stability   : experimental+-- Portability : portable+-----------------------------------------------------------------------------++module Graphics.Luminance.Core.Texture1DArray where++import Data.Proxy ( Proxy(..) )+import Data.Vector.Storable ( unsafeWith )+import Foreign.Ptr ( castPtr )+import GHC.TypeLits ( KnownNat, Nat, natVal )+import Graphics.Luminance.Core.Texture ( BaseTexture(..), Texture(..) )+import Graphics.Luminance.Core.Pixel ( Pixel(..) )+import Graphics.GL+import Numeric.Natural ( Natural )++-- |A 1D texture array.+data Texture1DArray (n :: Nat) (f :: *) = Texture1DArray {+    texture1DArrayBase :: BaseTexture+  , texture1DArrayW    :: Natural+  } deriving (Eq,Show)++instance (KnownNat n,Pixel f) => Texture (Texture1DArray n f) where+  -- |(w)+  type TextureSize (Texture1DArray n f) = Natural+  -- |(layer,x)+  type TextureOffset (Texture1DArray n f) = (Natural,Natural)+  fromBaseTexture = Texture1DArray+  toBaseTexture = texture1DArrayBase+  textureTypeEnum _ = GL_TEXTURE_1D_ARRAY+  textureSize = texture1DArrayW+  textureStorage _ tid levels w =+    glTextureStorage2D tid levels (pixelIFormat (Proxy :: Proxy f)) (fromIntegral w)+      (fromIntegral $ natVal (Proxy :: Proxy n))+  transferTexelsSub _ tid (layer,x) w texels =+      unsafeWith texels $ glTextureSubImage2D tid 0 (fromIntegral x) (fromIntegral w) (fromIntegral layer) 1 fmt+        typ . castPtr+    where+      proxy = Proxy :: Proxy f+      fmt = pixelFormat proxy+      typ = pixelType proxy+  fillTextureSub _ tid (layer,x) w filling =+      unsafeWith filling $ glClearTexSubImage tid 0 (fromIntegral x) (fromIntegral layer) 0 (fromIntegral w) (fromIntegral $ natVal (Proxy :: Proxy n)) 1+        fmt typ . castPtr+    where+      proxy = Proxy :: Proxy f+      fmt = pixelFormat proxy+      typ = pixelType proxy
+ src/Graphics/Luminance/Core/Texture2DArray.hs view
@@ -0,0 +1,54 @@+-----------------------------------------------------------------------------+-- |+-- Copyright   : (C) 2015 Dimitri Sabadie+-- License     : BSD3+--+-- Maintainer  : Dimitri Sabadie <dimitri.sabadie@gmail.com>+-- Stability   : experimental+-- Portability : portable+-----------------------------------------------------------------------------++module Graphics.Luminance.Core.Texture2DArray where++import Data.Proxy ( Proxy(..) )+import Data.Vector.Storable ( unsafeWith )+import Foreign.Ptr ( castPtr )+import GHC.TypeLits ( KnownNat, Nat, natVal )+import Graphics.Luminance.Core.Texture ( BaseTexture(..), Texture(..) )+import Graphics.Luminance.Core.Pixel ( Pixel(..) )+import Graphics.GL+import Numeric.Natural ( Natural )++-- |A 2D texture array.+data Texture2DArray (n :: Nat) (f :: *) = Texture2DArray {+    texture2DArrayBase :: BaseTexture+  , texture2DArrayW    :: Natural+  , texture2DArrayH    :: Natural+  } deriving (Eq,Show)++instance (KnownNat n,Pixel f) => Texture (Texture2DArray n f) where+  -- |(w,h)+  type TextureSize (Texture2DArray n f) = (Natural,Natural)+  -- |(layer,x,y)+  type TextureOffset (Texture2DArray n f) = (Natural,Natural,Natural)+  fromBaseTexture bt (w,h) = Texture2DArray bt w h+  toBaseTexture = texture2DArrayBase+  textureTypeEnum _ = GL_TEXTURE_2D_ARRAY+  textureSize (Texture2DArray _ w h) = (w,h)+  textureStorage _ tid levels (w,h) =+    glTextureStorage3D tid levels (pixelIFormat (Proxy :: Proxy f)) (fromIntegral w)+      (fromIntegral h) (fromIntegral $ natVal (Proxy :: Proxy n))+  transferTexelsSub _ tid (layer,x,y) (w,h) texels =+      unsafeWith texels $ glTextureSubImage3D tid 0 (fromIntegral x) (fromIntegral y)+        (fromIntegral layer) (fromIntegral w) (fromIntegral h) 1 fmt typ . castPtr+    where+      proxy = Proxy :: Proxy f+      fmt = pixelFormat proxy+      typ = pixelType proxy+  fillTextureSub _ tid (layer,x,y) (w,h) filling =+      unsafeWith filling $ glClearTexSubImage tid 0 (fromIntegral x)+        (fromIntegral y) (fromIntegral layer) (fromIntegral w) (fromIntegral h) (fromIntegral $ natVal (Proxy :: Proxy n)) fmt typ . castPtr+    where+      proxy = Proxy :: Proxy f+      fmt = pixelFormat proxy+      typ = pixelType proxy
src/Graphics/Luminance/Texture.hs view
@@ -26,10 +26,16 @@     -- ** 1D textures   , Texture1D   , texture1DW+    -- *** Array texture+  , Texture1DArray+  , texture1DArrayW     -- ** 2D textures   , Texture2D   , texture2DW   , texture2DH+    -- *** Array texture+  , Texture2DArray+  , texture2DArrayW     -- ** 3D textures   , Texture3D   , texture3DW@@ -40,10 +46,17 @@   , CubeFace(..)   , cubemapW   , cubemapH+    -- ** Array textures+  , CubemapArray+  , cubemapArrayW+  , cubemapArrayH   ) where    import Graphics.Luminance.Core.Cubemap+import Graphics.Luminance.Core.CubemapArray import Graphics.Luminance.Core.Texture import Graphics.Luminance.Core.Texture1D+import Graphics.Luminance.Core.Texture1DArray import Graphics.Luminance.Core.Texture2D+import Graphics.Luminance.Core.Texture2DArray import Graphics.Luminance.Core.Texture3D