Continue render refactor

This commit is contained in:
2023-03-14 14:11:14 +00:00
parent 35f401d8c8
commit 378af69ca5
12 changed files with 118 additions and 112 deletions
+14 -15
View File
@@ -29,18 +29,18 @@ makeShader ::
-- | The input vertex sizes
[Int] ->
EPrimitiveMode ->
IO FullShader
IO (FullShader,VBO)
makeShader s shaderlist sizes pm = do
prog <- makeSourcedShader s shaderlist
vaob <- setupVAO sizes
return $
FullShader
(vao,vbo) <- setupVAO sizes
return ( FullShader
{ _shadName = prog
, _shadVAO' = vaob
, _shadVAO' = vao
, _shadPrim' = pm
, _shadTex' = Nothing
, _shadUnis' = mempty
}
, vbo)
makeByteStringShaderUsingVAO ::
-- | (Arbitrary) name of the shader
@@ -95,18 +95,18 @@ makeShaderSized ::
-- | Number of vertexes that can be poked
Int ->
EPrimitiveMode ->
IO FullShader
IO (FullShader,VBO)
makeShaderSized s shaderlist sizes ndraw pm = do
prog <- makeSourcedShader s shaderlist
vaob <- setupVAOSized ndraw sizes
return $
FullShader
(vao,vbo) <- setupVAOSized ndraw sizes
return ( FullShader
{ _shadName = prog
, _shadVAO' = vaob
, _shadVAO' = vao
, _shadPrim' = pm
, _shadTex' = Nothing
, _shadUnis' = mempty
}
, vbo)
{- | Compile shader and get its uniform locations.
supposes the shader code is in the shader folder, with the string names
@@ -124,21 +124,20 @@ shaderTypeExt' GL_FRAGMENT_SHADER = ".frag"
shaderTypeExt' _ = undefined
-- I think that this requires that the correct shader program is bound?
setupVAO :: [Int] -> IO VAO
setupVAO :: [Int] -> IO (VAO,VBO)
setupVAO = setupVAOSized numDrawableElements
setupVAOSized :: Int -> [Int] -> IO VAO
setupVAOSized :: Int -> [Int] -> IO (VAO,VBO)
setupVAOSized ndraw sizes = do
vaoname <- mglCreate glCreateVertexArrays
glBindVertexArray vaoname
theVBO <- setupVBOSized ndraw vaoname sizes
return $
VAO
return ( VAO
{ _vaoName = vaoname
, _vaoAttribSizes = sizes
, _vaoStride = sum sizes
, _vaoVBO = theVBO
}
, theVBO)
setupVBOSized :: Int -> GLuint -> [Int] -> IO VBO
setupVBOSized ndraw vao sizes = do