diff options
author | Marc Sunet <jeannekamikaze@gmail.com> | 2012-08-30 22:31:20 +0200 |
---|---|---|
committer | Marc Sunet <jeannekamikaze@gmail.com> | 2012-08-30 22:31:20 +0200 |
commit | 25e0a6b7b06086ba156dfdd6b12da4fa6d34ee15 (patch) | |
tree | f0ac3b018c4287e80174fa5db2593531c3b4ea60 | |
parent | a1683c48e198b7391e858ee8cd6f27ae366a8079 (diff) |
Added bufferDatal
-rw-r--r-- | Spear.lkshw | 4 | ||||
-rw-r--r-- | Spear/GLSL.hs | 18 |
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 @@ | |||
1 | Version of workspace file format: | 1 | Version of workspace file format: |
2 | 1 | 2 | 1 |
3 | Time of storage: | 3 | Time of storage: |
4 | "Thu Aug 30 22:00:11 CEST 2012" | 4 | "Thu Aug 30 22:30:11 CEST 2012" |
5 | Name of the workspace: | 5 | Name of the workspace: |
6 | "Spear" | 6 | "Spear" |
7 | File paths of contained packages: | 7 | File paths of contained packages: |
8 | ["demos/simple-scene/simple-scene.cabal","Spear.cabal"] | 8 | ["demos/simple-scene/simple-scene.cabal","Spear.cabal"] |
9 | Maybe file path of an active package: | 9 | Maybe 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. |
583 | bufferData :: TargetBuffer -> Int -> Ptr a -> BufferUsage -> IO () | 584 | bufferData :: TargetBuffer |
585 | -> Int -- ^ Buffer size in bytes. | ||
586 | -> Ptr a | ||
587 | -> BufferUsage | ||
588 | -> IO () | ||
584 | bufferData target n bufData usage = glBufferData (fromTarget target) (unsafeCoerce n) bufData (fromUsage usage) | 589 | bufferData target n bufData usage = glBufferData (fromTarget target) (unsafeCoerce n) bufData (fromUsage usage) |
585 | 590 | ||
586 | 591 | ||
592 | -- | Set the buffer's data. | ||
593 | bufferDatal :: 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 () | ||
599 | bufferDatal 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. |
588 | withGLBuffer :: GLBuffer -> (GLuint -> a) -> a | 604 | withGLBuffer :: GLBuffer -> (GLuint -> a) -> a |
589 | withGLBuffer buf f = f $ getBuffer buf | 605 | withGLBuffer buf f = f $ getBuffer buf |