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