Remove RenderType datatype
This commit is contained in:
+4
-11
@@ -9,7 +9,6 @@ module Shader.Compile
|
||||
) where
|
||||
import Shader.Data
|
||||
import Shader.Parameters
|
||||
import Picture.Data
|
||||
|
||||
import Foreign
|
||||
import qualified Data.ByteString as BS
|
||||
@@ -26,9 +25,8 @@ makeVShader
|
||||
-> [ShaderType] -- ^ Filetype extensions
|
||||
-> [Int] -- ^ The input vertex sizes
|
||||
-> EPrimitiveMode
|
||||
-> (VertexType -> Bool)
|
||||
-> IO VShader
|
||||
makeVShader s shaderlist sizes renStrat vtest = do
|
||||
makeVShader s shaderlist sizes pm = do
|
||||
prog <- makeSourcedShader s shaderlist
|
||||
vaob <- setupVAO sizes
|
||||
return $ VShader
|
||||
@@ -36,8 +34,7 @@ makeVShader s shaderlist sizes renStrat vtest = do
|
||||
, _vshaderVAO = vaob
|
||||
, _vshaderTexture = Nothing
|
||||
, _vshaderCustomUnis = []
|
||||
, _vshaderPokeTest = vtest
|
||||
, _vshaderDrawPrimitive = renStrat
|
||||
, _vshaderDrawPrimitive = pm
|
||||
}
|
||||
|
||||
-- | Takes the VAO and poke strategy from another shader
|
||||
@@ -64,15 +61,13 @@ makeShader
|
||||
-> [ShaderType] -- ^ Filetype extensions
|
||||
-> [Int] -- ^ The input vertex sizes
|
||||
-> EPrimitiveMode
|
||||
-> (RenderType -> [[Float]]) -- ^ Poke strategy: method for creating a list of vertex data to be bound
|
||||
-> IO FullShader
|
||||
makeShader s shaderlist sizes pm renStrat = do
|
||||
makeShader s shaderlist sizes pm = do
|
||||
prog <- makeSourcedShader s shaderlist
|
||||
vaob <- setupVAO sizes
|
||||
return $ FullShader
|
||||
{ _shaderProgram = prog
|
||||
, _shaderVAO = vaob
|
||||
, _shaderPokeStrategy = renStrat
|
||||
, _shaderDrawPrimitive = pm
|
||||
, _shaderTexture = Nothing
|
||||
, _shaderCustomUnis = []
|
||||
@@ -87,15 +82,13 @@ makeShaderSized
|
||||
-> [Int] -- ^ The input vertex sizes
|
||||
-> Int -- ^ Number of vertexes that can be poked
|
||||
-> EPrimitiveMode
|
||||
-> (RenderType -> [[Float]]) -- ^ Poke strategy: method for creating a list of vertex data to be bound
|
||||
-> IO FullShader
|
||||
makeShaderSized s shaderlist sizes ndraw pm renStrat = do
|
||||
makeShaderSized s shaderlist sizes ndraw pm = do
|
||||
prog <- makeSourcedShader s shaderlist
|
||||
vaob <- setupVAOSized sizes ndraw
|
||||
return $ FullShader
|
||||
{ _shaderProgram = prog
|
||||
, _shaderVAO = vaob
|
||||
, _shaderPokeStrategy = renStrat
|
||||
, _shaderDrawPrimitive = pm
|
||||
, _shaderTexture = Nothing
|
||||
, _shaderCustomUnis = []
|
||||
|
||||
@@ -16,7 +16,6 @@ module Shader.Data
|
||||
|
||||
, shaderProgram
|
||||
, shaderVAO
|
||||
, shaderPokeStrategy
|
||||
, shaderDrawPrimitive
|
||||
, shaderTexture
|
||||
, shaderCustomUnis
|
||||
@@ -26,7 +25,6 @@ module Shader.Data
|
||||
, vshaderDrawPrimitive
|
||||
, vshaderTexture
|
||||
, vshaderCustomUnis
|
||||
, vshaderPokeTest
|
||||
|
||||
, psPoly
|
||||
, psPolyz
|
||||
@@ -38,8 +36,6 @@ module Shader.Data
|
||||
-- TODO make lenses for VBO object
|
||||
-- , textureObject
|
||||
) where
|
||||
import Picture.Data
|
||||
|
||||
import Graphics.Rendering.OpenGL
|
||||
import Foreign
|
||||
import Control.Lens
|
||||
@@ -66,7 +62,6 @@ data VShader = VShader
|
||||
, _vshaderDrawPrimitive :: EPrimitiveMode
|
||||
, _vshaderTexture :: Maybe ShaderTexture
|
||||
, _vshaderCustomUnis :: [UniformLocation]
|
||||
, _vshaderPokeTest :: VertexType -> Bool
|
||||
}
|
||||
data PicShads a = PicShads
|
||||
{ _psPoly :: a
|
||||
@@ -136,7 +131,6 @@ instance Foldable PicShads where
|
||||
data FullShader = FullShader
|
||||
{ _shaderProgram :: Program
|
||||
, _shaderVAO :: VAO
|
||||
, _shaderPokeStrategy :: RenderType -> [[Float]]-- -> F.FoldM IO RenderType Int
|
||||
, _shaderDrawPrimitive :: EPrimitiveMode
|
||||
, _shaderTexture :: Maybe ShaderTexture
|
||||
, _shaderCustomUnis :: [UniformLocation]
|
||||
|
||||
+21
-2
@@ -8,6 +8,7 @@ module Shader.Poke
|
||||
, pokePoint33s
|
||||
, pokeVerxs
|
||||
, pokeLayVerxs
|
||||
, pokeWalls
|
||||
) where
|
||||
import Shader.Data
|
||||
import Shader.Parameters
|
||||
@@ -55,7 +56,7 @@ pokeVerxs :: PicShads VBO -> [Verx] -> IO (PicShads Int)
|
||||
pokeVerxs vbos vxs0 = go vxs0 (pure 0)
|
||||
where
|
||||
go [] count = return count
|
||||
go (!vx:vxs) count = pokeVerx vbos count vx >> go vxs (addCountVerx count vx)
|
||||
go (!vx:vxs) !count = pokeVerx vbos count vx >> (go vxs $! addCountVerx count vx)
|
||||
|
||||
-- this is very brittle, but want to optimise speed if possible here
|
||||
pokeVerx :: PicShads VBO -> PicShads Int -> Verx -> IO ()
|
||||
@@ -175,7 +176,7 @@ pokeLayVerxs :: PicShads VBO -> [Verx] -> IO (IM.IntMap (PicShads Int))
|
||||
pokeLayVerxs vbos vxs0 = go vxs0 (IM.fromList $ (, pure 0) <$> [0..5])
|
||||
where
|
||||
go [] count = return count
|
||||
go (!vx:vxs) count = pokeLayVerx vbos count vx >> go vxs (addLayCountVerx count vx)
|
||||
go (!vx:vxs) !count = pokeLayVerx vbos count vx >> (go vxs $! addLayCountVerx count vx)
|
||||
|
||||
-- this is very brittle, but want to optimise speed if possible here
|
||||
pokeLayVerx :: PicShads VBO -> IM.IntMap (PicShads Int) -> Verx -> IO ()
|
||||
@@ -214,3 +215,21 @@ addLayCountVerx :: IM.IntMap (PicShads Int) -> Verx -> IM.IntMap (PicShads Int)
|
||||
addLayCountVerx m vx = IM.adjust f (_vxLayer vx) m
|
||||
where
|
||||
f = flip addCountVerx vx
|
||||
|
||||
pokeWalls :: Ptr Float -> [((Point2,Point2),Point4)] -> IO Int
|
||||
pokeWalls ptr vals0 = go vals0 0
|
||||
where
|
||||
go [] n = return n
|
||||
go ((((V2 a b),(V2 c d)),(V4 e f g h)):vals) !n = do
|
||||
pokeElemOff ptr (off 0) a
|
||||
pokeElemOff ptr (off 1) b
|
||||
pokeElemOff ptr (off 2) c
|
||||
pokeElemOff ptr (off 3) d
|
||||
pokeElemOff ptr (off 4) e
|
||||
pokeElemOff ptr (off 5) f
|
||||
pokeElemOff ptr (off 6) g
|
||||
pokeElemOff ptr (off 7) h
|
||||
go vals (n+1)
|
||||
where
|
||||
off i = n*8 + i
|
||||
|
||||
|
||||
Reference in New Issue
Block a user