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