Attach EBOs to VAOs using DSA
This commit is contained in:
+23
-29
@@ -35,24 +35,23 @@ preloadRender = do
|
||||
wpVBOname <- mglCreateSingle glCreateBuffers
|
||||
wpVBOptr <- mallocArray (8 * numDrawableWalls)
|
||||
glBindBuffer GL_ARRAY_BUFFER wpVBOname
|
||||
bufferData ArrayBuffer
|
||||
$= ( fromIntegral $ floatSize * numDrawableWalls * 8
|
||||
, nullPtr
|
||||
, StreamDraw
|
||||
)
|
||||
glNamedBufferData wpVBOname
|
||||
( fromIntegral $ floatSize * numDrawableWalls * 8)
|
||||
nullPtr
|
||||
GL_STREAM_DRAW
|
||||
let wpVBO = VBO{_vboName = wpVBOname, _vboPtr = wpVBOptr, _vboAttribSizes = [4, 4], _vboStride = 8}
|
||||
-- wpVAOname <- genObjectName
|
||||
-- bindVertexArrayObject $= Just wpVAOname
|
||||
wpVAOname <- mglCreateSingle glCreateVertexArrays
|
||||
glBindVertexArray wpVAOname
|
||||
glBindBuffer GL_ARRAY_BUFFER wpVBOname
|
||||
setupVertexAttribPointer 0 4 8 0
|
||||
setupVertexAttribPointer wpVAOname wpVBOname 0 4 8 0
|
||||
--wpColVAOname <- genObjectName
|
||||
--bindVertexArrayObject $= Just wpColVAOname
|
||||
wpColVAOname <- mglCreateSingle glCreateVertexArrays
|
||||
glBindVertexArray wpColVAOname
|
||||
setupVertexAttribPointer 0 4 8 0
|
||||
setupVertexAttribPointer 1 4 8 4
|
||||
setupVertexAttribPointer wpColVAOname wpVBOname 0 4 8 0
|
||||
setupVertexAttribPointer wpColVAOname wpVBOname 1 4 8 4
|
||||
let wpVAO = VAO{_vaoName = wpVAOname, _vaoVBO = wpVBO}
|
||||
wpColVAO = VAO{_vaoName = wpColVAOname, _vaoVBO = wpVBO}
|
||||
-- setup window points VBO, VAOs and shaders
|
||||
@@ -69,19 +68,12 @@ preloadRender = do
|
||||
--bindVertexArrayObject $= Just winColVAOname
|
||||
winColVAOname <- mglCreateSingle glCreateVertexArrays
|
||||
glBindVertexArray winColVAOname
|
||||
setupVertexAttribPointer 0 4 8 0
|
||||
setupVertexAttribPointer 1 4 8 4
|
||||
setupVertexAttribPointer winColVAOname winVBOname 0 4 8 0
|
||||
setupVertexAttribPointer winColVAOname winVBOname 1 4 8 4
|
||||
let winColVAO = VAO{_vaoName = winColVAOname, _vaoVBO = winVBO}
|
||||
-- setup shape geometry/cap VBO and two VAOs
|
||||
--shEBOname <- genObjectName
|
||||
shEBOptr <- mallocArray numDrawableElements
|
||||
shEBOname <- mglCreateSingle glCreateBuffers
|
||||
--bindBuffer ElementArrayBuffer $= Just shEBOname
|
||||
--bufferData ElementArrayBuffer
|
||||
-- $= ( fromIntegral $ glushortSize * numDrawableElements
|
||||
-- , nullPtr
|
||||
-- , StreamDraw
|
||||
-- )
|
||||
glNamedBufferData
|
||||
shEBOname
|
||||
( fromIntegral $ glushortSize * numDrawableElements)
|
||||
@@ -91,29 +83,30 @@ preloadRender = do
|
||||
shVBOname <- mglCreateSingle glCreateBuffers
|
||||
shVBOptr <- mallocArray (7 * numDrawableElements)
|
||||
glBindBuffer GL_ARRAY_BUFFER shVBOname
|
||||
bufferData ArrayBuffer
|
||||
$= ( fromIntegral $ floatSize * numDrawableElements * 7
|
||||
, nullPtr
|
||||
, StreamDraw
|
||||
)
|
||||
glNamedBufferData shVBOname
|
||||
( fromIntegral $ floatSize * numDrawableElements * 7)
|
||||
nullPtr
|
||||
GL_STREAM_DRAW
|
||||
let shVBO = VBO{_vboName = shVBOname, _vboPtr = shVBOptr, _vboAttribSizes = [4, 4], _vboStride = 8}
|
||||
--shPosColVAOname <- genObjectName
|
||||
--bindVertexArrayObject $= Just shPosColVAOname
|
||||
shPosColVAOname <- mglCreateSingle glCreateVertexArrays
|
||||
glBindVertexArray shPosColVAOname
|
||||
glBindBuffer GL_ARRAY_BUFFER shVBOname
|
||||
setupVertexAttribPointer 0 3 7 0
|
||||
setupVertexAttribPointer 1 4 7 3
|
||||
setupVertexAttribPointer shPosColVAOname shVBOname 0 3 7 0
|
||||
setupVertexAttribPointer shPosColVAOname shVBOname 1 4 7 3
|
||||
--bindBuffer ElementArrayBuffer $= Just shEBOname
|
||||
glBindBuffer GL_ELEMENT_ARRAY_BUFFER shEBOname
|
||||
--glBindBuffer GL_ELEMENT_ARRAY_BUFFER shEBOname
|
||||
glVertexArrayElementBuffer shPosColVAOname shEBOname
|
||||
--shPosVAOname <- genObjectName
|
||||
--bindVertexArrayObject $= Just shPosVAOname
|
||||
shPosVAOname <- mglCreateSingle glCreateVertexArrays
|
||||
glBindVertexArray shPosVAOname
|
||||
glBindBuffer GL_ARRAY_BUFFER shVBOname
|
||||
setupVertexAttribPointer 0 3 7 0
|
||||
setupVertexAttribPointer shPosVAOname shVBOname 0 3 7 0
|
||||
--bindBuffer ElementArrayBuffer $= Just shEBOname
|
||||
glBindBuffer GL_ELEMENT_ARRAY_BUFFER shEBOname
|
||||
--glBindBuffer GL_ELEMENT_ARRAY_BUFFER shEBOname
|
||||
glVertexArrayElementBuffer shPosVAOname shEBOname
|
||||
let shPosColVAO = VAO{_vaoName = shPosColVAOname, _vaoVBO = shVBO}
|
||||
shPosVAO = VAO{_vaoName = shPosVAOname, _vaoVBO = shVBO}
|
||||
--setup silhouette edge VAO
|
||||
@@ -122,12 +115,13 @@ preloadRender = do
|
||||
shEdgeVAOname <- mglCreateSingle glCreateVertexArrays
|
||||
glBindVertexArray shEdgeVAOname
|
||||
glBindBuffer GL_ARRAY_BUFFER shVBOname
|
||||
setupVertexAttribPointer 0 3 7 0
|
||||
setupVertexAttribPointer shEdgeVAOname shVBOname 0 3 7 0
|
||||
--setup ebo for silhouette edges
|
||||
silEBOname <- mglCreateSingle glCreateBuffers
|
||||
silEBOptr <- mallocArray numDrawableElements
|
||||
-- it may be important to bind this while the correct VAO is bound
|
||||
glBindBuffer GL_ELEMENT_ARRAY_BUFFER silEBOname --bindBuffer ElementArrayBuffer $= Just silEBOname
|
||||
--glBindBuffer GL_ELEMENT_ARRAY_BUFFER silEBOname --bindBuffer ElementArrayBuffer $= Just silEBOname
|
||||
glVertexArrayElementBuffer shEdgeVAOname silEBOname
|
||||
--bindBuffer ElementArrayBuffer $= Just silEBOname
|
||||
glNamedBufferData
|
||||
silEBOname
|
||||
|
||||
Reference in New Issue
Block a user