diff options
author | Joe Crayne <joe@jerkface.net> | 2019-05-19 05:15:01 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-05-19 05:15:01 -0400 |
commit | 117f516f3c7094c586d633010fb8f37274b910e9 (patch) | |
tree | 5f272427ebbec7cb80ec4d7a0377290162088660 | |
parent | efed7ba3aec1f77d35e2b3725000640936478a77 (diff) |
PointPrimitiveRing: rSize now counts vertices, not component/floats.
-rw-r--r-- | PointPrimitiveRing.hs | 12 |
1 files 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 | |||
32 | { rBufferObject :: Buffer | 32 | { rBufferObject :: Buffer |
33 | , rStorage :: GLStorage | 33 | , rStorage :: GLStorage |
34 | , rObject :: Object | 34 | , rObject :: Object |
35 | , rSize :: IORef CPtrdiff -- Current count of Floats in the ring buffer. | 35 | , rSize :: IORef Int -- Current count of Floats in the ring buffer. |
36 | , rBack :: IORef Int -- Where next vector will be added. | 36 | , rBack :: IORef Int -- Where next vector will be added. |
37 | , ringCapacity :: CPtrdiff -- Maximum number of floats in buffer. | 37 | , ringCapacity :: CPtrdiff -- Maximum number of floats in buffer. |
38 | , rPosition :: AttributeKey (GLVector 3 Float) | 38 | , rPosition :: AttributeKey (GLVector 3 Float) |
39 | } | 39 | } |
40 | 40 | ||
@@ -63,7 +63,7 @@ newRing storage sz = do | |||
63 | updateRingCommands :: Ring -> IO () | 63 | updateRingCommands :: Ring -> IO () |
64 | updateRingCommands r = do | 64 | updateRingCommands r = do |
65 | back <- fromIntegral <$> readIORef (rBack r) | 65 | back <- fromIntegral <$> readIORef (rBack r) |
66 | size <- fmap (fromIntegral . (`div` 3)) $ readIORef $ rSize r | 66 | size <- fromIntegral <$> readIORef (rSize r) |
67 | let mask 0 = [] | 67 | let mask 0 = [] |
68 | mask cnt = case cnt + back - size of | 68 | mask cnt = case cnt + back - size of |
69 | front | front > cnt -> [(front - cnt,size)] | 69 | front | front > cnt -> [(front - cnt,size)] |
@@ -80,8 +80,8 @@ pushBack r x y z = do | |||
80 | rPosition r @<- V3 x y z -- (fromList [x,y,z] :: Vector Float) | 80 | rPosition r @<- V3 x y z -- (fromList [x,y,z] :: Vector Float) |
81 | sz <- readIORef (rSize r) | 81 | sz <- readIORef (rSize r) |
82 | putStrLn $ "pushBack "++show (sz,back,(x,y,z)) | 82 | putStrLn $ "pushBack "++show (sz,back,(x,y,z)) |
83 | when (sz < ringCapacity r) $ do | 83 | when (sz < fromIntegral (ringCapacity r `div` 3)) $ do |
84 | writeIORef (rSize r) (sz + 3) | 84 | writeIORef (rSize r) (sz + 1) |
85 | updateRingCommands r | 85 | updateRingCommands r |
86 | 86 | ||
87 | updateRingUniforms :: GLStorage -> Ring -> IO () | 87 | updateRingUniforms :: GLStorage -> Ring -> IO () |