summaryrefslogtreecommitdiff
path: root/GPURing.hs
diff options
context:
space:
mode:
Diffstat (limited to 'GPURing.hs')
-rw-r--r--GPURing.hs46
1 files changed, 46 insertions, 0 deletions
diff --git a/GPURing.hs b/GPURing.hs
new file mode 100644
index 0000000..d5f46af
--- /dev/null
+++ b/GPURing.hs
@@ -0,0 +1,46 @@
1module GPURing where
2
3import Control.Monad.Writer
4import Data.Data
5import Data.Dependent.Sum
6import Data.Function
7import Data.Typeable
8
9import AttributeData
10import RingBuffer
11import MaskableStream
12
13import LambdaCube.GL as LC hiding (updateBuffer)
14import LambdaCube.GL.Data hiding (updateBuffer) -- (uploadCubeMapToGPU,uploadTextureBufferToGPU,updateTextureBuffer)
15import LambdaCube.GL.Mesh as LC
16import LambdaCube.GL.Type
17import LambdaCube.IR as LC
18import LambdaCube.GL.Util
19import LambdaCube.GL.Input.Type
20import LambdaCube.GL.Input hiding (createObjectCommands)
21
22
23-- | Typical usage:
24--
25-- > ringBuffer <- newRing capacity (VectorRing.new capacity)
26type Update keys = (keys -> Writer [DSum AttributeKey GLUniformValue] ())
27
28new :: Data keys => GLStorage -> (String -> String) -> Int -> IO (TargetBuffer (Update keys))
29new storage toAttr sz = fix $ \retProxy -> do
30 let paramProxy = paramProxy' retProxy
31 where paramProxy' :: io (targetbuffer (keys -> writer)) -> Proxy keys
32 paramProxy' _ = Proxy
33 let ps = fieldParameters paramProxy toAttr
34 putStrLn $ "Ring params: " ++ show ps
35 gd0 <- uploadDynamicBuffer sz ps
36 let gd = gd0 { dPrimitive = LineStrip }
37 Just keys <- return $ lookupAttrKeys (lookupAttributeKey gd . toAttr)
38 obj <- addToObjectArray storage "Points" [] gd
39 -- readIORef (objCommands obj) >>= mapM_ print
40 return TargetBuffer
41 { syncBuffer = \mask -> do updateCommands storage obj mask
42 return ()
43 , updateBuffer = \i u -> do updateAttributes i $ u keys
44 return ()
45 }
46