Change bufferData to bufferSubData
This commit is contained in:
+1
-1
@@ -27,7 +27,7 @@ import Foreign
|
|||||||
--import Control.Applicative
|
--import Control.Applicative
|
||||||
--import Control.Monad.State
|
--import Control.Monad.State
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Control.Monad
|
--import Control.Monad
|
||||||
import qualified Control.Foldl as F
|
import qualified Control.Foldl as F
|
||||||
import Data.Tuple.Extra
|
import Data.Tuple.Extra
|
||||||
--import Data.List
|
--import Data.List
|
||||||
|
|||||||
+12
-6
@@ -5,23 +5,29 @@ module Shader
|
|||||||
, drawShaders
|
, drawShaders
|
||||||
, freeShaderPointers
|
, freeShaderPointers
|
||||||
) where
|
) where
|
||||||
import Geometry.Data
|
--import Geometry.Data
|
||||||
import Shader.Data
|
import Shader.Data
|
||||||
import Shader.Parameters
|
import Shader.Parameters
|
||||||
import MatrixHelper
|
--import MatrixHelper
|
||||||
|
|
||||||
import Foreign
|
import Foreign
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Graphics.Rendering.OpenGL hiding (Point,translate,scale,imageHeight)
|
import Graphics.Rendering.OpenGL hiding (Point,translate,scale,imageHeight)
|
||||||
--import Text.RawString.QQ
|
--import Text.RawString.QQ
|
||||||
import Linear.Matrix
|
--import Linear.Matrix
|
||||||
import Linear.V4
|
--import Linear.V4
|
||||||
|
|
||||||
bindArrayBuffers :: Int -> VBO -> IO ()
|
bindArrayBuffers :: Int -> VBO -> IO ()
|
||||||
bindArrayBuffers numVs theVBO = do
|
bindArrayBuffers numVs theVBO = do
|
||||||
bindBuffer ArrayBuffer $= Just (_vbo theVBO)
|
bindBuffer ArrayBuffer $= Just (_vbo theVBO)
|
||||||
bufferData ArrayBuffer $=
|
-- bufferData ArrayBuffer $=
|
||||||
(fromIntegral $ floatSize * numVs * sum (_vboAttribSizes theVBO), _vboPointer theVBO, DynamicDraw)
|
-- (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 :: [FullShader] -> [Int] -> IO ()
|
||||||
bindShaderBuffers = zipWithM_ f
|
bindShaderBuffers = zipWithM_ f
|
||||||
|
|||||||
@@ -68,6 +68,12 @@ setupVBO sizes = do
|
|||||||
forM_ (zip3 [0..] sizes offs) $ \(loc,siz,off) -> do
|
forM_ (zip3 [0..] sizes offs) $ \(loc,siz,off) -> do
|
||||||
setupVertexAttribPointer loc siz strd off
|
setupVertexAttribPointer loc siz strd off
|
||||||
thePtr <- mallocArray (strd * numDrawableElements)
|
thePtr <- mallocArray (strd * numDrawableElements)
|
||||||
|
-- Allocate space
|
||||||
|
bufferData ArrayBuffer $=
|
||||||
|
(fromIntegral $ floatSize * numDrawableElements * strd
|
||||||
|
, nullPtr
|
||||||
|
, DynamicDraw
|
||||||
|
)
|
||||||
return $ VBO
|
return $ VBO
|
||||||
{ _vbo = vboName
|
{ _vbo = vboName
|
||||||
, _vboPointer = thePtr
|
, _vboPointer = thePtr
|
||||||
|
|||||||
Reference in New Issue
Block a user