Try to centralize the number of components per vertex in shapes

This commit is contained in:
2023-03-14 23:28:21 +00:00
parent cfddd1515f
commit 21f87b96d8
7 changed files with 27 additions and 32 deletions
+3 -7
View File
@@ -1,5 +1,5 @@
module Shader.Compile (
setupVBO4,
setupVBO,
makeShader,
makeShader4,
makeByteStringShaderUsingVAO,
@@ -67,8 +67,8 @@ makeShader4 s shaderlist sizes pm vbo = do
, _shadUnis' = mempty
}
setupVBO4 :: Int -> IO VBO
setupVBO4 vertexsize = do
setupVBO :: Int -> IO VBO
setupVBO vertexsize = do
vboname <- mglCreate glCreateBuffers
thePtr <- mallocArray (vertexsize * numDrawableElements)
-- Allocate space
@@ -170,8 +170,6 @@ setupVAOvbo sizes vbo = do
setupVertexAttribs vbo vaoname sizes
return $ VAO
{ _vaoName = vaoname
, _vaoAttribSizes = sizes
, _vaoStride = sum sizes
}
setupVAOSized :: Int -> [Int] -> IO (VAO,VBO)
@@ -181,8 +179,6 @@ setupVAOSized ndraw sizes = do
theVBO <- setupVBOSized ndraw vaoname sizes
return ( VAO
{ _vaoName = vaoname
, _vaoAttribSizes = sizes
, _vaoStride = sum sizes
}
, theVBO)
+3 -5
View File
@@ -12,8 +12,8 @@ module Shader.Data
-- | Lens functions
, vaoName
-- , vaoVBO
, vaoAttribSizes
, vaoStride
-- , vaoAttribSizes
-- , vaoStride
, vboName
, vboPtr
@@ -46,10 +46,8 @@ data FullShader = FullShader
}
{- | Vertex array object: contains the reference to the object,
and its buffer targets. -}
data VAO = VAO
newtype VAO = VAO
{ _vaoName :: GLuint
, _vaoAttribSizes :: [Int] -- ^ It is not clear to me if this is necessary to store or not
, _vaoStride :: Int
}
{- | Vertex buffer object: contains the reference to the object,
a pointer to a location with space that can be written to the buffer,
+1 -1
View File
@@ -181,7 +181,7 @@ pokeJustV ptr nv sh = do
pokeElemOff ptr (off 7) a
return (nv + 1)
where
off i = nv*8 + i
off i = nv*nShapeVerxComp + i
V3 x y z = _svPos sh
V4 r g b a = _svCol sh