Apply Hlints
This commit is contained in:
+12
-10
@@ -19,7 +19,7 @@ module Shader
|
||||
, freeShaderPointers
|
||||
, module Shader.Data
|
||||
)
|
||||
where
|
||||
where
|
||||
import Shader.Data
|
||||
|
||||
import Foreign
|
||||
@@ -27,7 +27,7 @@ import Codec.Picture
|
||||
|
||||
import qualified Data.Vector.Storable as V
|
||||
|
||||
import Control.Monad (when, forM, zipWithM_, forM_, foldM)
|
||||
import Control.Monad (when, unless, forM, zipWithM_, forM_, foldM)
|
||||
import Control.Lens
|
||||
|
||||
import Data.Maybe (fromMaybe)
|
||||
@@ -51,9 +51,10 @@ pokeShaders fss = traverse pokeShader fss
|
||||
|
||||
pokeShader :: FullShader a -> F.FoldM IO a Int
|
||||
pokeShader fs = F.FoldM (pokeRender fls (zip ptrs nAtss)) (return 0) return
|
||||
where vao = _shaderVAO fs
|
||||
(_,ptrs,nAtss) = unzip3 $ _vaoBufferTargets $ vao
|
||||
fls = _shaderPokeStrategy fs
|
||||
where
|
||||
vao = _shaderVAO fs
|
||||
(_,ptrs,nAtss) = unzip3 $ _vaoBufferTargets vao
|
||||
fls = _shaderPokeStrategy fs
|
||||
|
||||
pokeRender :: (a -> [[[Float]]])
|
||||
-> [(Ptr Float,Int)] -> Int -> a -> IO Int
|
||||
@@ -66,7 +67,7 @@ pokePtrs :: [(Ptr Float,Int)] -> Int -> [[Float]] -> IO Int
|
||||
pokePtrs ptrIs n fss = do
|
||||
zipWithM_ f ptrIs fss
|
||||
return $ n + 1
|
||||
where f (ptr,i) fs = pokeArrayOff ptr (i*n) fs
|
||||
where f (ptr,i) fs = pokeArrayOff ptr (i*n) fs
|
||||
|
||||
pokeArrayOff :: Storable a => Ptr a -> Int -> [a] -> IO ()
|
||||
pokeArrayOff ptr i xs =
|
||||
@@ -83,7 +84,8 @@ bindArrayBuffers numVs ps = do
|
||||
bindShaderBuffers :: [FullShader a] -> [Int] -> IO ()
|
||||
bindShaderBuffers fss is =
|
||||
zipWithM_ f fss is
|
||||
where f fs i = bindArrayBuffers i $ _vaoBufferTargets $ _shaderVAO fs
|
||||
where
|
||||
f fs i = bindArrayBuffers i $ _vaoBufferTargets $ _shaderVAO fs
|
||||
|
||||
drawShaders :: [FullShader a] -> [Int] -> IO ()
|
||||
drawShaders fss is =
|
||||
@@ -116,7 +118,7 @@ addTexture texturePath shad = do
|
||||
(PixelData RGBA UnsignedByte ptr)
|
||||
generateMipmap' Texture2D
|
||||
textureFilter Texture2D $= ((Linear',Just Linear') , Nearest)
|
||||
return $ shad & shaderTexture .~ Just (ShaderTexture {_textureObject = textureOb})
|
||||
return $ shad & shaderTexture ?~ ShaderTexture {_textureObject = textureOb}
|
||||
|
||||
makeShader :: String -> [ShaderType] -> [(GLuint,Int)] -> PrimitiveMode -> (a -> [[[Float]]]) -> IO (FullShader a)
|
||||
makeShader s shaderlist alocs pm renStrat = do
|
||||
@@ -198,7 +200,7 @@ makeShaderProgram str sources = do
|
||||
|
||||
linkProgram shaderProgram
|
||||
linkingSuccess <- linkStatus shaderProgram
|
||||
when (not linkingSuccess) $ do
|
||||
unless linkingSuccess $ do
|
||||
infoLog <- get (programInfoLog shaderProgram)
|
||||
putStrLn $ str ++ ": Program Linking" ++ infoLog
|
||||
|
||||
@@ -210,7 +212,7 @@ compileAndCheckShader str (shaderType,sourceCode) = do
|
||||
shaderSourceBS theShader $= sourceCode
|
||||
compileShader theShader
|
||||
success <- compileStatus theShader
|
||||
when (not success) $ do
|
||||
unless success $ do
|
||||
infoLog <- get (shaderInfoLog theShader)
|
||||
putStrLn $ str ++ ": Shader compile: " ++ show shaderType ++ " : " ++ show infoLog
|
||||
return theShader
|
||||
|
||||
Reference in New Issue
Block a user