Hello community, here is the log from the commit of package ghc-OpenGL for openSUSE:Factory checked in at 2016-05-17 17:15:54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-OpenGL (Old) and /work/SRC/openSUSE:Factory/.ghc-OpenGL.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-OpenGL" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-OpenGL/ghc-OpenGL.changes 2016-04-22 16:25:27.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-OpenGL.new/ghc-OpenGL.changes 2016-05-17 17:15:54.000000000 +0200 @@ -1,0 +2,9 @@ +Thu May 12 19:12:48 UTC 2016 - [email protected] + +- update to 3.0.1.0 +* Added Uniform instances for GLmatrix, Vertex1, Vector1, Vector2, Vector3, + and Vector4. +* Unbreak Uniform instances for GLint, GLuint and Gldouble. +* Relaxed upper version bound for OpenGLRaw. + +------------------------------------------------------------------- Old: ---- OpenGL-3.0.0.2.tar.gz New: ---- OpenGL-3.0.1.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-OpenGL.spec ++++++ --- /var/tmp/diff_new_pack.QcBTH8/_old 2016-05-17 17:15:55.000000000 +0200 +++ /var/tmp/diff_new_pack.QcBTH8/_new 2016-05-17 17:15:55.000000000 +0200 @@ -19,7 +19,7 @@ %global pkg_name OpenGL Name: ghc-OpenGL -Version: 3.0.0.2 +Version: 3.0.1.0 Release: 0 Summary: A binding for the OpenGL graphics system License: BSD-3-Clause ++++++ OpenGL-3.0.0.2.tar.gz -> OpenGL-3.0.1.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenGL-3.0.0.2/CHANGELOG.md new/OpenGL-3.0.1.0/CHANGELOG.md --- old/OpenGL-3.0.0.2/CHANGELOG.md 2016-04-11 08:30:08.000000000 +0200 +++ new/OpenGL-3.0.1.0/CHANGELOG.md 2016-05-11 14:20:57.000000000 +0200 @@ -1,3 +1,9 @@ +3.0.1.0 +------- +* Added `Uniform` instances for `GLmatrix`, `Vertex1`, `Vector1`, `Vector2`, `Vector3`, and `Vector4`. +* Unbreak `Uniform` instances for `GLint`, `GLuint` and `Gldouble`. +* Relaxed upper version bound for `OpenGLRaw`. + 3.0.0.2 ------- * Removed redundant constraints. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenGL-3.0.0.2/OpenGL.cabal new/OpenGL-3.0.1.0/OpenGL.cabal --- old/OpenGL-3.0.0.2/OpenGL.cabal 2016-04-11 08:30:36.000000000 +0200 +++ new/OpenGL-3.0.1.0/OpenGL.cabal 2016-05-11 14:20:57.000000000 +0200 @@ -1,5 +1,5 @@ name: OpenGL -version: 3.0.0.2 +version: 3.0.1.0 synopsis: A binding for the OpenGL graphics system description: A Haskell binding for the OpenGL graphics system (GL, version 4.5) and its @@ -126,6 +126,7 @@ Graphics.Rendering.OpenGL.GL.FramebufferObjects.RenderbufferTarget Graphics.Rendering.OpenGL.GL.GLboolean Graphics.Rendering.OpenGL.GL.IOState + Graphics.Rendering.OpenGL.GL.MatrixComponent Graphics.Rendering.OpenGL.GL.PeekPoke Graphics.Rendering.OpenGL.GL.PixelData Graphics.Rendering.OpenGL.GL.PixelFormat @@ -162,7 +163,7 @@ transformers >= 0.2 && < 0.6, ObjectName >= 1.1 && < 1.2, StateVar >= 1.1 && < 1.2, - OpenGLRaw >= 3.0 && < 3.2, + OpenGLRaw >= 3.0 && < 3.3, GLURaw >= 2.0 && < 2.1 default-language: Haskell2010 other-extensions: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenGL-3.0.0.2/src/Graphics/Rendering/OpenGL/GL/CoordTrans.hs new/OpenGL-3.0.1.0/src/Graphics/Rendering/OpenGL/GL/CoordTrans.hs --- old/OpenGL-3.0.0.2/src/Graphics/Rendering/OpenGL/GL/CoordTrans.hs 2016-01-04 08:30:21.000000000 +0100 +++ new/OpenGL-3.0.1.0/src/Graphics/Rendering/OpenGL/GL/CoordTrans.hs 2016-05-11 10:58:44.000000000 +0200 @@ -13,8 +13,6 @@ -- -------------------------------------------------------------------------------- -{-# LANGUAGE TypeSynonymInstances #-} - module Graphics.Rendering.OpenGL.GL.CoordTrans ( -- * Controlling the Viewport depthRange, @@ -43,9 +41,9 @@ import Foreign.Marshal.Utils import Foreign.Ptr import Foreign.Storable -import Graphics.Rendering.OpenGL.GL.Tensor import Graphics.Rendering.OpenGL.GL.Capability import Graphics.Rendering.OpenGL.GL.Exception +import Graphics.Rendering.OpenGL.GL.MatrixComponent import Graphics.Rendering.OpenGL.GL.PeekPoke import Graphics.Rendering.OpenGL.GL.QueryUtils import Graphics.Rendering.OpenGL.GL.Texturing.TextureUnit @@ -180,38 +178,6 @@ -------------------------------------------------------------------------------- -class Storable c => MatrixComponent c where - getMatrix :: GetPNameMatrix p => p -> Ptr c -> IO () - loadMatrix :: Ptr c -> IO () - loadTransposeMatrix :: Ptr c -> IO () - multMatrix_ :: Ptr c -> IO () - multTransposeMatrix :: Ptr c -> IO () - rotate :: c -> Vector3 c -> IO () - translate :: Vector3 c -> IO () - scale :: c -> c -> c -> IO () - -instance MatrixComponent GLfloat where - getMatrix = getMatrixf - loadMatrix = glLoadMatrixf - loadTransposeMatrix = glLoadTransposeMatrixf - multMatrix_ = glMultMatrixf - multTransposeMatrix = glMultTransposeMatrixf - rotate a (Vector3 x y z) = glRotatef a x y z - translate (Vector3 x y z) = glTranslatef x y z - scale = glScalef - -instance MatrixComponent GLdouble where - getMatrix = getMatrixd - loadMatrix = glLoadMatrixd - loadTransposeMatrix = glLoadTransposeMatrixd - multMatrix_ = glMultMatrixd - multTransposeMatrix = glMultTransposeMatrixd - rotate a (Vector3 x y z) = glRotated a x y z - translate (Vector3 x y z) = glTranslated x y z - scale = glScaled - --------------------------------------------------------------------------------- - class Matrix m where -- | Create a new matrix of the given order (containing undefined elements) -- and call the action to fill it with 4x4 elements. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenGL-3.0.0.2/src/Graphics/Rendering/OpenGL/GL/MatrixComponent.hs new/OpenGL-3.0.1.0/src/Graphics/Rendering/OpenGL/GL/MatrixComponent.hs --- old/OpenGL-3.0.0.2/src/Graphics/Rendering/OpenGL/GL/MatrixComponent.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/OpenGL-3.0.1.0/src/Graphics/Rendering/OpenGL/GL/MatrixComponent.hs 2016-05-11 10:58:44.000000000 +0200 @@ -0,0 +1,61 @@ +{-# LANGUAGE TypeSynonymInstances #-} +{-# OPTIONS_HADDOCK hide #-} +-------------------------------------------------------------------------------- +-- | +-- Module : Graphics.Rendering.OpenGL.GL.CoordTrans +-- Copyright : (c) Sven Panne 2002-2016 +-- License : BSD3 +-- +-- Maintainer : Sven Panne <[email protected]> +-- Stability : stable +-- Portability : portable +-- +-- This is a purely internal module for handling matrix components. +-- +-------------------------------------------------------------------------------- + +module Graphics.Rendering.OpenGL.GL.MatrixComponent where + +import Foreign.Ptr +import Foreign.Storable +import Graphics.Rendering.OpenGL.GL.QueryUtils +import Graphics.Rendering.OpenGL.GL.Tensor +import Graphics.GL + +-------------------------------------------------------------------------------- + +class Storable c => MatrixComponent c where + getMatrix :: GetPNameMatrix p => p -> Ptr c -> IO () + loadMatrix :: Ptr c -> IO () + loadTransposeMatrix :: Ptr c -> IO () + multMatrix_ :: Ptr c -> IO () + multTransposeMatrix :: Ptr c -> IO () + getUniformv :: GLuint -> GLint -> Ptr c -> IO () + uniformMatrix4v :: GLint -> GLsizei -> GLboolean -> Ptr c -> IO () + rotate :: c -> Vector3 c -> IO () + translate :: Vector3 c -> IO () + scale :: c -> c -> c -> IO () + +instance MatrixComponent GLfloat where + getMatrix = getMatrixf + loadMatrix = glLoadMatrixf + loadTransposeMatrix = glLoadTransposeMatrixf + multMatrix_ = glMultMatrixf + multTransposeMatrix = glMultTransposeMatrixf + getUniformv = glGetUniformfv + uniformMatrix4v = glUniformMatrix4fv + rotate a (Vector3 x y z) = glRotatef a x y z + translate (Vector3 x y z) = glTranslatef x y z + scale = glScalef + +instance MatrixComponent GLdouble where + getMatrix = getMatrixd + loadMatrix = glLoadMatrixd + loadTransposeMatrix = glLoadTransposeMatrixd + multMatrix_ = glMultMatrixd + multTransposeMatrix = glMultTransposeMatrixd + getUniformv = glGetUniformdv + uniformMatrix4v = glUniformMatrix4dv + rotate a (Vector3 x y z) = glRotated a x y z + translate (Vector3 x y z) = glTranslated x y z + scale = glScaled diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/OpenGL-3.0.0.2/src/Graphics/Rendering/OpenGL/GL/Shaders/Uniform.hs new/OpenGL-3.0.1.0/src/Graphics/Rendering/OpenGL/GL/Shaders/Uniform.hs --- old/OpenGL-3.0.0.2/src/Graphics/Rendering/OpenGL/GL/Shaders/Uniform.hs 2016-04-11 08:27:11.000000000 +0200 +++ new/OpenGL-3.0.1.0/src/Graphics/Rendering/OpenGL/GL/Shaders/Uniform.hs 2016-05-11 14:20:57.000000000 +0200 @@ -1,3 +1,4 @@ +{-# LANGUAGE TypeSynonymInstances #-} ----------------------------------------------------------------------------- -- | -- Module : Graphics.Rendering.OpenGL.GL.Shaders.Uniform @@ -13,8 +14,6 @@ -- ----------------------------------------------------------------------------- -{-# LANGUAGE TypeSynonymInstances #-} - module Graphics.Rendering.OpenGL.GL.Shaders.Uniform ( -- * Uniform variables UniformLocation(..), uniformLocation, activeUniforms, Uniform(..), @@ -29,6 +28,9 @@ import Foreign.Ptr import Foreign.Storable import Graphics.Rendering.OpenGL.GL.ByteString +import Graphics.Rendering.OpenGL.GL.CoordTrans +import Graphics.Rendering.OpenGL.GL.GLboolean +import Graphics.Rendering.OpenGL.GL.MatrixComponent import Graphics.Rendering.OpenGL.GL.Shaders.Program import Graphics.Rendering.OpenGL.GL.Shaders.ProgramObjects import Graphics.Rendering.OpenGL.GL.Shaders.Variables @@ -74,7 +76,7 @@ uniform3 :: UniformLocation -> a -> a -> a -> IO () uniform4 :: UniformLocation -> a -> a -> a -> a -> IO () - getUniform :: Storable (b a) => Program -> UniformLocation -> Ptr (b a) -> IO () + getUniform :: Storable (b a) => GLuint -> GLint -> Ptr (b a) -> IO () uniform1v :: UniformLocation -> GLsizei -> Ptr a -> IO () uniform2v :: UniformLocation -> GLsizei -> Ptr a -> IO () @@ -87,7 +89,7 @@ uniform3 (UniformLocation ul) = glUniform3i ul uniform4 (UniformLocation ul) = glUniform4i ul - getUniform (Program p) (UniformLocation ul) = glGetUniformiv p ul . castPtr + getUniform p ul = glGetUniformiv p ul . castPtr uniform1v (UniformLocation ul) = glUniform1iv ul uniform2v (UniformLocation ul) = glUniform2iv ul @@ -100,7 +102,7 @@ uniform3 (UniformLocation ul) = glUniform3ui ul uniform4 (UniformLocation ul) = glUniform4ui ul - getUniform (Program p) (UniformLocation ul) = glGetUniformuiv p ul . castPtr + getUniform p ul = glGetUniformuiv p ul . castPtr uniform1v (UniformLocation ul) = glUniform1uiv ul uniform2v (UniformLocation ul) = glUniform2uiv ul @@ -113,7 +115,7 @@ uniform3 (UniformLocation ul) = glUniform3f ul uniform4 (UniformLocation ul) = glUniform4f ul - getUniform (Program p) (UniformLocation ul) = glGetUniformfv p ul . castPtr + getUniform p ul = glGetUniformfv p ul . castPtr uniform1v (UniformLocation ul) = glUniform1fv ul uniform2v (UniformLocation ul) = glUniform2fv ul @@ -126,7 +128,7 @@ uniform3 (UniformLocation ul) = glUniform3d ul uniform4 (UniformLocation ul) = glUniform4d ul - getUniform (Program p) (UniformLocation ul) = glGetUniformdv p ul . castPtr + getUniform p ul = glGetUniformdv p ul . castPtr uniform1v (UniformLocation ul) = glUniform1dv ul uniform2v (UniformLocation ul) = glUniform2dv ul @@ -152,38 +154,35 @@ => (UniformLocation -> b a -> IO ()) -> UniformLocation -> StateVar (b a) makeUniformVar setter location = makeStateVar getter (setter location) - where getter = do program <- fmap fromJust $ get currentProgram - allocaBytes maxUniformBufferSize $ \buf -> do - getUniform program location buf - peek buf - -getSimpleUniform :: Program -> UniformLocation -> Ptr a -> IO () -getSimpleUniform (Program p) (UniformLocation ul) = glGetUniformfv p ul . castPtr - -makeSimpleUniformVar :: (UniformComponent a) - => UniformLocation -> StateVar a -makeSimpleUniformVar location = makeStateVar getter (uniform1 location) - where getter = do program <- fmap fromJust $ get currentProgram - allocaBytes maxUniformBufferSize $ \buf -> do - getSimpleUniform program location buf - peek buf + where getter = allocaBytes maxUniformBufferSize $ \buf -> do + getUniformWith getUniform location buf + peek buf + +single :: (UniformLocation -> StateVar (Vertex1 a)) + -> (UniformLocation -> StateVar a) +single var location = makeStateVar (do Vertex1 x <- get (var location); return x) + (\x -> var location $= Vertex1 x) instance Uniform GLfloat where - uniform = makeSimpleUniformVar + uniform = single uniform uniformv = uniform1v instance Uniform GLint where - uniform = makeSimpleUniformVar + uniform = single uniform uniformv = uniform1v instance Uniform GLuint where - uniform = makeSimpleUniformVar + uniform = single uniform uniformv = uniform1v instance Uniform GLdouble where - uniform = makeSimpleUniformVar + uniform = single uniform uniformv = uniform1v +instance UniformComponent a => Uniform (Vertex1 a) where + uniform = makeUniformVar $ \location (Vertex1 x) -> uniform1 location x + uniformv location count = uniform1v location count . (castPtr :: Ptr (Vertex1 b) -> Ptr b) + instance UniformComponent a => Uniform (Vertex2 a) where uniform = makeUniformVar $ \location (Vertex2 x y) -> uniform2 location x y uniformv location count = uniform2v location count . (castPtr :: Ptr (Vertex2 b) -> Ptr b) @@ -196,6 +195,22 @@ uniform = makeUniformVar $ \location (Vertex4 x y z w) -> uniform4 location x y z w uniformv location count = uniform4v location count . (castPtr :: Ptr (Vertex4 b) -> Ptr b) +instance UniformComponent a => Uniform (Vector1 a) where + uniform = makeUniformVar $ \location (Vector1 x) -> uniform1 location x + uniformv location count = uniform1v location count . (castPtr :: Ptr (Vector1 b) -> Ptr b) + +instance UniformComponent a => Uniform (Vector2 a) where + uniform = makeUniformVar $ \location (Vector2 x y) -> uniform2 location x y + uniformv location count = uniform2v location count . (castPtr :: Ptr (Vector2 b) -> Ptr b) + +instance UniformComponent a => Uniform (Vector3 a) where + uniform = makeUniformVar $ \location (Vector3 x y z) -> uniform3 location x y z + uniformv location count = uniform3v location count . (castPtr :: Ptr (Vector3 b) -> Ptr b) + +instance UniformComponent a => Uniform (Vector4 a) where + uniform = makeUniformVar $ \location (Vector4 x y z w) -> uniform4 location x y z w + uniformv location count = uniform4v location count . (castPtr :: Ptr (Vector4 b) -> Ptr b) + instance UniformComponent a => Uniform (TexCoord1 a) where uniform = makeUniformVar $ \location (TexCoord1 s) -> uniform1 location s uniformv location count = uniform1v location count . (castPtr :: Ptr (TexCoord1 b) -> Ptr b) @@ -236,13 +251,28 @@ -- getUniform. Even worse is that it requires the `GLint` uniforms while it is an enum or -- uint. instance Uniform TextureUnit where - uniform loc@(UniformLocation ul) = makeStateVar getter setter - where setter (TextureUnit tu) = uniform1 loc (fromIntegral tu :: GLint) - getter = do program <- fmap fromJust $ get currentProgram - allocaBytes (sizeOf (undefined :: GLint)) $ \buf -> do - glGetUniformiv (programID program) ul buf - tuID <- peek buf - return . TextureUnit $ fromIntegral tuID + uniform loc = makeStateVar getter setter + where getter = allocaBytes (sizeOf (undefined :: GLint)) $ \buf -> do + getUniformWith glGetUniformiv loc buf + fmap (TextureUnit . fromIntegral) $ peek buf + setter (TextureUnit tu) = uniform1 loc (fromIntegral tu :: GLint) uniformv location count = uniform1v location count . (castPtr :: Ptr TextureUnit -> Ptr GLint) +-- | Note: 'uniformv' expects all matrices to be in 'ColumnMajor' form. +instance MatrixComponent a => Uniform (GLmatrix a) where + uniform loc@(UniformLocation ul) = makeStateVar getter setter + where getter = withNewMatrix ColumnMajor $ getUniformWith getUniformv loc + setter m = withMatrix m $ uniformMatrix4v ul 1 . isRowMajor + uniformv (UniformLocation ul) count buf = + uniformMatrix4v ul count (marshalGLboolean False) (castPtr buf `asTypeOf` elemType buf) + where elemType = undefined :: MatrixComponent c => Ptr (GLmatrix c) -> Ptr c + +isRowMajor :: MatrixOrder -> GLboolean +isRowMajor = marshalGLboolean . (RowMajor ==) + +getUniformWith :: (GLuint -> GLint -> Ptr a -> IO ()) -> UniformLocation -> Ptr a -> IO () +getUniformWith getter (UniformLocation ul) buf = do + program <- fmap (programID . fromJust) $ get currentProgram + getter program ul buf + --------------------------------------------------------------------------------
