Add new files
This commit is contained in:
+12
-47
@@ -1,32 +1,20 @@
|
||||
--{-# LANGUAGE TupleSections #-}
|
||||
module Render
|
||||
where
|
||||
import Shader
|
||||
import Shader.Data
|
||||
import Shader.Poke
|
||||
--import MatrixHelper
|
||||
--import Shader.Poke
|
||||
import Data.Preload.Render
|
||||
import Picture.Data
|
||||
--import Picture.Tree
|
||||
--import Geometry
|
||||
import Geometry.Data
|
||||
--import Polyhedra.Data
|
||||
--import Polyhedra
|
||||
--import Layers
|
||||
|
||||
import Data.Foldable
|
||||
--import Control.Lens
|
||||
--import Control.Monad
|
||||
--import qualified Control.Foldl as F
|
||||
import Foreign hiding (rotate)
|
||||
import Graphics.Rendering.OpenGL hiding (Line,translate,scale,imageHeight,Polygon,Color,T)
|
||||
--import Data.Foldable
|
||||
--import Data.Tuple.Extra
|
||||
--import qualified Data.IntMap.Strict as IM
|
||||
import qualified SDL
|
||||
import qualified Data.Vector.Unboxed.Mutable as UMV
|
||||
import qualified Data.Vector.Mutable as MV
|
||||
import Control.Monad.Primitive
|
||||
--import qualified Data.Vector.Fusion.Stream.Monadic as VS
|
||||
|
||||
divideSize :: Int -> Size -> Size
|
||||
divideSize i (Size x y) = Size (div x $ fromIntegral i) (div y $ fromIntegral i)
|
||||
@@ -44,15 +32,15 @@ createLightMap
|
||||
-> IO ()
|
||||
createLightMap pdata lightPoints nWalls nSils nsurfVs = do
|
||||
depthFunc $= Just Less
|
||||
-- clear buffer to full alpha and furthest depth
|
||||
-- clearColor is specified in preloadRender
|
||||
-- clear buffer to full alpha and furthest depth
|
||||
-- clearColor is specified in preloadRender
|
||||
clearColor $= Color4 0 0 0 1
|
||||
clear [ColorBuffer,DepthBuffer]
|
||||
--colorMask $= Color4 Disabled Disabled Disabled Disabled
|
||||
cullFace $= Just Back
|
||||
-- draw walls from your point of view in order to set z buffer
|
||||
-- draw walls from your point of view in order to set z buffer
|
||||
drawShader (_lightingWallShader pdata) nWalls
|
||||
---- draw foreground elements to set z buffer
|
||||
-- draw foreground elements to set z buffer
|
||||
drawShader (_lightingSurfaceShader pdata) nsurfVs
|
||||
-- for each of the lights:
|
||||
-- stencil out the walls from this light's point of view
|
||||
@@ -62,6 +50,7 @@ createLightMap pdata lightPoints nWalls nSils nsurfVs = do
|
||||
blendFunc $= (Zero, OneMinusSrcAlpha)
|
||||
stencilTest $= Enabled
|
||||
depthFunc $= Just Lequal
|
||||
--flip VS.mapM_ (VS.fromList lightPoints) $ \(V3 x y z,r,lum) -> do
|
||||
forM_ lightPoints $ \(V3 x y z,r,lum) -> do
|
||||
-- stencil out shadows
|
||||
colorMask $= Color4 Disabled Disabled Disabled Disabled
|
||||
@@ -85,7 +74,6 @@ createLightMap pdata lightPoints nWalls nSils nsurfVs = do
|
||||
|
||||
currentProgram $= Just (_shaderProgram $ _lightingLineShadowShader pdata)
|
||||
drawShader (_lightingLineShadowShader pdata) nSils
|
||||
--depthFunc $= Just Lequal
|
||||
-- draw geometry surfaces
|
||||
cullFace $= Just Back
|
||||
colorMask $= Color4 Disabled Disabled Disabled Enabled
|
||||
@@ -105,11 +93,8 @@ createLightMap pdata lightPoints nWalls nSils nsurfVs = do
|
||||
drawShader (_lightingWallShader pdata) nWalls
|
||||
cullFace $= Nothing
|
||||
stencilTest $= Disabled
|
||||
--blend $= Disabled
|
||||
{- |
|
||||
Blur between two framebuffers.
|
||||
Assumes no depth testing is done
|
||||
-}
|
||||
{- | Blur between two framebuffers.
|
||||
Assumes no depth testing is done -}
|
||||
pingPongBlur :: RenderData -> IO ()
|
||||
pingPongBlur pdata = do
|
||||
bindFramebuffer Framebuffer $= fst (_fbo3 pdata)
|
||||
@@ -119,7 +104,6 @@ pingPongBlur pdata = do
|
||||
bindFramebuffer Framebuffer $= fst (_fbo2 pdata)
|
||||
textureBinding Texture2D $= Just (snd $ _fbo3 pdata)
|
||||
drawShader (_bloomBlurShader pdata) 4
|
||||
|
||||
-- assumes that vertices have already been sent to the shader
|
||||
pingPongBetween
|
||||
:: (FramebufferObject,TextureObject)
|
||||
@@ -145,24 +129,6 @@ drawTextureOnFramebuffer fs fbo to = do
|
||||
textureBinding Texture2D $= Just to
|
||||
drawShader fs 4
|
||||
|
||||
pokeBindFoldable
|
||||
:: MV.MVector (PrimState IO) FullShader
|
||||
-> UMV.MVector (PrimState IO) Int
|
||||
-> [Verx]
|
||||
-> IO ()
|
||||
pokeBindFoldable shadV counts m = do
|
||||
pokeVerxs shadV counts m
|
||||
bindShader shadV counts
|
||||
|
||||
pokeBindFoldableLayer
|
||||
:: MV.MVector (PrimState IO) FullShader
|
||||
-> UMV.MVector (PrimState IO) Int
|
||||
-> Picture
|
||||
-> IO ()
|
||||
pokeBindFoldableLayer shadV counts m = do
|
||||
pokeLayVerxs shadV counts m
|
||||
bindShaderLayers shadV counts
|
||||
|
||||
renderFoldable
|
||||
:: MV.MVector (PrimState IO) FullShader
|
||||
-> [Verx]
|
||||
@@ -170,7 +136,7 @@ renderFoldable
|
||||
renderFoldable shadV struct = do
|
||||
counts <- UMV.replicate 6 0
|
||||
pokeBindFoldable shadV counts struct
|
||||
MV.imapM_ (drawShaderLay' 0 counts) shadV
|
||||
MV.imapM_ (drawShaderLay 0 counts) shadV
|
||||
|
||||
renderFoldableTimed
|
||||
:: MV.MVector (PrimState IO) FullShader
|
||||
@@ -180,11 +146,10 @@ renderFoldableTimed shadV struct = do
|
||||
pokeStartTicks <- SDL.ticks
|
||||
counts <- UMV.replicate 6 0
|
||||
pokeBindFoldable shadV counts struct
|
||||
MV.imapM_ (drawShaderLay' 0 counts) shadV
|
||||
MV.imapM_ (drawShaderLay 0 counts) shadV
|
||||
pokeEndTicks <- SDL.ticks
|
||||
return $ pokeEndTicks - pokeStartTicks
|
||||
------------------------------end renderFoldable
|
||||
|
||||
renderLayer
|
||||
:: Int
|
||||
-> MV.MVector (PrimState IO) FullShader
|
||||
@@ -192,7 +157,7 @@ renderLayer
|
||||
-> IO ()
|
||||
renderLayer layer shads counts = do
|
||||
let layerCounts = UMV.slice (layer * 6) 6 counts
|
||||
MV.imapM_ (drawShaderLay' layer layerCounts) shads
|
||||
MV.imapM_ (drawShaderLay layer layerCounts) shads
|
||||
|
||||
pokeTwoOff
|
||||
:: Ptr Float
|
||||
|
||||
Reference in New Issue
Block a user