Gamgine 0.5.3 → 0.6.0
raw patch · 6 files changed
+64/−56 lines, 6 filesdep −cpphsdep ~GLFW-bdep ~StateVardep ~pretty-show
Dependencies removed: cpphs
Dependency ranges changed: GLFW-b, StateVar, pretty-show, time
Files
- Gamgine.cabal +27/−28
- Gamgine/Gfx.hs +13/−13
- Gamgine/Image/PNG.hs +1/−0
- Gamgine/Image/PNG/Internal/Parser.hs +9/−9
- Gamgine/Math/Matrix.hs +6/−6
- Gamgine/Utils.hs +8/−0
Gamgine.cabal view
@@ -1,24 +1,24 @@-name: Gamgine-version: 0.5.3-cabal-version: >=1.6-build-type: Simple-license: BSD3-license-file: LICENSE-maintainer: daniel.trstenjak@gmail.com-synopsis: Some kind of game library or set of utilities.+cabal-version: >=1.10+name: Gamgine+version: 0.6.0+license: BSD3+license-file: LICENSE+maintainer: daniel.trstenjak@gmail.com+author: Daniel Trstenjak+synopsis: Some kind of game library or set of utilities. description: Some kind of game library or set of utilities, which are mostly/certainly only usable for my own toy projects.-category: Library-author: Daniel Trstenjak-data-files:- Ressources/Fonts/*.glf++category: Library+build-type: Simple+data-files: Ressources/Fonts/*.glf extra-source-files: c_libraries/glf/glf.h c_libraries/glf/glf.c Gamgine/Utils.cpp source-repository head- type: git+ type: git location: https://github.com/dan-t/Gamgine library@@ -51,34 +51,33 @@ Gamgine.Zipper Gamgine.Lens.IORef Gamgine.Lens.State++ build-tools: cpphs >=1.18.4 && <1.21+ cpp-options: -DCABAL+ cc-options: -Wno-unused-result+ c-sources: c_libraries/glf/glf.c+ default-language: Haskell2010+ default-extensions: CPP+ include-dirs: . Gamgine c_libraries/glf+ includes: glf.h+ ghc-options: -pgmPcpphs -optP--cpp build-depends: base >3 && <5,- GLFW-b >=1.0 && <3.3,+ GLFW-b >=1.0 && <3.4, OpenGLRaw >=3.0.0.0 && <3.4, mtl >=2.1.3.1 && <2.3,- time >=1.4.0.1 && <1.9,+ time >=1.4.0.1 && <1.10, Vec >=1.0.1 && <1.1, utility-ht >=0.0.10 && <0.1, directory >=1.2.0.1 && <1.4,- StateVar >=1.0.0.0 && <1.2,+ StateVar >=1.0.0.0 && <1.3, array >=0.4.0.1 && <0.6, bytestring >=0.10.0.2 && <0.11, unordered-containers >=0.2.4.0 && <0.3, data-lens >=2.10.4 && <2.12,- pretty-show >=1.6.7 && <1.8,- cpphs >=1.18.4 && <1.21,+ pretty-show >=1.6.7 && <1.11, filepath >=1.3.0.1 && <1.5, parsec >=3.1.5 && <3.2, zlib >=0.5.4.1 && <0.7, ListZipper >=1.2.0.2 && <1.3, composition >=1.0.1.0 && <1.1- cpp-options: -DCABAL- cc-options: -Wno-unused-result- c-sources:- c_libraries/glf/glf.c- extensions: CPP- includes:- glf.h- include-dirs: . Gamgine c_libraries/glf- ghc-options: -pgmPcpphs -optP--cpp-
Gamgine/Gfx.hs view
@@ -189,22 +189,22 @@ res <- loadPNGFile file either (\str -> ERROR str) (\img -> genTex img)- res+ res where genTex img = do- let (width, height) = dimensions img+ let (width, height) = dimensions img imgData = imageData img- format = hasAlphaChannel img ? GL_RGBA $ GL_RGB- id <- with 0 (\buf -> glGenTextures 1 buf >> peek buf)- glBindTexture GL_TEXTURE_2D id- glTexParameteri GL_TEXTURE_2D GL_TEXTURE_WRAP_S (fromIntegral wrapMode)- glTexParameteri GL_TEXTURE_2D GL_TEXTURE_WRAP_T (fromIntegral wrapMode)- glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER (fromIntegral GL_NEAREST)- glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER (fromIntegral GL_NEAREST)- withStorableArray imgData (\array ->- glTexImage2D GL_TEXTURE_2D 0 (fromIntegral format) (fromIntegral width)- (fromIntegral height) 0 (fromIntegral format) GL_UNSIGNED_BYTE array)- return id+ format = hasAlphaChannel img ? GL_RGBA $ GL_RGB+ id <- with 0 (\buf -> glGenTextures 1 buf >> peek buf)+ glBindTexture GL_TEXTURE_2D id+ glTexParameteri GL_TEXTURE_2D GL_TEXTURE_WRAP_S (fromIntegral wrapMode)+ glTexParameteri GL_TEXTURE_2D GL_TEXTURE_WRAP_T (fromIntegral wrapMode)+ glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MAG_FILTER (fromIntegral GL_NEAREST)+ glTexParameteri GL_TEXTURE_2D GL_TEXTURE_MIN_FILTER (fromIntegral GL_NEAREST)+ withStorableArray imgData (\array ->+ glTexImage2D GL_TEXTURE_2D 0 (fromIntegral format) (fromIntegral width)+ (fromIntegral height) 0 (fromIntegral format) GL_UNSIGNED_BYTE array)+ return id renderTexturedQuad :: (Double,Double) -> GLuint -> IO ()
Gamgine/Image/PNG.hs view
@@ -48,6 +48,7 @@ import Gamgine.Image.PNG.Internal.Filters import qualified Gamgine.Image.PNG.Internal.LBS as LBS import Gamgine.Image.PNG.Internal.LBS (LBS)+import Gamgine.Utils () -- | Type for raw PNG chunks -- The parsing happens in two phases: first the file is read into
Gamgine/Image/PNG/Internal/Parser.hs view
@@ -15,45 +15,45 @@ type Parser = Parsec LBS () -word8 :: (Stream LBS m Word8) => Word8 -> ParsecT LBS u m Word8+word8 :: (Monad m) => Word8 -> ParsecT LBS u m Word8 word8 = satisfy . (==) -word16 :: (Stream LBS m Word8) => Word16 -> ParsecT LBS u m Word16+word16 :: (Monad m) => Word16 -> ParsecT LBS u m Word16 word16 w = (word8 hi >> word8 lo >> return w) <?> "0x" ++ showHex w "" where hi = fromIntegral (w `shiftR` 8) lo = fromIntegral w -word32 :: (Stream LBS m Word8) => Word32 -> ParsecT LBS u m Word32+word32 :: (Monad m) => Word32 -> ParsecT LBS u m Word32 word32 w = (word16 hi >> word16 lo >> return w) <?> "0x" ++ showHex w "" where hi = fromIntegral (w `shiftR` 16) lo = fromIntegral w -satisfy :: (Stream LBS m Word8) => (Word8 -> Bool) -> ParsecT LBS u m Word8+satisfy :: (Monad m) => (Word8 -> Bool) -> ParsecT LBS u m Word8 satisfy f = tokenPrim (\c -> "0x" ++ showHex c "") (\pos _ _ -> pos) (\c -> if f c then Just c else Nothing) -anyWord8 :: (Stream LBS m Word8) => ParsecT LBS u m Word8+anyWord8 :: (Monad m) => ParsecT LBS u m Word8 anyWord8 = anyToken -anyWord16 :: (Stream LBS m Word8) => ParsecT LBS u m Word16+anyWord16 :: (Monad m) => ParsecT LBS u m Word16 anyWord16 = do hi <- anyWord8 lo <- anyWord8 return $ (fromIntegral hi `shiftL` 8) .|. fromIntegral lo -anyWord32 :: (Stream LBS m Word8) => ParsecT LBS u m Word32+anyWord32 :: (Monad m) => ParsecT LBS u m Word32 anyWord32 = do hi <- anyWord16 lo <- anyWord16 return $ (fromIntegral hi `shiftL` 16) .|. fromIntegral lo -string :: (Stream LBS m Word8) => LBS -> ParsecT LBS u m LBS+string :: (Monad m) => LBS -> ParsecT LBS u m LBS string s = mapM_ word8 (LBS.unpack s) >> return s -block :: (Stream LBS m Word8) => Int -> ParsecT LBS u m LBS+block :: (Monad m) => Int -> ParsecT LBS u m LBS block size = do -- count size anyWord8 >>= return . LB.pack i <- getInput let (s,r) = LBS.splitAt (fromIntegral size) i
Gamgine/Math/Matrix.hs view
@@ -53,7 +53,7 @@ mkScale :: Vect -> Matrix-mkScale v = scale (snoc v 1) identity +mkScale v = scale (snoc v 1) identity mkTranslate :: Vect -> Matrix@@ -64,11 +64,11 @@ mkWindowMatrix (width, height) = toGLFW dHeight `multmm` unitCubeToWin dWidth dHeight where unitCubeToWin :: Double -> Double -> Matrix- unitCubeToWin width height = - mkScale (v3 (width*0.5) (height*0.5) 0.5) `multmm` mkTranslate (v3 1 1 1)+ unitCubeToWin width height =+ mkScale (v3 (width*0.5) (height*0.5) 0.5) `multmm` mkTranslate (v3 1 1 1) toGLFW :: Double -> Matrix- toGLFW height = mkTranslate (v3 0 height 0) `multmm` mkScale (v3 1 (-1) 1) + toGLFW height = mkTranslate (v3 0 height 0) `multmm` mkScale (v3 1 (-1) 1) dWidth = fromIntegral width dHeight = fromIntegral height@@ -85,8 +85,8 @@ inverseOrIdentity :: Matrix -> Matrix inverseOrIdentity m = case invert m of- Nothing -> identity- Just m -> m+ Nothing -> identity+ Just m -> m winToWorld :: Matrix -> WinCoord -> Vect
Gamgine/Utils.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE FlexibleInstances #-}+ module Gamgine.Utils where #include "Gamgine/Utils.cpp" import Gamgine.Control ((?))@@ -69,3 +71,9 @@ bytesFromStorableArray n array = do bytes <- withStorableArray array (bytesFromPointer n) return bytes+++#if (MIN_VERSION_base(4,9,0))+instance MonadFail (Either String) where+ fail = Left+#endif