From 2388715d52b4006b946c6fc58029229829e508c7 Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 9 Mar 2023 21:00:16 +0000 Subject: [PATCH] Continue migration to openglraw --- src/Dodge/Render.hs | 24 +++++------------------- src/Framebuffer/Check.hs | 11 +++++++++++ src/Framebuffer/Update.hs | 8 +------- 3 files changed, 17 insertions(+), 26 deletions(-) create mode 100644 src/Framebuffer/Check.hs diff --git a/src/Dodge/Render.hs b/src/Dodge/Render.hs index 4d6068eee..0fca7fd84 100644 --- a/src/Dodge/Render.hs +++ b/src/Dodge/Render.hs @@ -84,25 +84,11 @@ doDrawing win pdata u = do , (_windowShader pdata, nWins) , (_textureArrayShader pdata, nFls) ] - --bindBuffer ElementArrayBuffer $= pdata ^? shapeEBO . eboName --Just (_ebo $ _shapeEBO pdata) - --bufferSubData - -- ElementArrayBuffer - -- WriteToBuffer - -- 0 - -- (fromIntegral $ glushortSize * nIndices) - -- (_eboPtr $ _shapeEBO pdata) glNamedBufferSubData (_eboName $ _shapeEBO pdata) 0 (fromIntegral $ glushortSize * nIndices) (_eboPtr $ _shapeEBO pdata) - --bindBuffer ElementArrayBuffer $= pdata ^? silhouetteEBO . eboName --Just (_ebo $ _silhouetteEBO pdata) - --bufferSubData - -- ElementArrayBuffer - -- WriteToBuffer - -- 0 - -- (fromIntegral $ glushortSize * nSilIndices) - -- (_eboPtr $ _silhouetteEBO pdata) glNamedBufferSubData (_eboName $ _silhouetteEBO pdata) 0 @@ -113,7 +99,7 @@ doDrawing win pdata u = do setViewportSize (round winx `div` resFact) (round winy `div` resFact) --bindFramebuffer Framebuffer $= fst (_fboBase pdata) glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboBase pdata))) - clearColor $= Color4 0 0 0 0 + glClearColor 0 0 0 0 clear [ColorBuffer, DepthBuffer] depthFunc $= Just Less -- draw wall occlusions from the camera's point of view @@ -162,7 +148,7 @@ doDrawing win pdata u = do (snd $ snd $ pdata ^. fboBase) (drawCPUShadows pdata ws) colorMask $= Color4 Enabled Enabled Enabled Enabled - clearColor $= Color4 0 0 0 0 + glClearColor 0 0 0 0 --apply lightmap to base buffer --bindFramebuffer Framebuffer $= pdata ^. fboBase . _1 --fst (_fboBase pdata) glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fboBase . _1 . unFBO) @@ -200,7 +186,7 @@ doDrawing win pdata u = do glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboCloud pdata))) depthFunc $= Just Lequal depthMask $= Disabled - clearColor $= Color4 0.5 0.5 0.5 0 + glClearColor 0.5 0.5 0.5 0 --blendFunc $= (SrcAlphaSaturate,One) --blendColor $= Color4 0.5 0.5 0.5 0.5 --blendFuncSeparate $= ((SrcAlphaSaturate,One) , (One,OneMinusSrcAlpha)) @@ -232,9 +218,9 @@ doDrawing win pdata u = do (snd $ snd $ _fboCloud pdata) (drawCPUShadows pdata ws) colorMask $= Color4 Enabled Enabled Enabled Enabled - clearColor $= Color4 0 0 0 0 + glClearColor 0 0 0 0 --apply lightmap to cloud buffer - clearColor $= Color4 0 0 0 0 + glClearColor 0 0 0 0 --bindFramebuffer Framebuffer $= fst (_fboCloud pdata) glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboCloud pdata))) depthMask $= Disabled diff --git a/src/Framebuffer/Check.hs b/src/Framebuffer/Check.hs new file mode 100644 index 000000000..65fac2c6e --- /dev/null +++ b/src/Framebuffer/Check.hs @@ -0,0 +1,11 @@ +module Framebuffer.Check where + +import Data.Preload.Render +import Graphics.GL.Core45 + +checkFBO :: FBO -> IO () +checkFBO fbo = do + fboStatus <- glCheckNamedFramebufferStatus (_unFBO fbo) GL_FRAMEBUFFER + case fboStatus of + 36053 -> return () -- this should correspond to GL_COMPLETE or something + _ -> error $ "FBO id "++ show (_unFBO fbo) ++ ":" ++ show fboStatus diff --git a/src/Framebuffer/Update.hs b/src/Framebuffer/Update.hs index f8cd90356..fa7d5fd03 100644 --- a/src/Framebuffer/Update.hs +++ b/src/Framebuffer/Update.hs @@ -7,6 +7,7 @@ module Framebuffer.Update ( sizeFBOs, ) where +import Framebuffer.Check import Control.Lens import Control.Monad import Data.Preload.Render @@ -179,10 +180,3 @@ initializeTexture2DArray fbo attachpoint x y z minfilt magfilt informat = do glTextureParameteri to1 GL_TEXTURE_MAG_FILTER (unsafeCoerce magfilt) glNamedFramebufferTexture (_unFBO fbo) attachpoint to1 0 return to1 - -checkFBO :: FBO -> IO () -checkFBO fbo = do - fboStatus <- glCheckNamedFramebufferStatus (_unFBO fbo) GL_FRAMEBUFFER - case fboStatus of - 36053 -> return () -- this should correspond to GL_COMPLETE or something - _ -> error $ "after resize, resizeFBOTO framebuffer status:" ++ show fboStatus