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
+13 -11
View File
@@ -5,6 +5,7 @@ module Preload.Render (
cleanUpRenderPreload,
) where
import Shape.Data
import Geometry.Data
import MatrixHelper
import GLHelp
@@ -32,9 +33,9 @@ preloadRender = do
glNamedBufferData theUBO 64 nullPtr GL_STREAM_DRAW
glBindBufferBase GL_UNIFORM_BUFFER 0 theUBO
isoUBO <- mglCreate glCreateBuffers
orthonormalUBO <- mglCreate glCreateBuffers
withArray (isoMatrix 0 1 (V2 0 0) (V2 2 2)) $ \ptr ->
glNamedBufferStorage isoUBO 64 ptr 0
glNamedBufferStorage orthonormalUBO 64 ptr 0
lightsubo <- mglCreate glCreateBuffers
glNamedBufferData lightsubo 640 nullPtr GL_STREAM_DRAW
@@ -61,8 +62,8 @@ preloadRender = do
glVertexArrayVertexBuffer wpColVAOname 0 wpVBOname 0 (fromIntegral $ floatSize * 8)
setupVertexAttribPointer wpColVAOname 0 4 0
setupVertexAttribPointer wpColVAOname 1 4 4
let wpVAO = VAO{_vaoName = wpVAOname, _vaoAttribSizes = [4], _vaoStride = 8}
wpColVAO = VAO{_vaoName = wpColVAOname, _vaoAttribSizes = [4,4], _vaoStride = 8}
let wpVAO = VAO{_vaoName = wpVAOname}
wpColVAO = VAO{_vaoName = wpColVAOname}
-- setup window points VBO, VAOs and shaders
winVBOname <- mglCreate glCreateBuffers
winVBOptr <- mallocArray (8 * numDrawableWalls)
@@ -79,7 +80,7 @@ preloadRender = do
setupVertexAttribPointer winColVAOname 0 4 0
setupVertexAttribPointer winColVAOname 1 4 4
let winColVAO = VAO
{_vaoName = winColVAOname, _vaoAttribSizes = [4,4], _vaoStride = 8}
{_vaoName = winColVAOname}
-- setup shape geometry/cap VBO and two VAOs
shEBOptr <- mallocArray numDrawableElements
shEBOname <- mglCreate glCreateBuffers
@@ -89,17 +90,17 @@ preloadRender = do
nullPtr
GL_STREAM_DRAW
let shEBO = EBO{_eboName = shEBOname, _eboPtr = shEBOptr}
shVBO <- setupVBO4 8
shVBO <- setupVBO nShapeVerxComp
shPosVAOname <- mglCreate glCreateVertexArrays
glBindVertexArray shPosVAOname
glVertexArrayVertexBuffer shPosVAOname 0 (shVBO ^. vboName) 0 (fromIntegral $ floatSize * 8)
glVertexArrayVertexBuffer shPosVAOname 0 (shVBO ^. vboName) 0 (fromIntegral $ floatSize * nShapeVerxComp)
setupVertexAttribPointer shPosVAOname 0 4 0
glVertexArrayElementBuffer shPosVAOname shEBOname
let shPosVAO = VAO{_vaoName = shPosVAOname, _vaoAttribSizes = [4], _vaoStride = 8}
let shPosVAO = VAO{_vaoName = shPosVAOname}
--setup silhouette edge VAO
shEdgeVAOname <- mglCreate glCreateVertexArrays
glBindVertexArray shEdgeVAOname
glVertexArrayVertexBuffer shEdgeVAOname 0 (shVBO ^. vboName) 0 (fromIntegral $ floatSize * 8)
glVertexArrayVertexBuffer shEdgeVAOname 0 (shVBO ^. vboName) 0 (fromIntegral $ floatSize * nShapeVerxComp)
setupVertexAttribPointer shEdgeVAOname 0 4 0
--setup ebo for silhouette edges
silEBOname <- mglCreate glCreateBuffers
@@ -111,7 +112,7 @@ preloadRender = do
nullPtr
GL_STREAM_DRAW
let silEBO = EBO{_eboName = silEBOname, _eboPtr = silEBOptr}
shEdgeVAO = VAO{_vaoName = shEdgeVAOname, _vaoAttribSizes = [4], _vaoStride = 8}
shEdgeVAO = VAO{_vaoName = shEdgeVAOname}
-- shEdgeVAO is unecessary?
-- lighting shaders
lightingWallShadShad <-
@@ -265,7 +266,7 @@ preloadRender = do
, _fboPos = fboPosName
, _rboBaseBloom = rboBaseBloomName
, _matUBO = theUBO
, _isoMatUBO = isoUBO
, _orthonormalMatUBO = orthonormalUBO
, _lightsUBO = lightsubo
, _vboWalls = wpVBO
, _vboWindows = winVBO
@@ -294,6 +295,7 @@ initializeGLState :: IO ()
initializeGLState = do
glEnable GL_DEPTH_TEST
cleanUpRenderPreload :: RenderData -> IO ()
cleanUpRenderPreload _ = return ()
--cleanUpRenderPreload pd = do