Change VBO to store vertex size in bytes
This commit is contained in:
+27
-5
@@ -97,7 +97,25 @@ setupVBO vertexsize = do
|
||||
(fromIntegral $ floatSize * numDrawableElements * vertexsize)
|
||||
nullPtr
|
||||
GL_STREAM_DRAW
|
||||
return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexSize = vertexsize}
|
||||
return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexBytes = floatSize * vertexsize}
|
||||
|
||||
---- the input ptr is assumed to contain the correct amount of data according to
|
||||
---- the specified number and type of vertices
|
||||
---- note the VBO here does not have a sensible ptr value
|
||||
--setupStaticVBO :: Int -> [VertexAttribute] -> Ptr a -> IO (VBO,VAO)
|
||||
--setupStaticVBO numvs vas vdata = do
|
||||
-- vboname <- mglCreate glCreateBuffers
|
||||
-- glNamedBufferStorage
|
||||
-- vboname
|
||||
-- (CPtrdiff (fromIntegral (vasTightStride vas)))
|
||||
-- vdata
|
||||
-- 0
|
||||
-- let vbo = VBO
|
||||
-- { _vboName = vboname
|
||||
-- , _vboPtr = nullPtr
|
||||
-- , _vboVertexSize =
|
||||
|
||||
|
||||
|
||||
setupVBOStatic :: Int -> IO VBO
|
||||
setupVBOStatic vertexsize = do
|
||||
@@ -109,7 +127,7 @@ setupVBOStatic vertexsize = do
|
||||
(fromIntegral $ floatSize * numDrawableElements * vertexsize)
|
||||
nullPtr
|
||||
GL_STATIC_DRAW
|
||||
return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexSize = vertexsize}
|
||||
return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexBytes = floatSize * vertexsize}
|
||||
|
||||
makeByteStringShaderUsingVAO ::
|
||||
-- | (Arbitrary) name of the shader
|
||||
@@ -203,11 +221,11 @@ setupVAOvbo sizes strd vbo = do
|
||||
|
||||
setupVAOUsingVBO :: [VertexAttribute] -> VBO -> IO VAO
|
||||
setupVAOUsingVBO vas vbo = do
|
||||
let strd = vbo ^. vboVertexSize
|
||||
let strd = vbo ^. vboVertexBytes
|
||||
vaoname <- mglCreate glCreateVertexArrays
|
||||
glBindVertexArray vaoname
|
||||
setupVertexAttribs (vbo ^. vboName) vaoname vas
|
||||
(fromIntegral strd * fromIntegral floatSize)
|
||||
(fromIntegral strd)
|
||||
return VAO{_vaoName = vaoname}
|
||||
|
||||
setupEBO :: VAO -> IO EBO
|
||||
@@ -227,8 +245,12 @@ setupVBOVAO sizes = do
|
||||
vaoname <- mglCreate glCreateVertexArrays
|
||||
glBindVertexArray vaoname
|
||||
vbo <- setupVBO (sum sizes)
|
||||
vao <- setupVAOvbo (toFloatVAs sizes) (sum sizes) (vbo ^. vboName)
|
||||
--vao <- setupVAOvbo (toFloatVAs sizes) (sum sizes) (vbo ^. vboName)
|
||||
vao <- setupVAOUsingVBO (toFloatVAs sizes) vbo
|
||||
return (vao,vbo)
|
||||
where
|
||||
vas = toFloatVAs sizes
|
||||
strd = vasTightStride vas
|
||||
|
||||
toFloatVAs :: [Int] -> [VertexAttribute]
|
||||
toFloatVAs = go 0
|
||||
|
||||
Reference in New Issue
Block a user