Change bufferData to bufferSubData

This commit is contained in:
jgk
2021-06-24 18:19:03 +02:00
parent 97598bc171
commit d4795749e3
3 changed files with 19 additions and 7 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ import Foreign
--import Control.Applicative
--import Control.Monad.State
import Control.Lens
import Control.Monad
--import Control.Monad
import qualified Control.Foldl as F
import Data.Tuple.Extra
--import Data.List
+12 -6
View File
@@ -5,23 +5,29 @@ module Shader
, drawShaders
, freeShaderPointers
) where
import Geometry.Data
--import Geometry.Data
import Shader.Data
import Shader.Parameters
import MatrixHelper
--import MatrixHelper
import Foreign
import Control.Monad
import Graphics.Rendering.OpenGL hiding (Point,translate,scale,imageHeight)
--import Text.RawString.QQ
import Linear.Matrix
import Linear.V4
--import Linear.Matrix
--import Linear.V4
bindArrayBuffers :: Int -> VBO -> IO ()
bindArrayBuffers numVs theVBO = do
bindBuffer ArrayBuffer $= Just (_vbo theVBO)
bufferData ArrayBuffer $=
(fromIntegral $ floatSize * numVs * sum (_vboAttribSizes theVBO), _vboPointer theVBO, DynamicDraw)
-- bufferData ArrayBuffer $=
-- (fromIntegral $ floatSize * numVs * sum (_vboAttribSizes theVBO), _vboPointer theVBO, DynamicDraw)
bufferSubData
ArrayBuffer
WriteToBuffer
0
(fromIntegral $ floatSize * numVs * sum (_vboAttribSizes theVBO))
(_vboPointer theVBO)
bindShaderBuffers :: [FullShader] -> [Int] -> IO ()
bindShaderBuffers = zipWithM_ f
+6
View File
@@ -68,6 +68,12 @@ setupVBO sizes = do
forM_ (zip3 [0..] sizes offs) $ \(loc,siz,off) -> do
setupVertexAttribPointer loc siz strd off
thePtr <- mallocArray (strd * numDrawableElements)
-- Allocate space
bufferData ArrayBuffer $=
(fromIntegral $ floatSize * numDrawableElements * strd
, nullPtr
, DynamicDraw
)
return $ VBO
{ _vbo = vboName
, _vboPointer = thePtr