HGamer3D-Data 0.4.0 → 0.5.0
raw patch · 12 files changed
+499/−666 lines, 12 filesdep +containersdep +stmsetup-changedPVP ok
version bump matches the API change (PVP)
Dependencies added: containers, stm
API changes (from Hackage documentation)
- HGamer3D.Util.FileLocation: createDir :: FilePath -> IO ()
- HGamer3D.Util.FileLocation: findFileInDirs :: [Char] -> [[Char]] -> IO (Maybe FilePath)
- HGamer3D.Util.FileLocation: getAppConfigDirectory :: IO [Char]
- HGamer3D.Util.FileLocation: getAppLibDirectory :: IO [Char]
- HGamer3D.Util.FileLocation: getAppMediaDirectory :: IO [Char]
- HGamer3D.Util.FileLocation: getExeConfigDirectory :: IO [Char]
- HGamer3D.Util.FileLocation: getExeLibDirectory :: IO [Char]
- HGamer3D.Util.FileLocation: getExeMediaDirectory :: IO [Char]
- HGamer3D.Util.FileLocation: osSep :: [Char]
- HGamer3D.Util.UniqueName: createUniqueName :: String -> IO UniqueName
- HGamer3D.Util.UniqueName: data UniqueName
- HGamer3D.Util.UniqueName: nextUniqueName :: UniqueName -> IO String
+ HGamer3D.Data.GameTime: sleepFor :: GameTime -> IO ()
Files
- HGamer3D-Data.cabal +33/−32
- HGamer3D/Data.hs +46/−46
- HGamer3D/Data/Angle.hs +100/−100
- HGamer3D/Data/Colour.hs +74/−74
- HGamer3D/Data/GameTime.hs +98/−92
- HGamer3D/Data/HG3DClass.hs +59/−59
- HGamer3D/Data/TypeSynonyms.hs +33/−33
- HGamer3D/Util.hs +0/−34
- HGamer3D/Util/FileLocation.hs +0/−92
- HGamer3D/Util/UniqueName.hs +0/−48
- LICENSE +34/−34
- Setup.hs +22/−22
HGamer3D-Data.cabal view
@@ -1,32 +1,33 @@-Name: HGamer3D-Data -Version: 0.4.0 -Synopsis: Game Engine for the Haskell Programmer - Data Definitions and Utilities -Description: - HGamer3D is a game engine for developing 3D games in the programming - language Haskell. HGamer3D is available on Windows and Linux. This - package provides common data definitions and utility functions for HGamer3D. - -License: OtherLicense -License-file: LICENSE -Author: Peter Althainz -Maintainer: althainz@gmail.com -Build-Type: Simple -Cabal-Version: >=1.4 -Homepage: http://www.hgamer3d.org -Category: Game Engine -Extra-source-files: Setup.hs - -Library - Build-Depends: base >= 3 && < 5, FindBin, directory, filepath, vect, clock - - Exposed-modules: HGamer3D.Data.TypeSynonyms, HGamer3D.Data.Vector,HGamer3D.Data.Colour,HGamer3D.Data.HG3DClass,HGamer3D.Data.Angle,HGamer3D.Data.GameTime,HGamer3D.Data.Transform3D,HGamer3D.Data.Geometry2D,HGamer3D.Data.Window,HGamer3D.Util.FileLocation, HGamer3D.Util.UniqueName, HGamer3D.Data, HGamer3D.Util - Other-modules: - - c-sources: - - ghc-options: - cc-options: -Wno-attributes - hs-source-dirs: . - Include-dirs: . - build-depends: - extra-libraries: +Name: HGamer3D-Data+Version: 0.5.0+Synopsis: Toolset for the Haskell Game Programmer - Data Definitions+Description: + HGamer3D is a toolset for developing 3D games in the programming + language Haskell. HGamer3D is available on Windows and Linux. This + package provides common data definitions and utility functions for HGamer3D.+ Also in this package, the Entity Component System is placed.++License: OtherLicense+License-file: LICENSE+Author: Peter Althainz+Maintainer: althainz@gmail.com+Build-Type: Simple+Cabal-Version: >=1.4+Homepage: http://www.hgamer3d.org+Category: Game Engine+Extra-source-files: Setup.hs ++Library+ Build-Depends: base >= 3 && < 5, FindBin, directory, filepath, vect, clock, stm, containers++ Exposed-modules: HGamer3D.Data.TypeSynonyms, HGamer3D.Data.Vector,HGamer3D.Data.Colour,HGamer3D.Data.HG3DClass,HGamer3D.Data.Angle,HGamer3D.Data.GameTime,HGamer3D.Data.Transform3D,HGamer3D.Data.Geometry2D,HGamer3D.Data.Window,HGamer3D.Data+ Other-modules: ++ c-sources: + + ghc-options: -O2+ cc-options: -Wno-attributes + hs-source-dirs: .+ Include-dirs: . + build-depends: + extra-libraries:
HGamer3D/Data.hs view
@@ -1,46 +1,46 @@--- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.hgamer3d.org --- --- (c) 2011 - 2013 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Data.hs --- - --- | Common data definitions for HGamer3D -module HGamer3D.Data - -( - module HGamer3D.Data.Angle, - module HGamer3D.Data.Colour, - module HGamer3D.Data.Transform3D, - module HGamer3D.Data.GameTime, - module HGamer3D.Data.Vector, - module HGamer3D.Data.Geometry2D, - module HGamer3D.Data.TypeSynonyms, - Window, -) - -where - -import HGamer3D.Data.Angle -import HGamer3D.Data.Colour -import HGamer3D.Data.Transform3D -import HGamer3D.Data.GameTime -import HGamer3D.Data.Vector -import HGamer3D.Data.Geometry2D -import HGamer3D.Data.Window -import HGamer3D.Data.TypeSynonyms - +-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+-- +-- (c) 2011 - 2013 Peter Althainz+-- +-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+-- +-- http://www.apache.org/licenses/LICENSE-2.0+-- +-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.+-- +-- Data.hs+-- ++-- | Common data definitions for HGamer3D +module HGamer3D.Data ++(+ module HGamer3D.Data.Angle,+ module HGamer3D.Data.Colour,+ module HGamer3D.Data.Transform3D,+ module HGamer3D.Data.GameTime,+ module HGamer3D.Data.Vector,+ module HGamer3D.Data.Geometry2D,+ module HGamer3D.Data.TypeSynonyms,+ Window,+)++where++import HGamer3D.Data.Angle+import HGamer3D.Data.Colour+import HGamer3D.Data.Transform3D+import HGamer3D.Data.GameTime+import HGamer3D.Data.Vector+import HGamer3D.Data.Geometry2D+import HGamer3D.Data.Window+import HGamer3D.Data.TypeSynonyms+
HGamer3D/Data/Angle.hs view
@@ -1,100 +1,100 @@--- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.hgamer3d.org --- --- (c) 2011-2013 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- Angle.hs - --- | Angles as Degrees or Radians, based on Float datatype -module HGamer3D.Data.Angle - -( - -- * Data definitions and conversions - Angle (..), - Radians (..), - Degrees (..), - fromAngle, - - -- * Mathematical functions - addA, - subA, - mulA, - divA, - sinA, - cosA, - tanA, - asinA, - acosA, - atanA, -) - -where - - -data Angle = Rad Float | Deg Float deriving (Eq, Ord, Show) - -sinA :: Angle -> Float -sinA = sin . fromAngle - -cosA :: Angle -> Float -cosA = cos . fromAngle - -tanA :: Angle -> Float -tanA = tan . fromAngle - -asinA :: Float -> Angle -asinA = Rad . asin - -acosA :: Float -> Angle -acosA = Rad . acos - -atanA :: Float -> Angle -atanA = Rad . atan - -addA :: Angle -> Angle -> Angle -addA a b = Rad $ (fromAngle a) + (fromAngle b) - -subA :: Angle -> Angle -> Angle -subA a b = Rad $ (fromAngle a) - (fromAngle b) - -mulA :: Angle -> Float -> Angle -mulA a b = Rad $ (fromAngle a) * b - -divA :: Angle -> Float -> Angle -divA a b = Rad $ (fromAngle a) / b - -data Radians = Radians Float deriving (Eq, Ord, Show) -data Degrees = Degrees Float deriving (Eq, Ord, Show) - -class Angles a where - toAngle :: a -> Angle - fromAngle :: Angle -> a - -instance Angles Float where - toAngle r = Rad r - fromAngle (Rad r) = r - fromAngle (Deg d) = d/180*pi - -instance Angles Radians where - toAngle (Radians r) = Rad r - fromAngle (Rad r) = (Radians r) - fromAngle (Deg d) = (Radians (d/180*pi)) - -instance Angles Degrees where - toAngle (Degrees d) = Deg d - fromAngle (Deg d) = (Degrees d) - fromAngle (Rad r) = (Degrees (r/pi*180)) - +-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2011-2013 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- Angle.hs++-- | Angles as Degrees or Radians, based on Float datatype+module HGamer3D.Data.Angle ++(+ -- * Data definitions and conversions+ Angle (..),+ Radians (..),+ Degrees (..),+ fromAngle,+ + -- * Mathematical functions+ addA,+ subA,+ mulA,+ divA,+ sinA,+ cosA,+ tanA,+ asinA,+ acosA,+ atanA,+)++where+++data Angle = Rad Float | Deg Float deriving (Eq, Ord, Show)++sinA :: Angle -> Float+sinA = sin . fromAngle++cosA :: Angle -> Float+cosA = cos . fromAngle++tanA :: Angle -> Float+tanA = tan . fromAngle++asinA :: Float -> Angle+asinA = Rad . asin++acosA :: Float -> Angle+acosA = Rad . acos++atanA :: Float -> Angle+atanA = Rad . atan++addA :: Angle -> Angle -> Angle+addA a b = Rad $ (fromAngle a) + (fromAngle b)++subA :: Angle -> Angle -> Angle+subA a b = Rad $ (fromAngle a) - (fromAngle b)++mulA :: Angle -> Float -> Angle+mulA a b = Rad $ (fromAngle a) * b++divA :: Angle -> Float -> Angle+divA a b = Rad $ (fromAngle a) / b++data Radians = Radians Float deriving (Eq, Ord, Show)+data Degrees = Degrees Float deriving (Eq, Ord, Show)++class Angles a where+ toAngle :: a -> Angle+ fromAngle :: Angle -> a+ +instance Angles Float where+ toAngle r = Rad r+ fromAngle (Rad r) = r+ fromAngle (Deg d) = d/180*pi+ +instance Angles Radians where+ toAngle (Radians r) = Rad r+ fromAngle (Rad r) = (Radians r)+ fromAngle (Deg d) = (Radians (d/180*pi))+ +instance Angles Degrees where+ toAngle (Degrees d) = Deg d+ fromAngle (Deg d) = (Degrees d)+ fromAngle (Rad r) = (Degrees (r/pi*180))+
HGamer3D/Data/Colour.hs view
@@ -1,74 +1,74 @@--- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.hgamer3d.org --- --- (c) 2011-2013 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- ColourValue.hs - --- | Module providing the Colour type and some standard colours -module HGamer3D.Data.Colour - -( - Colour (Colour, cRed, cGreen, cBlue, cAlpha), - white, - silver, - grey, - darkgrey, - black, - red, - maroon, - yellow, - olive, - lime, - green, - aqua, - teal, - blue, - navy, - fuchsia, - purple -) - -where - --- | HGamer3D colour type -data Colour = Colour { - cRed :: Float, -- ^ red component ranging from 0.0 to 1.0 - cGreen :: Float, -- ^ green component ranging from 0.0 to 1.0 - cBlue :: Float, -- ^ blue component ranging from 0.0 to 1.0 - cAlpha :: Float -- ^ alpha component ranging from 0.0 to 1.0 with 1.0 being fully opaque - } deriving (Eq, Show) - -white = Colour 1.0 1.0 1.0 1.0 -silver = Colour 0.75 0.75 0.75 1.0 -grey = Colour 0.5 0.5 0.5 1.0 -darkgrey = Colour 0.25 0.25 0.25 1.0 -black = Colour 0.0 0.0 0.0 1.0 -red = Colour 1.0 0.0 0.0 1.0 -maroon = Colour 0.5 0.0 0.0 1.0 -yellow = Colour 1.0 1.0 0.0 1.0 -olive = Colour 0.5 0.5 0.0 1.0 -lime = Colour 0.0 1.0 0.0 1.0 -green = Colour 0.0 0.5 0.0 1.0 -aqua = Colour 0.0 1.0 1.0 1.0 -teal = Colour 0.0 0.5 0.5 1.0 -blue = Colour 0.0 0.0 1.0 1.0 -navy = Colour 0.0 0.0 0.5 1.0 -fuchsia = Colour 1.0 0.0 1.0 1.0 -purple = Colour 0.5 0.0 0.5 1.0 - - - +-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2011-2013 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- ColourValue.hs++-- | Module providing the Colour type and some standard colours+module HGamer3D.Data.Colour ++(+ Colour (Colour, cRed, cGreen, cBlue, cAlpha),+ white,+ silver,+ grey,+ darkgrey,+ black,+ red,+ maroon,+ yellow,+ olive,+ lime,+ green,+ aqua,+ teal,+ blue,+ navy,+ fuchsia,+ purple+)++where++-- | HGamer3D colour type+data Colour = Colour {+ cRed :: Float, -- ^ red component ranging from 0.0 to 1.0+ cGreen :: Float, -- ^ green component ranging from 0.0 to 1.0+ cBlue :: Float, -- ^ blue component ranging from 0.0 to 1.0+ cAlpha :: Float -- ^ alpha component ranging from 0.0 to 1.0 with 1.0 being fully opaque+ } deriving (Eq, Show)++white = Colour 1.0 1.0 1.0 1.0 +silver = Colour 0.75 0.75 0.75 1.0+grey = Colour 0.5 0.5 0.5 1.0+darkgrey = Colour 0.25 0.25 0.25 1.0+black = Colour 0.0 0.0 0.0 1.0+red = Colour 1.0 0.0 0.0 1.0+maroon = Colour 0.5 0.0 0.0 1.0+yellow = Colour 1.0 1.0 0.0 1.0+olive = Colour 0.5 0.5 0.0 1.0+lime = Colour 0.0 1.0 0.0 1.0+green = Colour 0.0 0.5 0.0 1.0+aqua = Colour 0.0 1.0 1.0 1.0+teal = Colour 0.0 0.5 0.5 1.0+blue = Colour 0.0 0.0 1.0 1.0 +navy = Colour 0.0 0.0 0.5 1.0+fuchsia = Colour 1.0 0.0 1.0 1.0+purple = Colour 0.5 0.0 0.5 1.0+++
HGamer3D/Data/GameTime.hs view
@@ -1,92 +1,98 @@-{-# LANGUAGE TypeSynonymInstances #-} --- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.hgamer3d.org --- --- (c) 2011-2013 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- TimeMS.hs - --- | Module providing the time type for HGamer3D -module HGamer3D.Data.GameTime - -( - GameTime, - sec, - msec, - usec, - - secT, - msecT, - usecT, - - getTime, - getThreadCPUTime, - getProcessCPUTime -) - -where - -import qualified System.Clock as C - -type GameTime = C.TimeSpec - -_toInteger :: C.TimeSpec -> Integer -_toInteger ts = let - s = (fromIntegral (C.sec ts)) :: Integer - ns = (fromIntegral (C.nsec ts)) :: Integer - in s * 1000000000 + ns - -_fromInteger :: Integer -> C.TimeSpec -_fromInteger i = let - s = fromIntegral (i `quot` 1000000000) - ns = fromIntegral (i `rem` 1000000000) - in C.TimeSpec s ns - -instance Num GameTime where - (+) a b = _fromInteger((_toInteger a) Prelude.+ (_toInteger b) ) - (-) a b = _fromInteger((_toInteger a) Prelude.- (_toInteger b) ) - (*) a b = _fromInteger((_toInteger a) Prelude.* (_toInteger b) ) - abs a = _fromInteger( Prelude.abs (_toInteger a)) - signum a = _fromInteger( Prelude.signum (_toInteger a)) - fromInteger i = _fromInteger i - -sec :: C.TimeSpec -> Int -sec ts = fromIntegral ((_toInteger ts) `quot` 1000000000) - -msec :: C.TimeSpec -> Int -msec ts = fromIntegral ((_toInteger ts) `quot` 1000000) - -usec :: C.TimeSpec -> Int -usec ts = fromIntegral ((_toInteger ts) `quot` 1000) - -secT :: Int -> C.TimeSpec -secT i = _fromInteger ((fromIntegral i) * 1000000000) - -msecT :: Int -> C.TimeSpec -msecT i = _fromInteger ((fromIntegral i) * 1000000) - -usecT :: Int -> C.TimeSpec -usecT i = _fromInteger ((fromIntegral i) * 1000) - -getTime :: IO GameTime -getTime = C.getTime C.Realtime - -getThreadCPUTime :: IO GameTime -getThreadCPUTime = C.getTime C.ThreadCPUTime - -getProcessCPUTime :: IO GameTime -getProcessCPUTime = C.getTime C.ProcessCPUTime - +{-# LANGUAGE TypeSynonymInstances #-}+-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2011-2013 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- TimeMS.hs++-- | Module providing the time type for HGamer3D+module HGamer3D.Data.GameTime++(+ GameTime,+ sec,+ msec,+ usec,+ + secT,+ msecT,+ usecT,+ + getTime,+ getThreadCPUTime,+ getProcessCPUTime,++ sleepFor+)++where++import Control.Concurrent+import qualified System.Clock as C++type GameTime = C.TimeSpec++_toInteger :: C.TimeSpec -> Integer+_toInteger ts = let+ s = (fromIntegral (C.sec ts)) :: Integer+ ns = (fromIntegral (C.nsec ts)) :: Integer+ in s * 1000000000 + ns++_fromInteger :: Integer -> C.TimeSpec+_fromInteger i = let+ s = fromIntegral (i `quot` 1000000000)+ ns = fromIntegral (i `rem` 1000000000)+ in C.TimeSpec s ns++instance Num GameTime where+ (+) a b = _fromInteger((_toInteger a) Prelude.+ (_toInteger b) )+ (-) a b = _fromInteger((_toInteger a) Prelude.- (_toInteger b) )+ (*) a b = _fromInteger((_toInteger a) Prelude.* (_toInteger b) )+ abs a = _fromInteger( Prelude.abs (_toInteger a))+ signum a = _fromInteger( Prelude.signum (_toInteger a))+ fromInteger i = _fromInteger i++sec :: C.TimeSpec -> Int+sec ts = fromIntegral ((_toInteger ts) `quot` 1000000000)++msec :: C.TimeSpec -> Int+msec ts = fromIntegral ((_toInteger ts) `quot` 1000000)++usec :: C.TimeSpec -> Int+usec ts = fromIntegral ((_toInteger ts) `quot` 1000)++secT :: Int -> C.TimeSpec+secT i = _fromInteger ((fromIntegral i) * 1000000000)++msecT :: Int -> C.TimeSpec+msecT i = _fromInteger ((fromIntegral i) * 1000000)++usecT :: Int -> C.TimeSpec+usecT i = _fromInteger ((fromIntegral i) * 1000)++getTime :: IO GameTime+getTime = C.getTime C.Realtime++getThreadCPUTime :: IO GameTime+getThreadCPUTime = C.getTime C.ThreadCPUTime++getProcessCPUTime :: IO GameTime+getProcessCPUTime = C.getTime C.ProcessCPUTime++sleepFor :: GameTime -> IO ()+sleepFor gt = threadDelay (usec gt)+
HGamer3D/Data/HG3DClass.hs view
@@ -1,59 +1,59 @@-{-# LANGUAGE ForeignFunctionInterface #-} -{-# LANGUAGE TypeSynonymInstances #-} - --- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.hgamer3d.org --- --- (c) 2011-2013 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- HG3DClass.hs --- - --- | Utility class to encapsulate class pointers -module HGamer3D.Data.HG3DClass where - --- import C2HS -import Foreign -import Foreign.Ptr -import Foreign.C -import Foreign.Storable - - -import Data.Bits - -data HG3DClass = HG3DClass { - ocPtr :: Ptr (), - ocFptr :: Ptr () - } deriving (Eq, Show) - -instance Storable HG3DClass where - alignment _ = alignment (undefined :: CDouble) - sizeOf _ = 2 * (sizeOf nullPtr) - - peek p = do - ptr <- (\ptr -> do {peekByteOff ptr 0 ::IO (Ptr ())}) p - fptr <- (\ptr -> do {peekByteOff ptr (sizeOf nullPtr) ::IO (Ptr ())}) p - let hc = HG3DClass (ptr) (fptr) - return hc - - poke p (HG3DClass ptr fptr) = do - (\ptr val -> do {pokeByteOff ptr 0 (val::(Ptr ()))}) p (ptr) - (\ptr val -> do {pokeByteOff ptr (sizeOf nullPtr) (val::(Ptr ()))}) p (fptr) - - - - - +{-# LANGUAGE ForeignFunctionInterface #-}+{-# LANGUAGE TypeSynonymInstances #-}++-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+-- +-- (c) 2011-2013 Peter Althainz+-- +-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+-- +-- http://www.apache.org/licenses/LICENSE-2.0+-- +-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.+-- +-- HG3DClass.hs+-- ++-- | Utility class to encapsulate class pointers+module HGamer3D.Data.HG3DClass where++-- import C2HS+import Foreign+import Foreign.Ptr+import Foreign.C+import Foreign.Storable+++import Data.Bits++data HG3DClass = HG3DClass {+ ocPtr :: Ptr (),+ ocFptr :: Ptr ()+ } deriving (Eq, Show)++instance Storable HG3DClass where+ alignment _ = alignment (undefined :: CDouble)+ sizeOf _ = 2 * (sizeOf nullPtr)+ + peek p = do+ ptr <- (\ptr -> do {peekByteOff ptr 0 ::IO (Ptr ())}) p+ fptr <- (\ptr -> do {peekByteOff ptr (sizeOf nullPtr) ::IO (Ptr ())}) p+ let hc = HG3DClass (ptr) (fptr)+ return hc+ + poke p (HG3DClass ptr fptr) = do+ (\ptr val -> do {pokeByteOff ptr 0 (val::(Ptr ()))}) p (ptr)+ (\ptr val -> do {pokeByteOff ptr (sizeOf nullPtr) (val::(Ptr ()))}) p (fptr)+ ++++
HGamer3D/Data/TypeSynonyms.hs view
@@ -1,33 +1,33 @@--- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.hgamer3d.org --- --- (c) 2011-2014 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- HGamer3D/Data/TypeSynonyms.hs - --- | Module providing better type names for standard types in HGamer3D -module HGamer3D.Data.TypeSynonyms - -where - -import HGamer3D.Data.Vector - --- | the Size, Position and Orientation types, implemented as a Vec3 and UnitQuaternion -type Size = Vec3 -type Position = Vec3 -type Orientation = UnitQuaternion - - +-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2011-2014 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- HGamer3D/Data/TypeSynonyms.hs++-- | Module providing better type names for standard types in HGamer3D+module HGamer3D.Data.TypeSynonyms++where++import HGamer3D.Data.Vector+ +-- | the Size, Position and Orientation types, implemented as a Vec3 and UnitQuaternion+type Size = Vec3+type Position = Vec3+type Orientation = UnitQuaternion++
− HGamer3D/Util.hs
@@ -1,34 +0,0 @@--- This source file is part of HGamer3D--- (A project to enable 3D game development in Haskell)--- For the latest info, see http://www.hgamer3d.org--- --- (c) 2011 - 2013 Peter Althainz--- --- Licensed under the Apache License, Version 2.0 (the "License");--- you may not use this file except in compliance with the License.--- You may obtain a copy of the License at--- --- http://www.apache.org/licenses/LICENSE-2.0--- --- Unless required by applicable law or agreed to in writing, software--- distributed under the License is distributed on an "AS IS" BASIS,--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.--- See the License for the specific language governing permissions and--- limitations under the License.--- --- Util.hs--- ---- | Common utilities for HGamer3D-module HGamer3D.Util--(- module HGamer3D.Util.FileLocation,- module HGamer3D.Util.UniqueName-)--where--import HGamer3D.Util.FileLocation-import HGamer3D.Util.UniqueName-
− HGamer3D/Util/FileLocation.hs
@@ -1,92 +0,0 @@--- This source file is part of HGamer3D--- (A project to enable 3D game development in Haskell)--- For the latest info, see http://www.hgamer3d.org------ (c) 2011-2013 Peter Althainz------ Licensed under the Apache License, Version 2.0 (the "License");--- you may not use this file except in compliance with the License.--- You may obtain a copy of the License at------ http://www.apache.org/licenses/LICENSE-2.0------ Unless required by applicable law or agreed to in writing, software--- distributed under the License is distributed on an "AS IS" BASIS,--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.--- See the License for the specific language governing permissions and--- limitations under the License.---- Util.hs---- | Utility to provide file location information to other parts of HGamer3D-module HGamer3D.Util.FileLocation--(- - -- * Directories relative to the user-related application directory for HGamer3D- getAppMediaDirectory,- getAppConfigDirectory,- getAppLibDirectory,- - -- * Directories relative to the executable (prog path)- getExeMediaDirectory,- getExeConfigDirectory,- getExeLibDirectory,- - -- * General utilities for path handling and finding files- osSep,- createDir,- findFileInDirs-)--where--import Control.Monad-import Control.Exception-import System.Directory-import System.FilePath-import System.Environment.FindBin--_getHG3DDirectory subdir = do- appdir <- getAppUserDataDirectory "HGamer3D" - let ndir = appdir ++ [pathSeparator] ++ subdir- createDirectoryIfMissing True ndir- return ndir- --- | path of media, relative to user app dir for HGamer3D-getAppMediaDirectory = _getHG3DDirectory "media"---- | path of configuration, relative to user app dir for HGamer3D-getAppConfigDirectory = _getHG3DDirectory "config"---- | path of libraries, relative to user app dir for HGamer3D-getAppLibDirectory = _getHG3DDirectory "lib"- -_getBinDir subdir = do- bdir <- try getProgPath :: IO (Either SomeException FilePath)- let bdir' = case bdir of- Left _ -> "."- Right path -> path- let ndir = bdir' ++ [pathSeparator] ++ ".HGamer3D" ++ [pathSeparator] ++ subdir- return ndir---- | path of media, relative to executable-getExeMediaDirectory = _getBinDir "media"---- | path of configuration, relative to executable-getExeConfigDirectory = _getBinDir "config"---- | path of libraries, relative to executable-getExeLibDirectory = _getBinDir "lib"---- | path separator for the filesystem-osSep = [pathSeparator]---- | create a directory-createDir dir = createDirectoryIfMissing True dir---- | find a file by searching in multiple directories-findFileInDirs filename listOfDirs = do- let files = fmap (\d -> d ++ [pathSeparator] ++ filename) listOfDirs- res <- filterM doesFileExist files- if length res > 0 then return $ Just (res !! 0) else return Nothing
− HGamer3D/Util/UniqueName.hs
@@ -1,48 +0,0 @@--- This source file is part of HGamer3D--- (A project to enable 3D game development in Haskell)--- For the latest info, see http://www.hgamer3d.org------ (c) 2011-2013 Peter Althainz------ Licensed under the Apache License, Version 2.0 (the "License");--- you may not use this file except in compliance with the License.--- You may obtain a copy of the License at------ http://www.apache.org/licenses/LICENSE-2.0------ Unless required by applicable law or agreed to in writing, software--- distributed under the License is distributed on an "AS IS" BASIS,--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.--- See the License for the specific language governing permissions and--- limitations under the License.---- UniqueName.hs---- | Utility to provide a unique name, carries internal state in a IORef-module HGamer3D.Util.UniqueName-(- - UniqueName,- createUniqueName,- nextUniqueName- -) where--import Data.IORef--data UniqueName = UniqueName String (IORef [Int])---- | creates a unique name holder-createUniqueName :: String -> IO UniqueName-createUniqueName baseName = do- ref <- newIORef [0..]- return $ UniqueName baseName ref- --- | delivers the next unique name from the name holder-nextUniqueName :: UniqueName -> IO String-nextUniqueName (UniqueName baseName ref) = do- name <- atomicModifyIORef ref (\ilist -> (tail ilist, baseName ++ (show (head ilist))))- return name- - -
LICENSE view
@@ -1,34 +1,34 @@-LICENSE -------- - -(c) 2011-2014 Peter Althainz - - -HGamer3D (http://www.hgamer3d.org) ----------------------------------- - -HGamer3D is licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - - -Source Code ------------ -You can obtain the latest version of the source code under http://www.bitbucket.org/althainz/HGamer3D - - -Open Source Software Used - Module HGamer3D.Data ------------------------------------------------- - -HGamer3D uses a number of open source software libraries. You are responsible to comply to the licenses of those packages and the licenses of software used by those packages if you use HGamer3D. - -The HGamer3D.Data module uses the following Haskell libraries from Hackage: - -base, license: BSD3 -FindBin, license: BSD3 -directory, license: BSD3 -filepath, license: BSD3 -vect, license: license: BSD3 - +LICENSE+-------++(c) 2011-2014 Peter Althainz+++HGamer3D (http://www.hgamer3d.org)+----------------------------------++HGamer3D is licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0+ +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.+++Source Code+-----------+You can obtain the latest version of the source code under http://www.bitbucket.org/althainz/HGamer3D+++Open Source Software Used - Module HGamer3D.Data+------------------------------------------------++HGamer3D uses a number of open source software libraries. You are responsible to comply to the licenses of those packages and the licenses of software used by those packages if you use HGamer3D. ++The HGamer3D.Data module uses the following Haskell libraries from Hackage:++base, license: BSD3+FindBin, license: BSD3+directory, license: BSD3+filepath, license: BSD3+vect, license: license: BSD3+
Setup.hs view
@@ -1,22 +1,22 @@--- This source file is part of HGamer3D --- (A project to enable 3D game development in Haskell) --- For the latest info, see http://www.hgamer3d.org --- --- (c) 2011-2013 Peter Althainz --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- Setup.hs - -import Distribution.Simple -main = defaultMain +-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2011-2013 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- Setup.hs++import Distribution.Simple+main = defaultMain