Use DSA for renderbuffers

This commit is contained in:
2023-03-09 14:58:38 +00:00
parent 0b698e5f5d
commit 76a8b05433
11 changed files with 81 additions and 74 deletions
+6 -6
View File
@@ -21,10 +21,10 @@ import GLHelp
-- I am not sure if this assumes that the shader is constructed directly before
-- the texture is added...
addTexture :: String -> FullShader' -> IO FullShader'
addTexture :: String -> FullShader -> IO FullShader
addTexture = addTexture2D 3 GL_LINEAR_MIPMAP_LINEAR GL_LINEAR
vaddTextureNoFilter :: String -> FullShader' -> IO FullShader'
vaddTextureNoFilter :: String -> FullShader -> IO FullShader
vaddTextureNoFilter = addTexture2D 1 GL_NEAREST GL_NEAREST
addTexture2D
@@ -32,7 +32,7 @@ addTexture2D
-> GLenum -- minfilter
-> GLenum -- magfilter
-> String -- path to image
-> FullShader' -> IO FullShader'
-> FullShader -> IO FullShader
addTexture2D nlev minfilt magfilt texpath shad = do
Right cmap <- readImage texpath
let texdata = convertRGBA8 cmap
@@ -63,7 +63,7 @@ addTexture2D nlev minfilt magfilt texpath shad = do
-- | for transforming a 256x256 image containing 64 tiles of 16x16 pixels into
-- an image that was directly readable by glTexSubImage3D, used the
-- transformation tilesToLine 8 128 on the underlying pixels.
addTextureArray :: String -> FullShader' -> IO FullShader'
addTextureArray :: String -> FullShader -> IO FullShader
addTextureArray texturePath shad = do
err <- glGetError
print err
@@ -87,10 +87,10 @@ tilesToLine
-> [a]
tilesToLine n w = concat . concat . transpose . chunksOf n . chunksOf w
addUniforms :: [String] -> FullShader' -> IO FullShader'
addUniforms :: [String] -> FullShader -> IO FullShader
addUniforms uniStrings shad = do foldM addUniform shad uniStrings
addUniform :: FullShader' -> String -> IO FullShader'
addUniform :: FullShader -> String -> IO FullShader
addUniform shad unistr = BS.useAsCString (pack unistr) $ \cstr -> do
loc <- glGetUniformLocation (_shadProg' shad) cstr
return $ shad & shadUnis' %~ (V.++ V.fromList [loc])