Translate VAOs to DSA

This commit is contained in:
2023-03-09 10:10:57 +00:00
parent 18fa216dff
commit 7b797dfdb4
9 changed files with 61 additions and 32 deletions
+2 -2
View File
@@ -38,7 +38,7 @@ addTexture2D nlev minfilt magfilt texpath shad = do
let texdata = convertRGBA8 cmap
let wtex = fromIntegral $ imageWidth texdata
htex = fromIntegral $ imageHeight texdata
texname <- mglCreateSingle $ glCreateTextures GL_TEXTURE_2D 1
texname <- mglCreateSingle $ glCreateTextures GL_TEXTURE_2D
glTextureStorage2D texname nlev GL_RGBA8 wtex htex
VS.unsafeWith (imageData texdata) $ \ptr -> do
glTextureSubImage2D texname 0 0 0 wtex htex GL_RGBA GL_UNSIGNED_BYTE ptr
@@ -69,7 +69,7 @@ addTextureArray texturePath shad = do
print err
Right cmap <- readImage texturePath
let texdata = convertRGBA8 cmap
texname <- mglCreateSingle $ glCreateTextures GL_TEXTURE_2D_ARRAY 1
texname <- mglCreateSingle $ glCreateTextures GL_TEXTURE_2D_ARRAY
glTextureStorage3D texname 3 GL_RGBA8 32 32 64
VS.unsafeWith (imageData texdata) $ \ptr -> do
glTextureSubImage3D texname 0 0 0 0 32 32 64 GL_RGBA GL_UNSIGNED_BYTE ptr
+11 -6
View File
@@ -8,6 +8,7 @@ module Shader.Compile (
setupVertexAttribPointer,
) where
import GLHelp
import Control.Monad
import qualified Data.ByteString as BS
import qualified Data.ByteString.Unsafe as BU
@@ -129,23 +130,27 @@ shaderTypeExt' _ = undefined
-- I think that this requires that the correct shader program is bound?
setupVAO :: [Int] -> IO VAO
setupVAO sizes = do
theVAO <- genObjectName
bindVertexArrayObject $= Just theVAO
--theVAO <- genObjectName
--bindVertexArrayObject $= Just theVAO
vaoname <- mglCreateSingle glGenVertexArrays
glBindVertexArray vaoname
theVBO <- setupVBO sizes
return $
VAO
{ _vaoName = theVAO
{ _vaoName = vaoname
, _vaoVBO = theVBO
}
setupVAOSized :: [Int] -> Int -> IO VAO
setupVAOSized sizes ndraw = do
theVAO <- genObjectName
bindVertexArrayObject $= Just theVAO
vaoname <- mglCreateSingle glGenVertexArrays
glBindVertexArray vaoname
-- theVAO <- genObjectName
--bindVertexArrayObject $= Just theVAO
theVBO <- setupVBOSized sizes ndraw
return $
VAO
{ _vaoName = theVAO
{ _vaoName = vaoname
, _vaoVBO = theVBO
}
+1 -1
View File
@@ -45,7 +45,7 @@ data FullShader' = FullShader'
{- | Vertex array object: contains the reference to the object,
and its buffer targets. -}
data VAO = VAO
{ _vaoName :: VertexArrayObject
{ _vaoName :: GLuint
, _vaoVBO :: VBO
}
{- | Vertex buffer object: contains the reference to the object,