This commit is contained in:
2026-01-02 11:07:47 +00:00
parent 119234af89
commit 804e4eb1e2
4 changed files with 60 additions and 93 deletions
+19 -24
View File
@@ -1,10 +1,9 @@
module Render (
createLightMap,
renderLayer,
pingPongBetween,
bindFBO,
) where
import Shader.Parameters
import Dodge.Base.Coordinate
import Dodge.Data.Camera
import Control.Lens
@@ -18,7 +17,6 @@ import Foreign hiding (rotate)
import Geometry.Data
import Graphics.GL.Core45
import Picture.Data
import Shader
import Shader.Data
{- | Determine where light is shining in the world.
@@ -104,12 +102,11 @@ renderLightingNoShadows positiontexture normaltexture lightPoints pdata = do
renderFlatLighting :: RenderData -> IO ()
renderFlatLighting pdata = do
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboLighting pdata)))
withArray [0, 0, 0, 1] $ \ptr ->
withArray [0, 0, 0, 1] $
glClearNamedFramebufferfv
(pdata ^. fboLighting . _1 . unFBO)
GL_COLOR
0
ptr
glDisable GL_CULL_FACE
glDepthFunc GL_ALWAYS
glDepthMask GL_FALSE
@@ -206,21 +203,6 @@ renderShadows isclouds cam cfig shadrendertype nWalls nSils nCaps positiontextur
glStencilOp GL_KEEP GL_KEEP GL_KEEP
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
-- assumes that vertices have already been sent to the shader
pingPongBetween ::
(FBO, TO) ->
(FBO, TO) ->
GLuint ->
IO ()
pingPongBetween (fb1, to1) (fb2, to2) fs = do
glBindFramebuffer GL_FRAMEBUFFER (_unFBO fb2)
glBindTextureUnit 0 (_unTO to1)
glUseProgram fs
glDrawArrays GL_TRIANGLES 0 6
glBindFramebuffer GL_FRAMEBUFFER (_unFBO fb1)
glBindTextureUnit 0 (_unTO to2)
glDrawArrays GL_TRIANGLES 0 6
renderLayer ::
Layer ->
MV.MVector (PrimState IO) (GLuint, VBO) ->
@@ -233,7 +215,20 @@ renderLayer layer shads counts = do
where
ln = fromEnum layer
bindFBO :: FBO -> IO ()
bindFBO fb =
--bindFramebuffer Framebuffer $= fb
glBindFramebuffer GL_FRAMEBUFFER (_unFBO fb)
drawShaderLay :: Int -> UMV.MVector (PrimState IO) Int -> Int -> (GLuint, VBO) -> IO ()
{-# INLINE drawShaderLay #-}
drawShaderLay l countsVector shadIn fs = do
-- putStr $ " shader: " <> show shadIn
i <- UMV.read countsVector shadIn
-- putStrLn $ " count: " <> show i
glUseProgram (fst fs)
glUniform1i 0 . fromIntegral $ (l * numSubElements)
glDrawArrays
GL_TRIANGLES
(fromIntegral $ l * numSubElements)
(drawCountMod shadIn i)
drawCountMod :: Int -> Int -> GLsizei
drawCountMod i n
| i == 3 = fromIntegral $ 2 * n -- modifies ellipse draw count
| otherwise = fromIntegral n