packages feed

GLUtil 0.6.3 → 0.6.4

raw patch · 5 files changed

+32/−7 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Graphics.GLUtil.Linear: instance AsUniform (V1 GLfloat)
+ Graphics.GLUtil.Linear: instance AsUniform (V1 GLint)
+ Graphics.GLUtil.Linear: instance AsUniform (V1 GLuint)
+ Graphics.GLUtil.Linear: instance AsUniform [V1 GLfloat]
+ Graphics.GLUtil.Linear: instance AsUniform [V1 GLint]
+ Graphics.GLUtil.Linear: instance AsUniform [V1 GLuint]
+ Graphics.GLUtil.Textures: withTexturesAt :: TextureTarget -> [(TextureObject, GLuint)] -> IO a -> IO a
+ Graphics.GLUtil.TypeMapping: instance HasVariableType t => HasVariableType [t]

Files

GLUtil.cabal view
@@ -1,5 +1,5 @@ Name:                GLUtil-Version:             0.6.3+Version:             0.6.4 Synopsis:            Miscellaneous OpenGL utilities. License:             BSD3 License-file:        LICENSE
src/Graphics/GLUtil/Linear.hs view
@@ -38,6 +38,7 @@  #define UNIFORMVEC(d) UNIFORMVEC_T(d,GLint,i); UNIFORMVEC_T(d,GLuint,ui); UNIFORMVEC_T(d,GLfloat,f) +UNIFORMVEC(1) UNIFORMVEC(2) UNIFORMVEC(3) UNIFORMVEC(4)@@ -60,6 +61,7 @@  #define UNIFORMARRAY(d) UNIFORMARRAY_T(d,GLint,i); UNIFORMARRAY_T(d,GLuint,ui); UNIFORMARRAY_T(d,GLfloat,f) +UNIFORMARRAY(1) UNIFORMARRAY(2) UNIFORMARRAY(3) UNIFORMARRAY(4)
src/Graphics/GLUtil/ShaderProgram.hs view
@@ -10,7 +10,7 @@                                       setUniform, getUniform) where import Prelude hiding (lookup) import Control.Applicative ((<$>), (<*>))-import Data.List (find, findIndex)+import Data.List (find, findIndex, isSuffixOf) import Data.Map.Strict (Map, fromList, lookup) import Data.Maybe (isJust, isNothing, catMaybes) import Graphics.GLUtil.Shaders (loadShader, loadGeoShader, linkShaderProgram,@@ -95,8 +95,13 @@                  , [(String, (UniformLocation, VariableType))] ) getActives p =    (,) <$> (get (activeAttribs p) >>= mapM (aux (attribLocation p)))-      <*> (get (activeUniforms p) >>= mapM (aux (uniformLocation p)))+      <*> (get (activeUniforms p)+           >>= mapM (aux (uniformLocation p) . on3 trimArray))   where aux f (_,t,name) = get (f name) >>= \l -> return (name, (l, t))+        on3 f (a,b,c) = (a, b, f c)+        -- An array uniform, foo, is sometimes given the name "foo" and+        -- sometimes the name "foo[0]". We strip off the "[0]" if present.+        trimArray n = if "[0]" `isSuffixOf` n then take (length n - 3) n else n  -- | Get the attribute and uniform locations associated with a list of -- the names of each.
src/Graphics/GLUtil/Textures.hs view
@@ -114,7 +114,7 @@   -- | Bind each of the given textures to successive texture units at--- the given 'TextureTarget'.+-- the given 'TextureTarget' starting with texture unit 0. withTextures :: TextureTarget -> [TextureObject] -> IO a -> IO a withTextures tt ts m = do mapM_ aux (zip ts [0..])                           r <- m@@ -124,12 +124,27 @@                        textureBinding tt $= Just t         cleanup _ [] = return ()         cleanup i (_:ts') = do activeTexture $= TextureUnit i-                               textureBinding Texture2D $= Nothing+                               textureBinding tt $= Nothing                                cleanup (i+1) ts' --- | Bind each of the given 2D textures to successive texture units.+-- | Bind each of the given 2D textures to successive texture units+-- starting with texture unit 0. withTextures2D :: [TextureObject] -> IO a -> IO a withTextures2D = withTextures Texture2D++-- | Bind each of the given textures to the texture unit they are+-- paired with. The given action is run with these bindings, then the+-- texture bindings are reset. If you don't care which texture units+-- are used, consider using 'withTextures' or 'withTextures2D'.+withTexturesAt :: TextureTarget -> [(TextureObject,GLuint)] -> IO a -> IO a+withTexturesAt tt ts m = do mapM_ aux ts+                            r <- m+                            mapM_ (cleanup . snd) ts+                            return r+  where aux (t,i) = do activeTexture $= TextureUnit i+                       textureBinding tt $= Just t+        cleanup i = do activeTexture $= TextureUnit i+                       textureBinding tt $= Nothing  -- | Generate a complete set of mipmaps for the currently bound -- texture object.
src/Graphics/GLUtil/TypeMapping.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}+{-# LANGUAGE FlexibleInstances, ScopedTypeVariables, TypeSynonymInstances #-} -- |This module contains classes and functions to relate Haskell types -- with OpenGL DataTypes (typically used to describe the values stored -- in arrays) and VariableTypes (used as attributes and uniforms in@@ -52,6 +52,9 @@ instance HasVariableType (M22 GLfloat) where variableType _ = FloatMat2 instance HasVariableType (M33 GLfloat) where variableType _ = FloatMat3 instance HasVariableType (M44 GLfloat) where variableType _ = FloatMat4++instance forall t. HasVariableType t => HasVariableType [t] where +  variableType _ = variableType (undefined::t)  -- | Maps each 'VariableType' to its corresponding -- 'DataType'. Typically this indicates the element type of composite