From 117f516f3c7094c586d633010fb8f37274b910e9 Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Sun, 19 May 2019 05:15:01 -0400 Subject: PointPrimitiveRing: rSize now counts vertices, not component/floats. --- PointPrimitiveRing.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/PointPrimitiveRing.hs b/PointPrimitiveRing.hs index 4c4b516..acca3ec 100644 --- a/PointPrimitiveRing.hs +++ b/PointPrimitiveRing.hs @@ -32,9 +32,9 @@ data Ring = Ring { rBufferObject :: Buffer , rStorage :: GLStorage , rObject :: Object - , rSize :: IORef CPtrdiff -- Current count of Floats in the ring buffer. - , rBack :: IORef Int -- Where next vector will be added. - , ringCapacity :: CPtrdiff -- Maximum number of floats in buffer. + , rSize :: IORef Int -- Current count of Floats in the ring buffer. + , rBack :: IORef Int -- Where next vector will be added. + , ringCapacity :: CPtrdiff -- Maximum number of floats in buffer. , rPosition :: AttributeKey (GLVector 3 Float) } @@ -63,7 +63,7 @@ newRing storage sz = do updateRingCommands :: Ring -> IO () updateRingCommands r = do back <- fromIntegral <$> readIORef (rBack r) - size <- fmap (fromIntegral . (`div` 3)) $ readIORef $ rSize r + size <- fromIntegral <$> readIORef (rSize r) let mask 0 = [] mask cnt = case cnt + back - size of front | front > cnt -> [(front - cnt,size)] @@ -80,8 +80,8 @@ pushBack r x y z = do rPosition r @<- V3 x y z -- (fromList [x,y,z] :: Vector Float) sz <- readIORef (rSize r) putStrLn $ "pushBack "++show (sz,back,(x,y,z)) - when (sz < ringCapacity r) $ do - writeIORef (rSize r) (sz + 3) + when (sz < fromIntegral (ringCapacity r `div` 3)) $ do + writeIORef (rSize r) (sz + 1) updateRingCommands r updateRingUniforms :: GLStorage -> Ring -> IO () -- cgit v1.2.3