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
(windowPoints, wallSPics, wallsToPoke) = wallsToDraw w
lightPoints = lightsToRender cfig (w ^. wCam) (w ^. cWorld . lWorld)
--(V2 vfx vfy) = w ^. wCam . camViewFrom
shadV = _pictureShaders pdata
nFls = w ^. cWorld . numberFloorVerxs
nchs = w ^. cWorld . numberChasmVerxs
+3 -3
View File
@@ -44,11 +44,11 @@ bufferShaderLayers shads counts = MV.imapM_ f shads
where
g stride theVBO lay = do
numVs <- UMV.unsafeRead counts $ lay * numLayers + i
glNamedBufferSubDataH
glNamedBufferSubData
(_vboName theVBO)
(fromIntegral $ floatSize * stride * numSubElements * lay)
(fromIntegral $ floatSize * numVs * stride)
(_vboPtr theVBO `plusPtr` (floatSize * stride * numSubElements * lay))
glNamedBufferSubDataH :: GLuint -> GLintptr -> GLsizeiptr -> Ptr a -> IO ()
glNamedBufferSubDataH = glNamedBufferSubData
--glNamedBufferSubDataH :: GLuint -> GLintptr -> GLsizeiptr -> Ptr a -> IO ()
--glNamedBufferSubDataH = glNamedBufferSubData
+12 -6
View File
@@ -86,12 +86,14 @@ setupVBO vertexsize = do
-- unclear whether this should also be multiplied by floatSize
thePtr <- mallocBytes (vertexsize * numDrawableVertices)
-- Allocate space
glNamedBufferData
--glNamedBufferData
glNamedBufferStorage
vboname
(fromIntegral $ floatSize * numDrawableVertices * vertexsize)
-- (fromIntegral $ numDrawableVertices * vertexsize)
nullPtr
GL_STREAM_DRAW
--GL_STREAM_DRAW
GL_DYNAMIC_STORAGE_BIT
return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexBytes = vertexsize}
-- the input ptr is assumed to contain the correct amount of data according to
@@ -118,11 +120,13 @@ setupVBOStatic vertexsize = do
vboname <- mglCreate glCreateBuffers
thePtr <- mallocBytes (vertexsize * numDrawableVertices)
-- Allocate space
glNamedBufferData
--glNamedBufferData
glNamedBufferStorage
vboname
(fromIntegral $ numDrawableVertices * vertexsize)
nullPtr
GL_STATIC_DRAW
GL_DYNAMIC_STORAGE_BIT
--GL_STATIC_DRAW
return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexBytes = vertexsize}
makeByteStringShaderUsingVAO ::
@@ -189,11 +193,13 @@ setupEBO :: VAO -> IO EBO
setupEBO vao = do
eboptr <- mallocArray numGLushort
eboname <- mglCreate glCreateBuffers
glNamedBufferData
--glNamedBufferData
glNamedBufferStorage
eboname
(fromIntegral $ glushortSize * numGLushort)
nullPtr
GL_STREAM_DRAW
GL_DYNAMIC_STORAGE_BIT
--GL_STREAM_DRAW
glVertexArrayElementBuffer (vao ^. vaoName) eboname
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,
and its buffer targets.
-}
newtype VAO = VAO
{ _vaoName :: GLuint
}
newtype VAO = VAO { _vaoName :: GLuint }
data VertexAttribute = VertexAttribute
{ _vaCount :: GLint