aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Spear.cabal12
-rw-r--r--Spear.lkshs10
-rw-r--r--Spear/GLSL.hs24
-rw-r--r--Spear/Render/Texture.hs34
-rw-r--r--Spear/Scene/Loader.hs5
-rw-r--r--Spear/Scene/SceneResources.hs1
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 @@
1Version of session file format: 1Version of session file format:
2 1 2 1
3Time of storage: 3Time of storage:
4 "Thu Aug 30 19:32:45 CEST 2012" 4 "Thu Aug 30 20:09:06 CEST 2012"
5Layout: 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 5Layout: 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
6Population: [(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])] 6Population: [(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])]
7Window size: (1820,939) 7Window size: (1820,939)
8Completion size: 8Completion size:
9 (750,399) 9 (750,399)
10Workspace: Just "/home/jeanne/programming/haskell/Spear/Spear.lkshw" 10Workspace: Just "/home/jeanne/programming/haskell/Spear/Spear.lkshw"
11Active pane: Just "Collision.hs" 11Active pane: Just "Modules"
12Toolbar visible: 12Toolbar visible:
13 True 13 True
14FindbarState: (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}) 14FindbarState: (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})
15Recently opened files: 15Recently 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"]
17Recently opened workspaces: 17Recently 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
84where 85where
85 86
86 87
88import Spear.Assets.Image
87import Spear.Math.Matrix3 (Matrix3) 89import Spear.Math.Matrix3 (Matrix3)
88import Spear.Math.Matrix4 (Matrix4) 90import Spear.Math.Matrix4 (Matrix4)
89import Spear.Math.Vector3 as V3 91import 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.
631loadTextureImage :: FilePath
632 -> GLenum -- ^ Texture's min filter.
633 -> GLenum -- ^ Texture's mag filter.
634 -> Setup Texture
635loadTextureImage 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.
629bindTexture :: Texture -> IO () 653bindTexture :: Texture -> IO ()
630bindTexture = glBindTexture gl_TEXTURE_2D . getTex 654bindTexture = 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 @@
1module Spear.Render.Texture
2(
3 loadTextureImage
4)
5where
6
7
8import Spear.Setup
9import Spear.Assets.Image
10import Spear.GLSL
11import Data.StateVar (($=))
12import Graphics.Rendering.OpenGL.Raw.Core31
13
14
15-- | Load the 'Texture' specified by the given file.
16loadTextureImage :: FilePath
17 -> GLenum -- ^ Texture's min filter.
18 -> GLenum -- ^ Texture's mag filter.
19 -> Setup Texture
20loadTextureImage 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
31import Spear.Render.Material 31import Spear.Render.Material
32import Spear.Render.Program 32import Spear.Render.Program
33import Spear.Render.StaticModel as SM 33import Spear.Render.StaticModel as SM
34import Spear.Render.Texture
35import Spear.Scene.GameObject as GO 34import Spear.Scene.GameObject as GO
36import Spear.Scene.Graph 35import Spear.Scene.Graph
37import Spear.Scene.Light 36import Spear.Scene.Light
@@ -227,7 +226,9 @@ rotateModel (Rotation x y z order) model =
227 226
228 227
229loadTexture :: FilePath -> Loader GLSL.Texture 228loadTexture :: FilePath -> Loader GLSL.Texture
230loadTexture file = loadResource file textures addTexture $ loadTextureImage file gl_LINEAR gl_LINEAR 229loadTexture file =
230 loadResource file textures addTexture $
231 GLSL.loadTextureImage file gl_LINEAR gl_LINEAR
231 232
232 233
233newShaderProgram :: SceneGraph -> Loader () 234newShaderProgram :: 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
21import Spear.Render.Material 21import Spear.Render.Material
22import Spear.Render.Program 22import Spear.Render.Program
23import Spear.Render.StaticModel 23import Spear.Render.StaticModel
24import Spear.Render.Texture
25import Spear.Scene.Light 24import Spear.Scene.Light
26 25
27import Data.Map as M 26import Data.Map as M