To openglraw
This commit is contained in:
+27
-21
@@ -20,7 +20,6 @@ import Dodge.Render.Walls
|
||||
import Foreign
|
||||
import Geometry
|
||||
import Graphics.GL.Core45
|
||||
import Graphics.Rendering.OpenGL hiding (color, rotate, scale, translate)
|
||||
import MatrixHelper
|
||||
import Render
|
||||
--import qualified SDL
|
||||
@@ -95,7 +94,7 @@ doDrawing win pdata u = do
|
||||
(fromIntegral $ glushortSize * nSilIndices)
|
||||
(_eboPtr $ _silhouetteEBO pdata)
|
||||
-- set the coordinate uniform ready for drawing elements using world coordinates
|
||||
bufferUBO $ perspectiveMatrixb rot camzoom trans wins viewFroms
|
||||
bufferUBO (pdata ^. matUBO) $ perspectiveMatrixb rot camzoom trans wins viewFroms
|
||||
setViewportSize (round winx `div` resFact) (round winy `div` resFact)
|
||||
--bindFramebuffer Framebuffer $= fst (_fboBase pdata)
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboBase pdata)))
|
||||
@@ -147,7 +146,7 @@ doDrawing win pdata u = do
|
||||
(u ^. uvConfig . graphics_object_shadows)
|
||||
(snd $ snd $ pdata ^. fboBase)
|
||||
(drawCPUShadows pdata ws)
|
||||
colorMask $= Color4 Enabled Enabled Enabled Enabled
|
||||
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
|
||||
glClearColor 0 0 0 0
|
||||
--apply lightmap to base buffer
|
||||
--bindFramebuffer Framebuffer $= pdata ^. fboBase . _1 --fst (_fboBase pdata)
|
||||
@@ -191,7 +190,8 @@ doDrawing win pdata u = do
|
||||
--blendColor $= Color4 0.5 0.5 0.5 0.5
|
||||
--glBlendFuncSeparate GL_SRC_ALPHASaturate,One) , (One,GL_ONE_MINUS_SRC_ALPHA))
|
||||
glBlendFuncSeparate GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_ONE GL_ONE_MINUS_SRC_ALPHA
|
||||
drawBuffers $= [FBOColorAttachment 0, NoBuffers]
|
||||
--drawBuffers $= [FBOColorAttachment 0, NoBuffers]
|
||||
withArray [GL_COLOR_ATTACHMENT0, GL_NONE] $ \ptr -> glDrawBuffers 2 ptr
|
||||
glClear GL_COLOR_BUFFER_BIT
|
||||
renderLayer MidLayer shadV layerCounts
|
||||
--renderWindows pdata windowPoints
|
||||
@@ -218,14 +218,15 @@ doDrawing win pdata u = do
|
||||
(_graphics_object_shadows $ _uvConfig u)
|
||||
(snd $ snd $ _fboCloud pdata)
|
||||
(drawCPUShadows pdata ws)
|
||||
colorMask $= Color4 Enabled Enabled Enabled Enabled
|
||||
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
|
||||
glClearColor 0 0 0 0
|
||||
--apply lightmap to cloud buffer
|
||||
glClearColor 0 0 0 0
|
||||
--bindFramebuffer Framebuffer $= fst (_fboCloud pdata)
|
||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboCloud pdata)))
|
||||
glDepthMask GL_FALSE
|
||||
drawBuffers $= [FBOColorAttachment 0, NoBuffers]
|
||||
--drawBuffers $= [FBOColorAttachment 0, NoBuffers]
|
||||
withArray [GL_COLOR_ATTACHMENT0, GL_NONE] $ \ptr -> glDrawBuffers 2 ptr
|
||||
glDepthFunc GL_ALWAYS
|
||||
--textureBinding Texture2D $= Just (snd $ _fboLighting pdata)
|
||||
glBindTexture GL_TEXTURE_2D (_unTO . snd $ _fboLighting pdata)
|
||||
@@ -256,7 +257,7 @@ doDrawing win pdata u = do
|
||||
case w ^. cWorld . lWorld . distortions of
|
||||
[] -> do
|
||||
bindTO $ fst $ snd $ _fboBase pdata
|
||||
bindFramebuffer Framebuffer $= defaultFramebufferObject
|
||||
glBindFramebuffer GL_FRAMEBUFFER 0
|
||||
--bufferUBO $ perspectiveMatrixb rot camzoom trans wins viewFroms
|
||||
drawShader (_fullscreenShader pdata) 4
|
||||
rds -> do
|
||||
@@ -271,9 +272,11 @@ doDrawing win pdata u = do
|
||||
++ [FBO 0]
|
||||
toList = fst (snd (_fboBase pdata)) : concat (repeat [snd $ _fbo2 pdata, snd $ _fbo3 pdata])
|
||||
bindings = zipWith (>>) (map bindFBO fboList) (map bindTO toList)
|
||||
activeTexture $= TextureUnit 1
|
||||
glActiveTexture GL_TEXTURE1
|
||||
--activeTexture $= TextureUnit 1
|
||||
zipWithM_ (>>) bindings $ map bindDrawDist rds
|
||||
activeTexture $= TextureUnit 0
|
||||
--activeTexture $= TextureUnit 0
|
||||
glActiveTexture GL_TEXTURE1
|
||||
glDepthFunc GL_ALWAYS
|
||||
glEnable GL_BLEND
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
@@ -283,7 +286,7 @@ doDrawing win pdata u = do
|
||||
glDepthMask GL_FALSE
|
||||
glEnable GL_BLEND
|
||||
glBlendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
|
||||
bufferUBO $ isoMatrix 0 1 (V2 0 0) (V2 2 2)
|
||||
bufferUBO (pdata ^. matUBO) $ isoMatrix 0 1 (V2 0 0) (V2 2 2)
|
||||
renderLayer FixedCoordLayer shadV layerCounts
|
||||
renderFoldable shadV $ fixedCoordPictures u
|
||||
glDepthMask GL_TRUE
|
||||
@@ -312,16 +315,13 @@ fpsText x = color col $ text $ "ms/frame " ++ show x
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- note: currently assume there is only one UBO, we only bind it once at setup
|
||||
bufferUBO :: [Float] -> IO ()
|
||||
bufferUBO mat = withArray mat $ \ptr ->
|
||||
bufferSubData UniformBuffer WriteToBuffer 0 64 ptr
|
||||
bufferUBO :: GLuint -> [Float] -> IO ()
|
||||
bufferUBO ubo mat = withArray mat $ \ptr ->
|
||||
glNamedBufferSubData ubo 0 64 ptr
|
||||
|
||||
setViewportSize :: Int -> Int -> IO ()
|
||||
setViewportSize x y =
|
||||
viewport
|
||||
$= ( Position 0 0
|
||||
, Size (fromIntegral x) (fromIntegral y)
|
||||
)
|
||||
glViewport 0 0 (fromIntegral x) (fromIntegral y)
|
||||
|
||||
renderBlankWalls ::
|
||||
RenderData ->
|
||||
@@ -329,9 +329,12 @@ renderBlankWalls ::
|
||||
Int ->
|
||||
IO ()
|
||||
renderBlankWalls pdata nWalls = do
|
||||
cullFace $= Just Back
|
||||
glEnable GL_CULL_FACE
|
||||
glCullFace GL_BACK
|
||||
--cullFace $= Just Back
|
||||
drawShader (_wallBlankShader pdata) nWalls
|
||||
cullFace $= Nothing
|
||||
glDisable GL_CULL_FACE
|
||||
--cullFace $= Nothing
|
||||
|
||||
renderTextureWalls ::
|
||||
RenderData ->
|
||||
@@ -339,7 +342,10 @@ renderTextureWalls ::
|
||||
Int ->
|
||||
IO ()
|
||||
renderTextureWalls pdata nWalls = do
|
||||
cullFace $= Just Back
|
||||
--cullFace $= Just Back
|
||||
glEnable GL_CULL_FACE
|
||||
glCullFace GL_BACK
|
||||
drawShader (_wallTextureShader pdata) nWalls
|
||||
cullFace $= Nothing
|
||||
glDisable GL_CULL_FACE
|
||||
--cullFace $= Nothing
|
||||
|
||||
|
||||
Reference in New Issue
Block a user