From 25e0a6b7b06086ba156dfdd6b12da4fa6d34ee15 Mon Sep 17 00:00:00 2001 From: Marc Sunet Date: Thu, 30 Aug 2012 22:31:20 +0200 Subject: Added bufferDatal --- Spear.lkshw | 4 ++-- 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 @@ Version of workspace file format: 1 Time of storage: - "Thu Aug 30 22:00:11 CEST 2012" + "Thu Aug 30 22:30:11 CEST 2012" Name of the workspace: "Spear" File paths of contained packages: ["demos/simple-scene/simple-scene.cabal","Spear.cabal"] Maybe file path of an active package: - Just "demos/simple-scene/simple-scene.cabal" \ No newline at end of file + 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 -- ** Manipulation , bindBuffer , bufferData +, bufferDatal , withGLBuffer -- * Textures @@ -580,10 +581,25 @@ bindBuffer buf target = glBindBuffer (fromTarget target) $ getBuffer buf -- | Set the buffer's data. -bufferData :: TargetBuffer -> Int -> Ptr a -> BufferUsage -> IO () +bufferData :: TargetBuffer + -> Int -- ^ Buffer size in bytes. + -> Ptr a + -> BufferUsage + -> IO () bufferData target n bufData usage = glBufferData (fromTarget target) (unsafeCoerce n) bufData (fromUsage usage) +-- | Set the buffer's data. +bufferDatal :: Storable a + => TargetBuffer + -> Int -- ^ The size in bytes of an element in the data list. + -> [a] -- ^ The data list. + -> BufferUsage + -> IO () +bufferDatal target n bufData usage = withArray bufData $ + \ptr -> bufferData target (n * length bufData) ptr usage + + -- | Apply the given function the buffer's id. withGLBuffer :: GLBuffer -> (GLuint -> a) -> a withGLBuffer buf f = f $ getBuffer buf -- cgit v1.2.3