Commit before attempting to implement immutable buffer storage (openGL)
This commit is contained in:
+14
-9
@@ -4,14 +4,14 @@ module Dodge.Render (
|
|||||||
getWindowSize
|
getWindowSize
|
||||||
) where
|
) where
|
||||||
|
|
||||||
--import qualified Data.Vector as V
|
import qualified Data.Vector as V
|
||||||
|
|
||||||
import Dodge.Shadows
|
import Dodge.Shadows
|
||||||
import Dodge.WindowSize
|
import Dodge.WindowSize
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import qualified Control.Monad.Parallel as MP
|
import qualified Control.Monad.Parallel as MP
|
||||||
import Data.List (sortOn)
|
--import Data.List (sortOn)
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
import Data.Preload.Render
|
import Data.Preload.Render
|
||||||
import qualified Data.Vector.Unboxed.Mutable as UMV
|
import qualified Data.Vector.Unboxed.Mutable as UMV
|
||||||
@@ -85,10 +85,12 @@ doDrawing' win pdata u = do
|
|||||||
ws
|
ws
|
||||||
)
|
)
|
||||||
(nCloudVs, nCloudIs) <-
|
(nCloudVs, nCloudIs) <-
|
||||||
foldM
|
-- Might want to sort the clouds based on z depth, not sure
|
||||||
|
V.foldM'
|
||||||
(pokeCloud (pdata ^. cloudVBO . vboPtr) (pdata ^. cloudEBO . eboPtr))
|
(pokeCloud (pdata ^. cloudVBO . vboPtr) (pdata ^. cloudEBO . eboPtr))
|
||||||
(0, 0)
|
(0, 0)
|
||||||
(sortOn (^. clPos . _3) $ w ^. cWorld . lWorld . clouds)
|
(V.fromList $ w ^. cWorld . lWorld . clouds)
|
||||||
|
--(sortOn (^. clPos . _3) $ w ^. cWorld . lWorld . clouds)
|
||||||
-- bind wall points, silhouette data, surface geometry
|
-- bind wall points, silhouette data, surface geometry
|
||||||
bufferShaderLayers shadV layerCounts
|
bufferShaderLayers shadV layerCounts
|
||||||
mapM_
|
mapM_
|
||||||
@@ -226,8 +228,11 @@ doDrawing' win pdata u = do
|
|||||||
glBindTextureUnit 0 (pdata ^. fboBloom . _2 . unTO)
|
glBindTextureUnit 0 (pdata ^. fboBloom . _2 . unTO)
|
||||||
glDisable GL_BLEND
|
glDisable GL_BLEND
|
||||||
drawShader (_bloomBlurShader pdata) 4
|
drawShader (_bloomBlurShader pdata) 4
|
||||||
replicateM_ 2 $ pingPongBetween (_fboHalf1 pdata) (_fboHalf2 pdata) (_bloomBlurShader pdata)
|
if cfig ^. graphics_bloom
|
||||||
glEnable GL_BLEND
|
then do
|
||||||
|
replicateM_ 2 $ pingPongBetween (_fboHalf1 pdata) (_fboHalf2 pdata) (_bloomBlurShader pdata)
|
||||||
|
glEnable GL_BLEND
|
||||||
|
else return ()
|
||||||
setViewport _graphics_world_resolution cfig
|
setViewport _graphics_world_resolution cfig
|
||||||
--draw clouds onto cloud buffer
|
--draw clouds onto cloud buffer
|
||||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboCloud pdata)))
|
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboCloud pdata)))
|
||||||
@@ -341,12 +346,12 @@ doDrawing' win pdata u = do
|
|||||||
glBlendFunc GL_ONE GL_ZERO
|
glBlendFunc GL_ONE GL_ZERO
|
||||||
-- perform any radial distortion
|
-- perform any radial distortion
|
||||||
-- this is hideous
|
-- this is hideous
|
||||||
case getDistortions cfig w of
|
case (getDistortions cfig w, cfig ^. graphics_distortions) of
|
||||||
[] -> do
|
(rds, x) | null rds || not x -> do
|
||||||
glBindTextureUnit 0 $ pdata ^. fboBase . _2 . _1 . unTO
|
glBindTextureUnit 0 $ pdata ^. fboBase . _2 . _1 . unTO
|
||||||
glBindFramebuffer GL_FRAMEBUFFER 0
|
glBindFramebuffer GL_FRAMEBUFFER 0
|
||||||
drawShader (_fullscreenShader pdata) 4
|
drawShader (_fullscreenShader pdata) 4
|
||||||
rds -> do
|
(rds,_) -> do
|
||||||
let bindDrawDist :: Distortion -> IO ()
|
let bindDrawDist :: Distortion -> IO ()
|
||||||
bindDrawDist (RadialDistortion (V2 a b) (V2 c d) (V2 e f) g) = do
|
bindDrawDist (RadialDistortion (V2 a b) (V2 c d) (V2 e f) g) = do
|
||||||
pokeArray (shadVBOptr $ _barrelShader pdata) [a, b, c, d, e, f, g]
|
pokeArray (shadVBOptr $ _barrelShader pdata) [a, b, c, d, e, f, g]
|
||||||
|
|||||||
+7
-5
@@ -150,7 +150,7 @@ renderShadows ::
|
|||||||
RenderData ->
|
RenderData ->
|
||||||
IO ()
|
IO ()
|
||||||
renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture lightPoints pdata = do
|
renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture lightPoints pdata = do
|
||||||
glBindFramebuffer GL_FRAMEBUFFER (_unFBO (fst (_fboLighting pdata)))
|
glBindFramebuffer GL_FRAMEBUFFER $ pdata ^. fboLighting . _1 . unFBO --(_unFBO (fst (_fboLighting pdata)))
|
||||||
let llinesShad = _lightingLineShadowShader pdata
|
let llinesShad = _lightingLineShadowShader pdata
|
||||||
lcapShad = _lightingCapShader pdata
|
lcapShad = _lightingCapShader pdata
|
||||||
lwallShad = _lightingWallShadShader pdata
|
lwallShad = _lightingWallShadShader pdata
|
||||||
@@ -166,9 +166,7 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li
|
|||||||
GL_COLOR
|
GL_COLOR
|
||||||
0
|
0
|
||||||
ptr
|
ptr
|
||||||
-- for each of the lights:
|
-- setup stencil and blending
|
||||||
-- 1. stencil out the shadows from this light's point of view
|
|
||||||
-- 2. calculate lighting based on each fragment's position and normal
|
|
||||||
glBlendFunc GL_ZERO GL_ONE_MINUS_SRC_COLOR
|
glBlendFunc GL_ZERO GL_ONE_MINUS_SRC_COLOR
|
||||||
glEnable GL_STENCIL_TEST
|
glEnable GL_STENCIL_TEST
|
||||||
glStencilOpSeparate GL_FRONT GL_KEEP GL_KEEP GL_INCR_WRAP
|
glStencilOpSeparate GL_FRONT GL_KEEP GL_KEEP GL_INCR_WRAP
|
||||||
@@ -176,6 +174,9 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li
|
|||||||
-- bind world position texture-- these will be used by the lighting shader
|
-- bind world position texture-- these will be used by the lighting shader
|
||||||
glBindTextureUnit 0 (positiontexture ^. unTO)
|
glBindTextureUnit 0 (positiontexture ^. unTO)
|
||||||
glBindTextureUnit 1 (normaltexture ^. unTO)
|
glBindTextureUnit 1 (normaltexture ^. unTO)
|
||||||
|
-- for each of the lights:
|
||||||
|
-- 1. stencil out the shadows from this light's point of view
|
||||||
|
-- 2. calculate lighting based on each fragment's position and normal
|
||||||
flip VFSM.mapM_ (VFSM.fromList lightPoints) $ \(V3 x y z, rad, V3 r g b) -> do
|
flip VFSM.mapM_ (VFSM.fromList lightPoints) $ \(V3 x y z, rad, V3 r g b) -> do
|
||||||
glDepthFunc GL_LESS
|
glDepthFunc GL_LESS
|
||||||
-- setup stencil
|
-- setup stencil
|
||||||
@@ -226,7 +227,7 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li
|
|||||||
--draw lightmap itself
|
--draw lightmap itself
|
||||||
glDepthFunc GL_ALWAYS
|
glDepthFunc GL_ALWAYS
|
||||||
glDisable GL_CULL_FACE
|
glDisable GL_CULL_FACE
|
||||||
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
|
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_FALSE
|
||||||
glStencilFunc GL_EQUAL 0 255
|
glStencilFunc GL_EQUAL 0 255
|
||||||
glUseProgram (ltextShad ^. shaderUINT) --Just (_shadProg ltextShad)
|
glUseProgram (ltextShad ^. shaderUINT) --Just (_shadProg ltextShad)
|
||||||
glUniform3f 0 x y z
|
glUniform3f 0 x y z
|
||||||
@@ -238,6 +239,7 @@ renderShadows shadrendertype nWalls nSils nCaps positiontexture normaltexture li
|
|||||||
(fromIntegral (4 :: Int))
|
(fromIntegral (4 :: Int))
|
||||||
--cleanup: may not be necessary, depending on what comes after...
|
--cleanup: may not be necessary, depending on what comes after...
|
||||||
glDisable GL_STENCIL_TEST
|
glDisable GL_STENCIL_TEST
|
||||||
|
glColorMask GL_TRUE GL_TRUE GL_TRUE GL_TRUE
|
||||||
|
|
||||||
lightsToArray :: [(Point3, Float, Point3)] -> [Float]
|
lightsToArray :: [(Point3, Float, Point3)] -> [Float]
|
||||||
lightsToArray xs =
|
lightsToArray xs =
|
||||||
|
|||||||
Reference in New Issue
Block a user