Change bufferData to bufferSubData
This commit is contained in:
+1
-1
@@ -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
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user