diff options
-rw-r--r-- | Spear.cabal | 12 | ||||
-rw-r--r-- | Spear.lkshs | 10 | ||||
-rw-r--r-- | Spear/GLSL.hs | 24 | ||||
-rw-r--r-- | Spear/Render/Texture.hs | 34 | ||||
-rw-r--r-- | Spear/Scene/Loader.hs | 5 | ||||
-rw-r--r-- | Spear/Scene/SceneResources.hs | 1 |
6 files changed, 38 insertions, 48 deletions
diff --git a/Spear.cabal b/Spear.cabal index a893ce3..ceb4ea7 100644 --- a/Spear.cabal +++ b/Spear.cabal | |||
@@ -25,12 +25,12 @@ library | |||
25 | Spear.Math.Quaternion Spear.Math.Vector3 Spear.Math.Vector4 | 25 | Spear.Math.Quaternion Spear.Math.Vector3 Spear.Math.Vector4 |
26 | Spear.Physics Spear.Physics.Rigid Spear.Render.AnimatedModel | 26 | Spear.Physics Spear.Physics.Rigid Spear.Render.AnimatedModel |
27 | Spear.Render.Material Spear.Render.Model Spear.Render.Program | 27 | Spear.Render.Material Spear.Render.Model Spear.Render.Program |
28 | Spear.Render.StaticModel Spear.Render.Texture Spear.Scene.Graph | 28 | Spear.Render.StaticModel Spear.Scene.Graph Spear.Scene.Light |
29 | Spear.Scene.Light Spear.Scene.Loader Spear.Scene.Scene | 29 | Spear.Scene.Loader Spear.Scene.Scene Spear.Scene.SceneResources |
30 | Spear.Scene.SceneResources Spear.Setup Spear.Sys.Timer | 30 | Spear.Setup Spear.Sys.Timer Spear.Sys.Store Spear.Sys.Store.ID |
31 | Spear.Sys.Store Spear.Sys.Store.ID Spear.Math.Vector2 | 31 | Spear.Math.Vector2 Spear.Math.Quad Spear.Math.Ray |
32 | Spear.Math.Quad Spear.Math.Ray Spear.Math.Segment Spear.Math.Utils | 32 | Spear.Math.Segment Spear.Math.Utils Spear.Math.Spatial2 |
33 | Spear.Math.Spatial2 Spear.Math.Spatial3 | 33 | Spear.Math.Spatial3 |
34 | exposed: True | 34 | exposed: True |
35 | buildable: True | 35 | buildable: True |
36 | build-tools: hsc2hs -any | 36 | build-tools: hsc2hs -any |
diff --git a/Spear.lkshs b/Spear.lkshs index 1f6f16e..ee993af 100644 --- a/Spear.lkshs +++ b/Spear.lkshs | |||
@@ -1,18 +1,18 @@ | |||
1 | Version of session file format: | 1 | Version of session file format: |
2 | 1 | 2 | 1 |
3 | Time of storage: | 3 | Time of storage: |
4 | "Thu Aug 30 19:32:45 CEST 2012" | 4 | "Thu Aug 30 20:09:06 CEST 2012" |
5 | Layout: VerticalP (TerminalP {paneGroups = fromList [], paneTabs = Just TopP, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (HorizontalP (TerminalP {paneGroups = fromList [("Browser",HorizontalP (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (HorizontalP (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) 353) 140)], paneTabs = Just BottomP, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) 653) 954 | 5 | Layout: VerticalP (TerminalP {paneGroups = fromList [], paneTabs = Just TopP, currentPage = 3, detachedId = Nothing, detachedSize = Nothing}) (HorizontalP (TerminalP {paneGroups = fromList [("Browser",HorizontalP (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (HorizontalP (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) 367) 146)], paneTabs = Just BottomP, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) (TerminalP {paneGroups = fromList [], paneTabs = Nothing, currentPage = 0, detachedId = Nothing, detachedSize = Nothing}) 678) 954 |
6 | Population: [(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/Collision.hs" 3278)),[SplitP LeftP]),(Just (ErrorsSt ErrorsState),[SplitP RightP,SplitP TopP]),(Just (FilesSt FilesState),[SplitP RightP,SplitP TopP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/Scene/GameObject.hs" 402)),[SplitP LeftP]),(Just (InfoSt (InfoState Nothing)),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP BottomP,SplitP BottomP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/Scene/Loader.hs" 296)),[SplitP LeftP]),(Just (LogSt LogState),[SplitP RightP,SplitP BottomP]),(Just (ModulesSt (ModulesState 328 (PackageScope False,False) (Nothing,Nothing) (ExpanderState {packageExp = ([],[]), packageExpNoBlack = ([[0]],[]), packageDExp = ([],[]), packageDExpNoBlack = ([],[]), workspaceExp = ([],[]), workspaceExpNoBlack = ([],[]), workspaceDExp = ([],[]), workspaceDExpNoBlack = ([],[]), systemExp = ([],[]), systemExpNoBlack = ([],[])}))),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP BottomP,SplitP TopP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/Render/Program.hs" 248)),[SplitP LeftP]),(Just (WorkspaceSt WorkspaceState),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP TopP])] | 6 | Population: [(Just (ErrorsSt ErrorsState),[SplitP RightP,SplitP TopP]),(Just (FilesSt FilesState),[SplitP RightP,SplitP TopP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/GLSL.hs" 1193)),[SplitP LeftP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/Scene/GameObject.hs" 96)),[SplitP LeftP]),(Just (InfoSt (InfoState Nothing)),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP BottomP,SplitP BottomP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/Scene/Loader.hs" 296)),[SplitP LeftP]),(Just (LogSt LogState),[SplitP RightP,SplitP BottomP]),(Just (ModulesSt (ModulesState 328 (PackageScope False,False) (Just (ModuleName ["Spear","Render","Texture"]),Nothing) (ExpanderState {packageExp = ([],[]), packageExpNoBlack = ([[0,6],[0]],[]), packageDExp = ([],[]), packageDExpNoBlack = ([],[]), workspaceExp = ([],[]), workspaceExpNoBlack = ([],[]), workspaceDExp = ([],[]), workspaceDExpNoBlack = ([],[]), systemExp = ([],[]), systemExpNoBlack = ([],[])}))),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP BottomP,SplitP TopP]),(Just (BufferSt (BufferState "/home/jeanne/programming/haskell/Spear/Spear/Render/Program.hs" 52)),[SplitP LeftP]),(Just (WorkspaceSt WorkspaceState),[SplitP RightP,SplitP TopP,GroupP "Browser",SplitP TopP])] |
7 | Window size: (1820,939) | 7 | Window size: (1820,939) |
8 | Completion size: | 8 | Completion size: |
9 | (750,399) | 9 | (750,399) |
10 | Workspace: Just "/home/jeanne/programming/haskell/Spear/Spear.lkshw" | 10 | Workspace: Just "/home/jeanne/programming/haskell/Spear/Spear.lkshw" |
11 | Active pane: Just "Collision.hs" | 11 | Active pane: Just "Modules" |
12 | Toolbar visible: | 12 | Toolbar visible: |
13 | True | 13 | True |
14 | FindbarState: (False,FindState {entryStr = "", entryHist = ["VAO","'VAO'","\170","\\","^","scale","Vector4.","asdad","translv","Vector3.","Vector.","copy_tr"], replaceStr = "V3.", replaceHist = [], caseSensitive = True, entireWord = False, wrapAround = False, regex = False, lineNr = 1}) | 14 | FindbarState: (False,FindState {entryStr = "", entryHist = ["VAO","'VAO'","\170","\\","^","scale","Vector4.","asdad","translv","Vector3.","Vector.","copy_tr"], replaceStr = "V3.", replaceHist = [], caseSensitive = True, entireWord = False, wrapAround = False, regex = False, lineNr = 1}) |
15 | Recently opened files: | 15 | Recently opened files: |
16 | ["/home/jeanne/programming/haskell/Spear/Spear/Math/QuadTree.hs","/home/jeanne/programming/haskell/Spear/Spear/Scene/Scene.hs","/home/jeanne/programming/haskell/Spear/Spear/Collision/Types.hs","/home/jeanne/programming/haskell/Spear/Spear/Collision/Collisioner.hs","/home/jeanne/programming/haskell/Spear/Spear/Collision/Collision.hs","/home/jeanne/programming/haskell/Spear/Spear/Updatable.hs","/home/jeanne/programming/haskell/Spear/demos/simple-scene/main.hs","/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/Utils.hs","/home/jeanne/programming/haskell/Spear/Spear/Render/Texture.hs","/home/jeanne/programming/haskell/Spear/demos/simple-scene/Game/GameObject/Player.hs","/home/jeanne/programming/haskell/Spear/Spear/GLSL.hs","/home/jeanne/programming/haskell/Spear/Spear/GLSL/VAO.hs"] | 16 | ["/home/jeanne/programming/haskell/Spear/Spear/Render/Texture.hs","/home/jeanne/programming/haskell/Spear/Spear/Render/AnimatedModel.hs","/home/jeanne/programming/haskell/Spear/Spear/Render/StaticModel.hs","/home/jeanne/programming/haskell/Spear/Spear/Render/Program.hs","/home/jeanne/programming/haskell/Spear/Spear/Collision.hs","/home/jeanne/programming/haskell/Spear/Spear/Math/QuadTree.hs","/home/jeanne/programming/haskell/Spear/Spear/Scene/Scene.hs","/home/jeanne/programming/haskell/Spear/Spear/Collision/Types.hs","/home/jeanne/programming/haskell/Spear/Spear/Collision/Collisioner.hs","/home/jeanne/programming/haskell/Spear/Spear/Collision/Collision.hs","/home/jeanne/programming/haskell/Spear/Spear/Updatable.hs","/home/jeanne/programming/haskell/Spear/demos/simple-scene/main.hs"] |
17 | Recently opened workspaces: | 17 | Recently opened workspaces: |
18 | ["/home/jeanne/programming/haskell/hagen/hagen.lkshw","/home/jeanne/programming/haskell/foo/foo.lkshw","/home/jeanne/programming/haskell/Spear/Spear.lkshw","/home/jeanne/programming/haskell/nexus/nexus.lkshw","/home/jeanne/leksah.lkshw"] \ No newline at end of file | 18 | ["/home/jeanne/programming/haskell/hagen/hagen.lkshw","/home/jeanne/programming/haskell/foo/foo.lkshw","/home/jeanne/programming/haskell/Spear/Spear.lkshw","/home/jeanne/programming/haskell/nexus/nexus.lkshw","/home/jeanne/leksah.lkshw"] \ No newline at end of file |
diff --git a/Spear/GLSL.hs b/Spear/GLSL.hs index e0e1661..1d4d287 100644 --- a/Spear/GLSL.hs +++ b/Spear/GLSL.hs | |||
@@ -68,6 +68,7 @@ module Spear.GLSL | |||
68 | , ($) | 68 | , ($) |
69 | -- ** Creation and destruction | 69 | -- ** Creation and destruction |
70 | , newTexture | 70 | , newTexture |
71 | , loadTextureImage | ||
71 | , releaseTexture | 72 | , releaseTexture |
72 | -- ** Manipulation | 73 | -- ** Manipulation |
73 | , bindTexture | 74 | , bindTexture |
@@ -84,6 +85,7 @@ module Spear.GLSL | |||
84 | where | 85 | where |
85 | 86 | ||
86 | 87 | ||
88 | import Spear.Assets.Image | ||
87 | import Spear.Math.Matrix3 (Matrix3) | 89 | import Spear.Math.Matrix3 (Matrix3) |
88 | import Spear.Math.Matrix4 (Matrix4) | 90 | import Spear.Math.Matrix4 (Matrix4) |
89 | import Spear.Math.Vector3 as V3 | 91 | import Spear.Math.Vector3 as V3 |
@@ -625,6 +627,28 @@ deleteTexture tex = do | |||
625 | with tex $ glDeleteTextures 1 | 627 | with tex $ glDeleteTextures 1 |
626 | 628 | ||
627 | 629 | ||
630 | -- | Load the 'Texture' specified by the given file. | ||
631 | loadTextureImage :: FilePath | ||
632 | -> GLenum -- ^ Texture's min filter. | ||
633 | -> GLenum -- ^ Texture's mag filter. | ||
634 | -> Setup Texture | ||
635 | loadTextureImage file minFilter magFilter = do | ||
636 | image <- loadImage file | ||
637 | tex <- newTexture | ||
638 | setupIO $ do | ||
639 | let w = width image | ||
640 | h = height image | ||
641 | pix = pixels image | ||
642 | rgb = fromIntegral . fromEnum $ gl_RGB | ||
643 | |||
644 | bindTexture tex | ||
645 | loadTextureData gl_TEXTURE_2D 0 rgb w h 0 gl_RGB gl_UNSIGNED_BYTE pix | ||
646 | texParami gl_TEXTURE_2D gl_TEXTURE_MIN_FILTER $= minFilter | ||
647 | texParami gl_TEXTURE_2D gl_TEXTURE_MAG_FILTER $= magFilter | ||
648 | |||
649 | return tex | ||
650 | |||
651 | |||
628 | -- | Bind the texture. | 652 | -- | Bind the texture. |
629 | bindTexture :: Texture -> IO () | 653 | bindTexture :: Texture -> IO () |
630 | bindTexture = glBindTexture gl_TEXTURE_2D . getTex | 654 | bindTexture = glBindTexture gl_TEXTURE_2D . getTex |
diff --git a/Spear/Render/Texture.hs b/Spear/Render/Texture.hs deleted file mode 100644 index 3311ce6..0000000 --- a/Spear/Render/Texture.hs +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | module Spear.Render.Texture | ||
2 | ( | ||
3 | loadTextureImage | ||
4 | ) | ||
5 | where | ||
6 | |||
7 | |||
8 | import Spear.Setup | ||
9 | import Spear.Assets.Image | ||
10 | import Spear.GLSL | ||
11 | import Data.StateVar (($=)) | ||
12 | import Graphics.Rendering.OpenGL.Raw.Core31 | ||
13 | |||
14 | |||
15 | -- | Load the 'Texture' specified by the given file. | ||
16 | loadTextureImage :: FilePath | ||
17 | -> GLenum -- ^ Texture's min filter. | ||
18 | -> GLenum -- ^ Texture's mag filter. | ||
19 | -> Setup Texture | ||
20 | loadTextureImage file minFilter magFilter = do | ||
21 | image <- loadImage file | ||
22 | tex <- newTexture | ||
23 | setupIO $ do | ||
24 | let w = width image | ||
25 | h = height image | ||
26 | pix = pixels image | ||
27 | rgb = fromIntegral . fromEnum $ gl_RGB | ||
28 | |||
29 | bindTexture tex | ||
30 | loadTextureData gl_TEXTURE_2D 0 rgb w h 0 gl_RGB gl_UNSIGNED_BYTE pix | ||
31 | texParami gl_TEXTURE_2D gl_TEXTURE_MIN_FILTER $= minFilter | ||
32 | texParami gl_TEXTURE_2D gl_TEXTURE_MAG_FILTER $= magFilter | ||
33 | |||
34 | return tex | ||
diff --git a/Spear/Scene/Loader.hs b/Spear/Scene/Loader.hs index 820ad51..0ef5333 100644 --- a/Spear/Scene/Loader.hs +++ b/Spear/Scene/Loader.hs | |||
@@ -31,7 +31,6 @@ import Spear.Render.AnimatedModel as AM | |||
31 | import Spear.Render.Material | 31 | import Spear.Render.Material |
32 | import Spear.Render.Program | 32 | import Spear.Render.Program |
33 | import Spear.Render.StaticModel as SM | 33 | import Spear.Render.StaticModel as SM |
34 | import Spear.Render.Texture | ||
35 | import Spear.Scene.GameObject as GO | 34 | import Spear.Scene.GameObject as GO |
36 | import Spear.Scene.Graph | 35 | import Spear.Scene.Graph |
37 | import Spear.Scene.Light | 36 | import Spear.Scene.Light |
@@ -227,7 +226,9 @@ rotateModel (Rotation x y z order) model = | |||
227 | 226 | ||
228 | 227 | ||
229 | loadTexture :: FilePath -> Loader GLSL.Texture | 228 | loadTexture :: FilePath -> Loader GLSL.Texture |
230 | loadTexture file = loadResource file textures addTexture $ loadTextureImage file gl_LINEAR gl_LINEAR | 229 | loadTexture file = |
230 | loadResource file textures addTexture $ | ||
231 | GLSL.loadTextureImage file gl_LINEAR gl_LINEAR | ||
231 | 232 | ||
232 | 233 | ||
233 | newShaderProgram :: SceneGraph -> Loader () | 234 | newShaderProgram :: SceneGraph -> Loader () |
diff --git a/Spear/Scene/SceneResources.hs b/Spear/Scene/SceneResources.hs index e54f385..037e3aa 100644 --- a/Spear/Scene/SceneResources.hs +++ b/Spear/Scene/SceneResources.hs | |||
@@ -21,7 +21,6 @@ import Spear.Render.AnimatedModel | |||
21 | import Spear.Render.Material | 21 | import Spear.Render.Material |
22 | import Spear.Render.Program | 22 | import Spear.Render.Program |
23 | import Spear.Render.StaticModel | 23 | import Spear.Render.StaticModel |
24 | import Spear.Render.Texture | ||
25 | import Spear.Scene.Light | 24 | import Spear.Scene.Light |
26 | 25 | ||
27 | import Data.Map as M | 26 | import Data.Map as M |