Map an "isometric" matrix to a static buffer

This commit is contained in:
2023-03-09 23:28:48 +00:00
parent d72033c562
commit b1750ad028
6 changed files with 14 additions and 13 deletions
+1
View File
@@ -49,6 +49,7 @@ data RenderData = RenderData
, _fboShadow :: (FBO, (TO, TO))
, _rboBaseBloom :: GLuint -- RenderbufferObject id
, _matUBO :: GLuint -- BufferObject id
, _isoMatUBO :: GLuint -- BufferObject id
}
makeLenses ''RenderData
+3 -1
View File
@@ -94,6 +94,7 @@ doDrawing win pdata u = do
(fromIntegral $ glushortSize * nSilIndices)
(_eboPtr $ _silhouetteEBO pdata)
-- set the coordinate uniform ready for drawing elements using world coordinates
glBindBufferBase GL_UNIFORM_BUFFER 0 (pdata ^. matUBO)
bufferUBO (pdata ^. matUBO) $ perspectiveMatrixb rot camzoom trans wins viewFroms
setViewportSize (round winx `div` resFact) (round winy `div` resFact)
--bindFramebuffer Framebuffer $= fst (_fboBase pdata)
@@ -286,7 +287,8 @@ doDrawing win pdata u = do
glDepthMask GL_FALSE
glEnable GL_BLEND
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
bufferUBO (pdata ^. matUBO) $ isoMatrix 0 1 (V2 0 0) (V2 2 2)
--bufferUBO (pdata ^. matUBO) $ isoMatrix 0 1 (V2 0 0) (V2 2 2)
glBindBufferBase GL_UNIFORM_BUFFER 0 (pdata ^. isoMatUBO)
renderLayer FixedCoordLayer shadV layerCounts
renderFoldable shadV $ fixedCoordPictures u
glDepthMask GL_TRUE
+10 -1
View File
@@ -5,6 +5,8 @@ module Preload.Render (
cleanUpRenderPreload,
) where
import Geometry.Data
import MatrixHelper
import GLHelp
import Control.Lens
import Control.Monad
@@ -29,6 +31,12 @@ preloadRender = do
theUBO <- mglCreate glCreateBuffers
glNamedBufferData theUBO 64 nullPtr GL_STREAM_DRAW
glBindBufferBase GL_UNIFORM_BUFFER 0 theUBO
isoUBO <- mglCreate glCreateBuffers
withArray (isoMatrix 0 1 (V2 0 0) (V2 2 2)) $ \ptr ->
glNamedBufferStorage isoUBO 64 ptr 0
glBindBufferBase GL_UNIFORM_BUFFER 1 theUBO
-- setup wall points VBO, VAOs and shaders
wpVBOname <- mglCreate glCreateBuffers
wpVBOptr <- mallocArray (8 * numDrawableWalls)
@@ -170,7 +178,7 @@ preloadRender = do
>>= addTextureArray "data/texture/ayene_wooden_floor_transformed.png"
-- >>= addTextureArray "data/texture/ayene_wooden_floor.png"
-- bind fixed vertex data
bindShaderBuffers' [fsShad] [4, 4]
bindShaderBuffers [fsShad] [4, 4]
framebuf2 <- setupTextureFramebuffer 800 600
framebuf3 <- setupTextureFramebuffer 800 600
@@ -248,6 +256,7 @@ preloadRender = do
, _fboPos = fboPosName
, _rboBaseBloom = rboBaseBloomName
, _matUBO = theUBO
, _isoMatUBO = isoUBO
}
--------------------end preloadRender
-1
View File
@@ -30,7 +30,6 @@ import Shader.ExtraPrimitive
createLightMap ::
RenderData ->
[(Point3, Float, Point3)] -> -- Lights
-- | number of walls
Int ->
-- | number of silhoutte lines to draw
-9
View File
@@ -1,7 +1,6 @@
module Shader.Bind
( bindShaderLayers
, bindShaderBuffers
, bindShaderBuffers'
, bindShader
) where
import Shader.Data
@@ -29,10 +28,7 @@ bindShaderLayers shads counts = MV.imapM_ f shads
f i shad = do
let theVBO = _vaoVBO $ _shadVAO' shad
stride = sum $ _vboAttribSizes theVBO
glBindBuffer GL_ARRAY_BUFFER (_vboName theVBO)
VFSM.mapM_ (g stride theVBO) $ VFSM.enumFromStepN 0 1 6 -- [0..5]
--S.mapM_ (g stride theVBO) $ S.each [0..5]
where
g stride theVBO lay = do
numVs <- UMV.unsafeRead counts $ lay * 6 + i
@@ -54,8 +50,3 @@ bindShaderBuffers :: [FullShader] -> [Int] -> IO ()
bindShaderBuffers = zipWithM_ f
where
f fs i = bindArrayBuffers i $ _vaoVBO $ _shadVAO' fs
bindShaderBuffers' :: [FullShader] -> [Int] -> IO ()
bindShaderBuffers' = zipWithM_ f
where
f fs i = bindArrayBuffers i $ _vaoVBO $ _shadVAO' fs
-1
View File
@@ -143,7 +143,6 @@ setupVBOSized ndraw vao sizes = do
--vboName <- genObjectName
--bindBuffer ArrayBuffer $= Just vboName
vboname <- mglCreate glCreateBuffers
glBindBuffer GL_ARRAY_BUFFER vboname
forM_ (zip3 [0 ..] sizes offs) $ \(loc, siz, off) -> do
setupVertexAttribPointer vao vboname loc siz strd off
thePtr <- mallocArray (strd * ndraw)