change byte offset to offset in number of buffer elements
This commit is contained in:
parent
0fb10b0981
commit
a9165b852a
|
@ -37,7 +37,7 @@ class (Bindable a, Storable (StoreType a)) =>
|
||||||
write
|
write
|
||||||
:: a
|
:: a
|
||||||
-> Word
|
-> Word
|
||||||
-- ^ write offset from beginning of buffer in bytes
|
-- ^ write offset from beginning of buffer in number of data elements
|
||||||
-> StoreContainer a (StoreType a)
|
-> StoreContainer a (StoreType a)
|
||||||
-- ^ Data to write
|
-- ^ Data to write
|
||||||
-> IO ()
|
-> IO ()
|
||||||
|
|
|
@ -52,7 +52,8 @@ instance Buffer IndexBuffer where
|
||||||
write buf offset dat = do
|
write buf offset dat = do
|
||||||
currentBufSize <- readTVarIO (iBufSize buf)
|
currentBufSize <- readTVarIO (iBufSize buf)
|
||||||
whileM_
|
whileM_
|
||||||
(pure $ offset + VS.length dat * sizeOf (undefined :: StoreType IndexBuffer)
|
(pure $ (offset + VS.length dat) *
|
||||||
|
sizeOf (undefined :: StoreType IndexBuffer)
|
||||||
> currentBufSize) $ do
|
> currentBufSize) $ do
|
||||||
allocaArray
|
allocaArray
|
||||||
(currentBufSize `div` sizeOf (undefined :: StoreType IndexBuffer))
|
(currentBufSize `div` sizeOf (undefined :: StoreType IndexBuffer))
|
||||||
|
@ -77,9 +78,10 @@ instance Buffer IndexBuffer where
|
||||||
GL.bufferSubData
|
GL.bufferSubData
|
||||||
(target buf)
|
(target buf)
|
||||||
GL.WriteToBuffer
|
GL.WriteToBuffer
|
||||||
(CPtrdiff $ fromIntegral offset)
|
(CPtrdiff $ fromIntegral offset *
|
||||||
|
sizeOf (undefined :: StoreType IndexBuffer))
|
||||||
(CPtrdiff $ fromIntegral $
|
(CPtrdiff $ fromIntegral $
|
||||||
VS.length dat * sizeOf (undefined ::StoreType IndexBuffer))
|
VS.length dat * sizeOf (undefined :: StoreType IndexBuffer))
|
||||||
ptr
|
ptr
|
||||||
|
|
||||||
expand buf = do
|
expand buf = do
|
||||||
|
|
|
@ -90,8 +90,8 @@ instance Buffer VertexBuffer where
|
||||||
write buf offset dat = do
|
write buf offset dat = do
|
||||||
currentBufSize <- readTVarIO (vBufSize buf)
|
currentBufSize <- readTVarIO (vBufSize buf)
|
||||||
whileM_
|
whileM_
|
||||||
(pure $ fromIntegral offset +
|
(pure $ (fromIntegral offset + VS.length dat) *
|
||||||
VS.length dat * sizeOf (undefined :: StoreType VertexBuffer)
|
sizeOf (undefined :: StoreType VertexBuffer)
|
||||||
> fromIntegral currentBufSize) $ do
|
> fromIntegral currentBufSize) $ do
|
||||||
allocaArray
|
allocaArray
|
||||||
(fromIntegral currentBufSize `div`
|
(fromIntegral currentBufSize `div`
|
||||||
|
@ -119,7 +119,8 @@ instance Buffer VertexBuffer where
|
||||||
-- target buffer type
|
-- target buffer type
|
||||||
GL.WriteToBuffer
|
GL.WriteToBuffer
|
||||||
-- data access direction
|
-- data access direction
|
||||||
(CPtrdiff $ fromIntegral offset)
|
(CPtrdiff $ fromIntegral offset *
|
||||||
|
fromIntegral (sizeOf (undefined :: StoreType VertexBuffer)))
|
||||||
-- offset from buffer start
|
-- offset from buffer start
|
||||||
(CPtrdiff $ fromIntegral $
|
(CPtrdiff $ fromIntegral $
|
||||||
VS.length dat * sizeOf (undefined :: StoreType VertexBuffer))
|
VS.length dat * sizeOf (undefined :: StoreType VertexBuffer))
|
||||||
|
|
Loading…
Reference in a new issue