isolated error. Map Rendering is missing Depth-Comp
- refactored a bit
This commit is contained in:
parent
581cb142bb
commit
c10622d506
@ -308,11 +308,13 @@ adjustWindow = do
|
||||
textureFilter Texture2D GL.$= ((Linear', Nothing), Linear')
|
||||
texImage2D Texture2D GL.NoProxy 0 RGBA8 (GL.TextureSize2D fbCWidth fbCHeight) 0
|
||||
(GL.PixelData GL.RGBA GL.UnsignedByte ptr)
|
||||
textureBinding Texture2D GL.$= Nothing
|
||||
-- MAP
|
||||
textureBinding Texture2D GL.$= Just maptexid
|
||||
textureFilter Texture2D GL.$= ((Linear', Nothing), Linear')
|
||||
texImage2D Texture2D GL.NoProxy 0 RGBA8 (GL.TextureSize2D fbCWidth fbCHeight) 0
|
||||
(GL.PixelData GL.RGBA GL.UnsignedByte ptr)
|
||||
textureBinding Texture2D GL.$= Nothing
|
||||
allocaBytes (2048*2048) $ \ptr -> do
|
||||
let smapdata = genColorData (2048*2048) [0]
|
||||
pokeArray ptr smapdata
|
||||
@ -320,6 +322,7 @@ adjustWindow = do
|
||||
textureFilter Texture2D GL.$= ((Nearest,Nothing), Nearest)
|
||||
texImage2D Texture2D GL.NoProxy 0 GL.DepthComponent16 (GL.TextureSize2D 2048 2048) 0
|
||||
(GL.PixelData GL.DepthComponent GL.UnsignedByte ptr)
|
||||
textureBinding Texture2D GL.$= Nothing
|
||||
checkError "setting up HUD-Tex"
|
||||
return renderBuffer
|
||||
modify $ gl.glRenderbuffer .~ rb
|
||||
|
@ -9,6 +9,8 @@ import Graphics.Rendering.OpenGL.GL.StateVar
|
||||
import Graphics.Rendering.OpenGL.GL.StringQueries
|
||||
import Graphics.Rendering.OpenGL.GLU.Errors
|
||||
import Graphics.Rendering.OpenGL.GL.VertexArrayObjects
|
||||
import Graphics.Rendering.OpenGL.GL.VertexArrays
|
||||
import Graphics.Rendering.OpenGL.GL.VertexSpec
|
||||
import Graphics.Rendering.OpenGL.GL.BufferObjects
|
||||
import Graphics.UI.SDL.Types (Texture)
|
||||
import System.IO (hPutStrLn, stderr)
|
||||
@ -180,3 +182,10 @@ withVBO b t a = do
|
||||
ret <- a
|
||||
bindBuffer t $= Nothing
|
||||
return ret
|
||||
|
||||
withVAA :: [AttribLocation] -> IO a -> IO a
|
||||
withVAA atts action = do
|
||||
mapM_ (\a -> vertexAttribArray a $= Enabled) atts
|
||||
ret <- action
|
||||
mapM_ (\a -> vertexAttribArray a $= Disabled) atts
|
||||
return ret
|
||||
|
@ -287,8 +287,7 @@ initRendering = do
|
||||
renderIQM :: IQM -> L.V3 CFloat -> L.V3 CFloat -> IO ()
|
||||
renderIQM m p@(L.V3 x y z) s@(L.V3 sx sy sz) = do
|
||||
withVAO (vertexArrayObject m) $ do
|
||||
vertexAttribArray (AttribLocation 0) $= Enabled
|
||||
vertexAttribArray (AttribLocation 1) $= Enabled
|
||||
withVAA [(AttribLocation 0),(AttribLocation 1)] $ do
|
||||
checkError "setting array to enabled"
|
||||
bindBuffer ElementArrayBuffer $= Just (triangleBufferObject m)
|
||||
checkError "bindBuffer"
|
||||
@ -297,7 +296,6 @@ renderIQM m p@(L.V3 x y z) s@(L.V3 sx sy sz) = do
|
||||
drawElements Triangles n UnsignedInt nullPtr
|
||||
checkError "drawing model"
|
||||
bindBuffer ElementArrayBuffer $= Nothing
|
||||
vertexAttribArray (AttribLocation 0) $= Disabled
|
||||
checkError "unbind buffer"
|
||||
return ()
|
||||
|
||||
@ -322,13 +320,11 @@ drawMap = do
|
||||
glUniform1f tli (fromIntegral tessFac)
|
||||
glUniform1f tlo (fromIntegral tessFac)
|
||||
|
||||
bindBuffer ArrayBuffer $= Just map'
|
||||
withVBO map' ArrayBuffer $ do
|
||||
vertexAttribPointer ci $= fgColorIndex
|
||||
vertexAttribArray ci $= Enabled
|
||||
vertexAttribPointer ni $= fgNormalIndex
|
||||
vertexAttribArray ni $= Enabled
|
||||
vertexAttribPointer vi $= fgVertexIndex
|
||||
vertexAttribArray vi $= Enabled
|
||||
withVAA [ci,ni,vi] $ do
|
||||
checkError "beforeDraw"
|
||||
|
||||
glPatchParameteri gl_PATCH_VERTICES 3
|
||||
@ -339,10 +335,6 @@ drawMap = do
|
||||
glDrawArrays gl_PATCHES 0 (fromIntegral numVert)
|
||||
|
||||
checkError "draw map"
|
||||
bindBuffer ArrayBuffer $= Nothing
|
||||
vertexAttribArray ci $= Disabled
|
||||
vertexAttribArray ni $= Disabled
|
||||
vertexAttribArray vi $= Disabled
|
||||
|
||||
-- set sample 1 as target in renderbuffer
|
||||
{-framebufferRenderbuffer
|
||||
@ -405,16 +397,16 @@ render = do
|
||||
(state ^. gl.glRenderbuffer)-}
|
||||
|
||||
---- RENDER SHADOWMAP <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
{- liftIO $ do
|
||||
textureBinding Texture2D $= Just (state ^. gl.glMap.shadowMapTexture)
|
||||
framebufferTexture2D
|
||||
liftIO $ do
|
||||
-- textureBinding Texture2D $= Just (state ^. gl.glMap.shadowMapTexture)
|
||||
{- framebufferTexture2D
|
||||
Framebuffer
|
||||
DepthAttachment
|
||||
Texture2D
|
||||
(state ^. gl.glMap.shadowMapTexture)
|
||||
0
|
||||
0-}
|
||||
|
||||
drawBuffer $= NoBuffers --color-buffer is not needed but must(?) be set up
|
||||
-- drawBuffer $= NoBuffers --color-buffer is not needed but must(?) be set up
|
||||
checkError "setup Render-Target"
|
||||
|
||||
clear [DepthBuffer]
|
||||
@ -432,9 +424,9 @@ render = do
|
||||
--TODO: needed?
|
||||
mat33ToGPU sunnmap nmat "nmat"
|
||||
|
||||
drawMap
|
||||
-- drawMap
|
||||
|
||||
liftIO $ do
|
||||
{- liftIO $ do
|
||||
---- RENDER MAPOBJECTS --------------------------------------------
|
||||
currentProgram $= Just (state ^. gl.glMap.objectProgram)
|
||||
checkError "setting up shadowmap-program"
|
||||
@ -454,7 +446,7 @@ render = do
|
||||
mapM_ renderObject (state ^. gl.glMap.mapObjects)
|
||||
checkError "draw mapobjects"
|
||||
|
||||
checkError "draw ShadowMap"-}
|
||||
checkError "draw ShadowMap"--}
|
||||
|
||||
---- RENDER MAP IN TEXTURE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
-- COLORMAP
|
||||
|
Loading…
Reference in New Issue
Block a user