Implement static VBO/VAO
This commit is contained in:
@@ -124,14 +124,15 @@ preloadRender = do
|
||||
--initTexture2DArray 50 "data/texture/charMapVertBig.png" 2 32 64 95 GL_LINEAR_MIPMAP_NEAREST GL_LINEAR
|
||||
|
||||
putStrLn "Setup full screen shaders"
|
||||
screentexturevbo <- mglCreate glCreateBuffers
|
||||
withArray (concat cornerList) $ \ptr ->
|
||||
glNamedBufferStorage
|
||||
screentexturevbo
|
||||
(fromIntegral $ floatSize * length (concat cornerList))
|
||||
ptr
|
||||
0
|
||||
screentexturevao <- setupVAOvbo (toFloatVAs [2, 2]) 4 screentexturevbo
|
||||
-- screentexturevbo <- mglCreate glCreateBuffers
|
||||
-- withArray (concat cornerList) $ \ptr ->
|
||||
-- glNamedBufferStorage
|
||||
-- screentexturevbo
|
||||
-- (fromIntegral $ floatSize * length (concat cornerList))
|
||||
-- ptr
|
||||
-- 0
|
||||
-- screentexturevao <- setupVAOvbo (toFloatVAs [2, 2]) 4 screentexturevbo
|
||||
(_,screentexturevao) <- setupStaticVBO (toFloatVAs [2,2]) (concat cornerList)
|
||||
alphadivideshader <- makeShaderUsingVAO "texture2D/alphaDivide" [vert, frag] pmTriangleStrip screentexturevao
|
||||
fsShad <- makeShaderUsingVAO "texture/simple" [vert, frag] pmTriangleStrip screentexturevao
|
||||
bloomBlurShad <- makeShaderUsingVAO "texture/bloomBlur" [vert, frag] pmTriangleStrip screentexturevao
|
||||
|
||||
+20
-15
@@ -13,8 +13,10 @@ module Shader.Compile (
|
||||
setupVertexAttribPointer,
|
||||
makeSourcedShader,
|
||||
toFloatVAs,
|
||||
setupStaticVBO
|
||||
) where
|
||||
|
||||
import Foreign.C.Types
|
||||
import Graphics.GL.Types
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
@@ -99,21 +101,24 @@ setupVBO vertexsize = do
|
||||
GL_STREAM_DRAW
|
||||
return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexBytes = floatSize * vertexsize}
|
||||
|
||||
---- the input ptr is assumed to contain the correct amount of data according to
|
||||
---- the specified number and type of vertices
|
||||
---- note the VBO here does not have a sensible ptr value
|
||||
--setupStaticVBO :: Int -> [VertexAttribute] -> Ptr a -> IO (VBO,VAO)
|
||||
--setupStaticVBO numvs vas vdata = do
|
||||
-- vboname <- mglCreate glCreateBuffers
|
||||
-- glNamedBufferStorage
|
||||
-- vboname
|
||||
-- (CPtrdiff (fromIntegral (vasTightStride vas)))
|
||||
-- vdata
|
||||
-- 0
|
||||
-- let vbo = VBO
|
||||
-- { _vboName = vboname
|
||||
-- , _vboPtr = nullPtr
|
||||
-- , _vboVertexSize =
|
||||
-- the input ptr is assumed to contain the correct amount of data according to
|
||||
-- the specified number and type of vertices
|
||||
-- note the VBO here does not have a sensible ptr value
|
||||
setupStaticVBO :: Storable a => [VertexAttribute] -> [a] -> IO (VBO,VAO)
|
||||
setupStaticVBO vas vdata = withArrayLen vdata $ \i ptr -> do
|
||||
vboname <- mglCreate glCreateBuffers
|
||||
glNamedBufferStorage
|
||||
vboname
|
||||
(CPtrdiff (fromIntegral (i * sizeOf (head vdata))))
|
||||
ptr
|
||||
0
|
||||
let vbo = VBO
|
||||
{ _vboName = vboname
|
||||
, _vboPtr = nullPtr
|
||||
, _vboVertexBytes = vasTightStride vas
|
||||
}
|
||||
vao <- setupVAOUsingVBO vas vbo
|
||||
return (vbo,vao)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user