Make the matrix UBO use raw opengl
This commit is contained in:
@@ -45,7 +45,7 @@ data RenderData = RenderData
|
|||||||
, _fboLighting :: (FramebufferObject, TextureObject)
|
, _fboLighting :: (FramebufferObject, TextureObject)
|
||||||
, _fboLightingHigh :: (FramebufferObject, TextureObject)
|
, _fboLightingHigh :: (FramebufferObject, TextureObject)
|
||||||
, _fboShadow :: (FramebufferObject, (TextureObject,TextureObject))
|
, _fboShadow :: (FramebufferObject, (TextureObject,TextureObject))
|
||||||
, _matUBO :: BufferObject
|
, _matUBO :: GLuint
|
||||||
}
|
}
|
||||||
makeLenses ''RenderData
|
makeLenses ''RenderData
|
||||||
|
|
||||||
|
|||||||
+7
-14
@@ -27,14 +27,16 @@ numDrawableWalls = 5000
|
|||||||
preloadRender :: IO RenderData
|
preloadRender :: IO RenderData
|
||||||
preloadRender = do
|
preloadRender = do
|
||||||
-- set up uniform buffer object
|
-- set up uniform buffer object
|
||||||
theUBO <- genObjectName
|
theUBO <- mglCreateSingle glCreateBuffers
|
||||||
bindBuffer UniformBuffer $= Just theUBO
|
--glBindBuffer GL_UNIFORM_BUFFER theUBO
|
||||||
bufferData UniformBuffer $= (64, nullPtr, StreamDraw)
|
--bindBuffer UniformBuffer $= Just theUBO
|
||||||
bindBufferBase IndexedUniformBuffer 0 $= Just theUBO
|
glNamedBufferData theUBO 64 nullPtr GL_STREAM_DRAW
|
||||||
|
--bufferData UniformBuffer $= (64, nullPtr, StreamDraw)
|
||||||
|
--bindBufferBase IndexedUniformBuffer 0 $= Just theUBO
|
||||||
|
glBindBufferBase GL_UNIFORM_BUFFER 0 theUBO
|
||||||
-- setup wall points VBO, VAOs and shaders
|
-- setup wall points VBO, VAOs and shaders
|
||||||
wpVBOname <- mglCreateSingle glCreateBuffers
|
wpVBOname <- mglCreateSingle glCreateBuffers
|
||||||
wpVBOptr <- mallocArray (8 * numDrawableWalls)
|
wpVBOptr <- mallocArray (8 * numDrawableWalls)
|
||||||
glBindBuffer GL_ARRAY_BUFFER wpVBOname
|
|
||||||
glNamedBufferData wpVBOname
|
glNamedBufferData wpVBOname
|
||||||
( fromIntegral $ floatSize * numDrawableWalls * 8)
|
( fromIntegral $ floatSize * numDrawableWalls * 8)
|
||||||
nullPtr
|
nullPtr
|
||||||
@@ -44,7 +46,6 @@ preloadRender = do
|
|||||||
-- bindVertexArrayObject $= Just wpVAOname
|
-- bindVertexArrayObject $= Just wpVAOname
|
||||||
wpVAOname <- mglCreateSingle glCreateVertexArrays
|
wpVAOname <- mglCreateSingle glCreateVertexArrays
|
||||||
glBindVertexArray wpVAOname
|
glBindVertexArray wpVAOname
|
||||||
glBindBuffer GL_ARRAY_BUFFER wpVBOname
|
|
||||||
setupVertexAttribPointer wpVAOname wpVBOname 0 4 8 0
|
setupVertexAttribPointer wpVAOname wpVBOname 0 4 8 0
|
||||||
--wpColVAOname <- genObjectName
|
--wpColVAOname <- genObjectName
|
||||||
--bindVertexArrayObject $= Just wpColVAOname
|
--bindVertexArrayObject $= Just wpColVAOname
|
||||||
@@ -57,7 +58,6 @@ preloadRender = do
|
|||||||
-- setup window points VBO, VAOs and shaders
|
-- setup window points VBO, VAOs and shaders
|
||||||
winVBOname <- mglCreateSingle glCreateBuffers
|
winVBOname <- mglCreateSingle glCreateBuffers
|
||||||
winVBOptr <- mallocArray (8 * numDrawableWalls)
|
winVBOptr <- mallocArray (8 * numDrawableWalls)
|
||||||
glBindBuffer GL_ARRAY_BUFFER winVBOname
|
|
||||||
bufferData ArrayBuffer
|
bufferData ArrayBuffer
|
||||||
$= ( fromIntegral $ floatSize * numDrawableWalls * 8
|
$= ( fromIntegral $ floatSize * numDrawableWalls * 8
|
||||||
, nullPtr
|
, nullPtr
|
||||||
@@ -82,7 +82,6 @@ preloadRender = do
|
|||||||
let shEBO = EBO{_eboName = shEBOname, _eboPtr = shEBOptr}
|
let shEBO = EBO{_eboName = shEBOname, _eboPtr = shEBOptr}
|
||||||
shVBOname <- mglCreateSingle glCreateBuffers
|
shVBOname <- mglCreateSingle glCreateBuffers
|
||||||
shVBOptr <- mallocArray (7 * numDrawableElements)
|
shVBOptr <- mallocArray (7 * numDrawableElements)
|
||||||
glBindBuffer GL_ARRAY_BUFFER shVBOname
|
|
||||||
glNamedBufferData shVBOname
|
glNamedBufferData shVBOname
|
||||||
( fromIntegral $ floatSize * numDrawableElements * 7)
|
( fromIntegral $ floatSize * numDrawableElements * 7)
|
||||||
nullPtr
|
nullPtr
|
||||||
@@ -92,20 +91,16 @@ preloadRender = do
|
|||||||
--bindVertexArrayObject $= Just shPosColVAOname
|
--bindVertexArrayObject $= Just shPosColVAOname
|
||||||
shPosColVAOname <- mglCreateSingle glCreateVertexArrays
|
shPosColVAOname <- mglCreateSingle glCreateVertexArrays
|
||||||
glBindVertexArray shPosColVAOname
|
glBindVertexArray shPosColVAOname
|
||||||
glBindBuffer GL_ARRAY_BUFFER shVBOname
|
|
||||||
setupVertexAttribPointer shPosColVAOname shVBOname 0 3 7 0
|
setupVertexAttribPointer shPosColVAOname shVBOname 0 3 7 0
|
||||||
setupVertexAttribPointer shPosColVAOname shVBOname 1 4 7 3
|
setupVertexAttribPointer shPosColVAOname shVBOname 1 4 7 3
|
||||||
--bindBuffer ElementArrayBuffer $= Just shEBOname
|
--bindBuffer ElementArrayBuffer $= Just shEBOname
|
||||||
--glBindBuffer GL_ELEMENT_ARRAY_BUFFER shEBOname
|
|
||||||
glVertexArrayElementBuffer shPosColVAOname shEBOname
|
glVertexArrayElementBuffer shPosColVAOname shEBOname
|
||||||
--shPosVAOname <- genObjectName
|
--shPosVAOname <- genObjectName
|
||||||
--bindVertexArrayObject $= Just shPosVAOname
|
--bindVertexArrayObject $= Just shPosVAOname
|
||||||
shPosVAOname <- mglCreateSingle glCreateVertexArrays
|
shPosVAOname <- mglCreateSingle glCreateVertexArrays
|
||||||
glBindVertexArray shPosVAOname
|
glBindVertexArray shPosVAOname
|
||||||
glBindBuffer GL_ARRAY_BUFFER shVBOname
|
|
||||||
setupVertexAttribPointer shPosVAOname shVBOname 0 3 7 0
|
setupVertexAttribPointer shPosVAOname shVBOname 0 3 7 0
|
||||||
--bindBuffer ElementArrayBuffer $= Just shEBOname
|
--bindBuffer ElementArrayBuffer $= Just shEBOname
|
||||||
--glBindBuffer GL_ELEMENT_ARRAY_BUFFER shEBOname
|
|
||||||
glVertexArrayElementBuffer shPosVAOname shEBOname
|
glVertexArrayElementBuffer shPosVAOname shEBOname
|
||||||
let shPosColVAO = VAO{_vaoName = shPosColVAOname, _vaoVBO = shVBO}
|
let shPosColVAO = VAO{_vaoName = shPosColVAOname, _vaoVBO = shVBO}
|
||||||
shPosVAO = VAO{_vaoName = shPosVAOname, _vaoVBO = shVBO}
|
shPosVAO = VAO{_vaoName = shPosVAOname, _vaoVBO = shVBO}
|
||||||
@@ -114,13 +109,11 @@ preloadRender = do
|
|||||||
--bindVertexArrayObject $= Just shEdgeVAOname
|
--bindVertexArrayObject $= Just shEdgeVAOname
|
||||||
shEdgeVAOname <- mglCreateSingle glCreateVertexArrays
|
shEdgeVAOname <- mglCreateSingle glCreateVertexArrays
|
||||||
glBindVertexArray shEdgeVAOname
|
glBindVertexArray shEdgeVAOname
|
||||||
glBindBuffer GL_ARRAY_BUFFER shVBOname
|
|
||||||
setupVertexAttribPointer shEdgeVAOname shVBOname 0 3 7 0
|
setupVertexAttribPointer shEdgeVAOname shVBOname 0 3 7 0
|
||||||
--setup ebo for silhouette edges
|
--setup ebo for silhouette edges
|
||||||
silEBOname <- mglCreateSingle glCreateBuffers
|
silEBOname <- mglCreateSingle glCreateBuffers
|
||||||
silEBOptr <- mallocArray numDrawableElements
|
silEBOptr <- mallocArray numDrawableElements
|
||||||
-- it may be important to bind this while the correct VAO is bound
|
-- it may be important to bind this while the correct VAO is bound
|
||||||
--glBindBuffer GL_ELEMENT_ARRAY_BUFFER silEBOname --bindBuffer ElementArrayBuffer $= Just silEBOname
|
|
||||||
glVertexArrayElementBuffer shEdgeVAOname silEBOname
|
glVertexArrayElementBuffer shEdgeVAOname silEBOname
|
||||||
--bindBuffer ElementArrayBuffer $= Just silEBOname
|
--bindBuffer ElementArrayBuffer $= Just silEBOname
|
||||||
glNamedBufferData
|
glNamedBufferData
|
||||||
|
|||||||
@@ -178,7 +178,8 @@ setupVertexAttribPointer ::
|
|||||||
Int ->
|
Int ->
|
||||||
IO ()
|
IO ()
|
||||||
setupVertexAttribPointer vao vbo loc siz strd off = do
|
setupVertexAttribPointer vao vbo loc siz strd off = do
|
||||||
glVertexArrayVertexBuffer vao 0 vbo 0 (fromIntegral $ floatSize * strd)
|
glVertexArrayVertexBuffer vao 0 vbo 0 (fromIntegral $ floatSize * strd)
|
||||||
|
-- the above is probably duplicated: needs moving out of this function
|
||||||
glEnableVertexArrayAttrib vao loc'
|
glEnableVertexArrayAttrib vao loc'
|
||||||
glVertexArrayAttribFormat vao loc' siz' GL_FLOAT GL_FALSE (fromIntegral $ floatSize * off)
|
glVertexArrayAttribFormat vao loc' siz' GL_FLOAT GL_FALSE (fromIntegral $ floatSize * off)
|
||||||
glVertexArrayAttribBinding vao loc' 0
|
glVertexArrayAttribBinding vao loc' 0
|
||||||
|
|||||||
Reference in New Issue
Block a user