aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Sunet <jeannekamikaze@gmail.com>2012-08-30 22:31:20 +0200
committerMarc Sunet <jeannekamikaze@gmail.com>2012-08-30 22:31:20 +0200
commit25e0a6b7b06086ba156dfdd6b12da4fa6d34ee15 (patch)
treef0ac3b018c4287e80174fa5db2593531c3b4ea60
parenta1683c48e198b7391e858ee8cd6f27ae366a8079 (diff)
Added bufferDatal
-rw-r--r--Spear.lkshw4
-rw-r--r--Spear/GLSL.hs18
2 files changed, 19 insertions, 3 deletions
diff --git a/Spear.lkshw b/Spear.lkshw
index 2bfefbb..fb35953 100644
--- a/Spear.lkshw
+++ b/Spear.lkshw
@@ -1,10 +1,10 @@
1Version of workspace file format: 1Version of workspace file format:
2 1 2 1
3Time of storage: 3Time of storage:
4 "Thu Aug 30 22:00:11 CEST 2012" 4 "Thu Aug 30 22:30:11 CEST 2012"
5Name of the workspace: 5Name of the workspace:
6 "Spear" 6 "Spear"
7File paths of contained packages: 7File paths of contained packages:
8 ["demos/simple-scene/simple-scene.cabal","Spear.cabal"] 8 ["demos/simple-scene/simple-scene.cabal","Spear.cabal"]
9Maybe file path of an active package: 9Maybe file path of an active package:
10 Just "demos/simple-scene/simple-scene.cabal" \ No newline at end of file 10 Just "Spear.cabal" \ No newline at end of file
diff --git a/Spear/GLSL.hs b/Spear/GLSL.hs
index 4e836eb..b64c22e 100644
--- a/Spear/GLSL.hs
+++ b/Spear/GLSL.hs
@@ -61,6 +61,7 @@ module Spear.GLSL
61 -- ** Manipulation 61 -- ** Manipulation
62, bindBuffer 62, bindBuffer
63, bufferData 63, bufferData
64, bufferDatal
64, withGLBuffer 65, withGLBuffer
65 66
66 -- * Textures 67 -- * Textures
@@ -580,10 +581,25 @@ bindBuffer buf target = glBindBuffer (fromTarget target) $ getBuffer buf
580 581
581 582
582-- | Set the buffer's data. 583-- | Set the buffer's data.
583bufferData :: TargetBuffer -> Int -> Ptr a -> BufferUsage -> IO () 584bufferData :: TargetBuffer
585 -> Int -- ^ Buffer size in bytes.
586 -> Ptr a
587 -> BufferUsage
588 -> IO ()
584bufferData target n bufData usage = glBufferData (fromTarget target) (unsafeCoerce n) bufData (fromUsage usage) 589bufferData target n bufData usage = glBufferData (fromTarget target) (unsafeCoerce n) bufData (fromUsage usage)
585 590
586 591
592-- | Set the buffer's data.
593bufferDatal :: Storable a
594 => TargetBuffer
595 -> Int -- ^ The size in bytes of an element in the data list.
596 -> [a] -- ^ The data list.
597 -> BufferUsage
598 -> IO ()
599bufferDatal target n bufData usage = withArray bufData $
600 \ptr -> bufferData target (n * length bufData) ptr usage
601
602
587-- | Apply the given function the buffer's id. 603-- | Apply the given function the buffer's id.
588withGLBuffer :: GLBuffer -> (GLuint -> a) -> a 604withGLBuffer :: GLBuffer -> (GLuint -> a) -> a
589withGLBuffer buf f = f $ getBuffer buf 605withGLBuffer buf f = f $ getBuffer buf