Move from glNamedBufferData to glNamedBufferStorage

This commit is contained in:
2025-11-09 21:11:55 +00:00
parent 7ae50adb55
commit 187751ec26
4 changed files with 16 additions and 13 deletions
-1
View File
@@ -50,7 +50,6 @@ doDrawing' win pdata u = do
cfig = _uvConfig u cfig = _uvConfig u
(windowPoints, wallSPics, wallsToPoke) = wallsToDraw w (windowPoints, wallSPics, wallsToPoke) = wallsToDraw w
lightPoints = lightsToRender cfig (w ^. wCam) (w ^. cWorld . lWorld) lightPoints = lightsToRender cfig (w ^. wCam) (w ^. cWorld . lWorld)
--(V2 vfx vfy) = w ^. wCam . camViewFrom
shadV = _pictureShaders pdata shadV = _pictureShaders pdata
nFls = w ^. cWorld . numberFloorVerxs nFls = w ^. cWorld . numberFloorVerxs
nchs = w ^. cWorld . numberChasmVerxs nchs = w ^. cWorld . numberChasmVerxs
+3 -3
View File
@@ -44,11 +44,11 @@ bufferShaderLayers shads counts = MV.imapM_ f shads
where where
g stride theVBO lay = do g stride theVBO lay = do
numVs <- UMV.unsafeRead counts $ lay * numLayers + i numVs <- UMV.unsafeRead counts $ lay * numLayers + i
glNamedBufferSubDataH glNamedBufferSubData
(_vboName theVBO) (_vboName theVBO)
(fromIntegral $ floatSize * stride * numSubElements * lay) (fromIntegral $ floatSize * stride * numSubElements * lay)
(fromIntegral $ floatSize * numVs * stride) (fromIntegral $ floatSize * numVs * stride)
(_vboPtr theVBO `plusPtr` (floatSize * stride * numSubElements * lay)) (_vboPtr theVBO `plusPtr` (floatSize * stride * numSubElements * lay))
glNamedBufferSubDataH :: GLuint -> GLintptr -> GLsizeiptr -> Ptr a -> IO () --glNamedBufferSubDataH :: GLuint -> GLintptr -> GLsizeiptr -> Ptr a -> IO ()
glNamedBufferSubDataH = glNamedBufferSubData --glNamedBufferSubDataH = glNamedBufferSubData
+12 -6
View File
@@ -86,12 +86,14 @@ setupVBO vertexsize = do
-- unclear whether this should also be multiplied by floatSize -- unclear whether this should also be multiplied by floatSize
thePtr <- mallocBytes (vertexsize * numDrawableVertices) thePtr <- mallocBytes (vertexsize * numDrawableVertices)
-- Allocate space -- Allocate space
glNamedBufferData --glNamedBufferData
glNamedBufferStorage
vboname vboname
(fromIntegral $ floatSize * numDrawableVertices * vertexsize) (fromIntegral $ floatSize * numDrawableVertices * vertexsize)
-- (fromIntegral $ numDrawableVertices * vertexsize) -- (fromIntegral $ numDrawableVertices * vertexsize)
nullPtr nullPtr
GL_STREAM_DRAW --GL_STREAM_DRAW
GL_DYNAMIC_STORAGE_BIT
return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexBytes = vertexsize} return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexBytes = vertexsize}
-- the input ptr is assumed to contain the correct amount of data according to -- the input ptr is assumed to contain the correct amount of data according to
@@ -118,11 +120,13 @@ setupVBOStatic vertexsize = do
vboname <- mglCreate glCreateBuffers vboname <- mglCreate glCreateBuffers
thePtr <- mallocBytes (vertexsize * numDrawableVertices) thePtr <- mallocBytes (vertexsize * numDrawableVertices)
-- Allocate space -- Allocate space
glNamedBufferData --glNamedBufferData
glNamedBufferStorage
vboname vboname
(fromIntegral $ numDrawableVertices * vertexsize) (fromIntegral $ numDrawableVertices * vertexsize)
nullPtr nullPtr
GL_STATIC_DRAW GL_DYNAMIC_STORAGE_BIT
--GL_STATIC_DRAW
return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexBytes = vertexsize} return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexBytes = vertexsize}
makeByteStringShaderUsingVAO :: makeByteStringShaderUsingVAO ::
@@ -189,11 +193,13 @@ setupEBO :: VAO -> IO EBO
setupEBO vao = do setupEBO vao = do
eboptr <- mallocArray numGLushort eboptr <- mallocArray numGLushort
eboname <- mglCreate glCreateBuffers eboname <- mglCreate glCreateBuffers
glNamedBufferData --glNamedBufferData
glNamedBufferStorage
eboname eboname
(fromIntegral $ glushortSize * numGLushort) (fromIntegral $ glushortSize * numGLushort)
nullPtr nullPtr
GL_STREAM_DRAW GL_DYNAMIC_STORAGE_BIT
--GL_STREAM_DRAW
glVertexArrayElementBuffer (vao ^. vaoName) eboname glVertexArrayElementBuffer (vao ^. vaoName) eboname
return $ EBO eboname eboptr return $ EBO eboname eboptr
+1 -3
View File
@@ -61,9 +61,7 @@ newtype TO = TO {_unTO :: GLuint}
{- | Vertex array object: contains the reference to the object, {- | Vertex array object: contains the reference to the object,
and its buffer targets. and its buffer targets.
-} -}
newtype VAO = VAO newtype VAO = VAO { _vaoName :: GLuint }
{ _vaoName :: GLuint
}
data VertexAttribute = VertexAttribute data VertexAttribute = VertexAttribute
{ _vaCount :: GLint { _vaCount :: GLint