-- | Load a shader program from vertex, geometry, and fragment shaders
-- that all share the same root file name and the various conventional
-- extensions: \".vert\", \".geom\", and \".frag\". If a specific file
-- doesn't exist, such as a geometry shader, it is skipped. For
-- instance, @loadShaderFamily "simple"@ will load and compile,
-- \"simple.vert\" and \"simple.frag\" if those files exist.
loadShaderFamily :: FilePath -> IO ShaderProgram
loadShaderFamily root = mapM aux shaderTypes >>= loadShaderProgram . catMaybes
  where shaderTypes = [ (VertexShader, "vert")
                      , (GeometryShader, "geom")
                      , (FragmentShader, "frag") ]
        aux (tag, ext) = let f = root <.> ext
                         in doesFileExist f >>= \b -> return $
                              if b then Just (tag, f) else Nothing

-- | Get all attributes and uniforms used by a program. Note that
-- unused parameters may be elided by the compiler, and so will not be
-- considered as active.
loadShaderFamily :: FilePath -> IO ShaderProgram
loadShaderFamily root = mapM aux shaderTypes >>= loadShaderProgram . catMaybes
  where shaderTypes = [ (VertexShader, "vert")
                      , (GeometryShader, "geom")
                      , (FragmentShader, "frag") ]
        aux (tag, ext) = let f = root <.> ext
                         in doesFileExist f >>= \b -> return $
                              if b then Just (tag, f) else Nothing

-- | Get all attributes and uniforms used by a program. Note that
-- unused parameters may be elided by the compiler, and so will not be
-- considered as active.
loadShaderFamily root = mapM aux shaderTypes >>= loadShaderProgram . catMaybes
  where shaderTypes = [ (VertexShader, "vert")
                      , (GeometryShader, "geom")
                      , (FragmentShader, "frag") ]
        aux (tag, ext) = let f = root <.> ext
                         in doesFileExist f >>= \b -> return $
                              if b then Just (tag, f) else Nothing

-- | Get all attributes and uniforms used by a program. Note that
-- unused parameters may be elided by the compiler, and so will not be
-- considered as active.