Separate sound and render io parameters
This commit is contained in:
+7
-4
@@ -21,6 +21,8 @@ import Picture
|
|||||||
import Picture.Render
|
import Picture.Render
|
||||||
import Picture.Preload
|
import Picture.Preload
|
||||||
|
|
||||||
|
import Preload
|
||||||
|
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
|
|
||||||
@@ -46,15 +48,16 @@ main = do
|
|||||||
setupLoop
|
setupLoop
|
||||||
"windowName"
|
"windowName"
|
||||||
800 600
|
800 600
|
||||||
doPreload'
|
doPreload
|
||||||
cleanUpPreload
|
cleanUpPreload
|
||||||
(initializeWorld $ generateFromTree lev1 $ initWorld)
|
(initializeWorld $ generateFromTree lev1 $ initWorld)
|
||||||
(-- \((bs:fs:ts:_),tes) w -> --do render setparams w egFade
|
(-- \((bs:fs:ts:_),tes) w -> --do render setparams w egFade
|
||||||
\preData w -> --do render setparams w egFade
|
\preData w -> --do render setparams w egFade
|
||||||
do
|
do
|
||||||
renderPicture' preData (_cameraRot w) (_cameraZoom w)
|
renderPicture' (_renderData preData)
|
||||||
(_cameraPos w)
|
(_cameraRot w) (_cameraZoom w)
|
||||||
(_windowX w,_windowY w)
|
(_cameraPos w)
|
||||||
|
(_windowX w,_windowY w)
|
||||||
(wallsForGloom' w)
|
(wallsForGloom' w)
|
||||||
(lightsForGloom' w)
|
(lightsForGloom' w)
|
||||||
(draw blank w)
|
(draw blank w)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import Foreign
|
|||||||
|
|
||||||
import Shaders
|
import Shaders
|
||||||
|
|
||||||
data PreloadData = PreloadData
|
data RenderData = RenderData
|
||||||
{ --_charMap :: Image PixelRGBA8
|
{ --_charMap :: Image PixelRGBA8
|
||||||
_textures :: [TextureObject]
|
_textures :: [TextureObject]
|
||||||
, _basicShader :: Program
|
, _basicShader :: Program
|
||||||
@@ -52,7 +52,7 @@ data VAO = VAO
|
|||||||
, _vaoBufferTargets :: [(BufferObject,Ptr Float,Int)]
|
, _vaoBufferTargets :: [(BufferObject,Ptr Float,Int)]
|
||||||
}
|
}
|
||||||
|
|
||||||
makeLenses ''PreloadData
|
makeLenses ''RenderData
|
||||||
makeLenses ''VAO
|
makeLenses ''VAO
|
||||||
|
|
||||||
floatSize = sizeOf (0.5 :: GLfloat)
|
floatSize = sizeOf (0.5 :: GLfloat)
|
||||||
@@ -100,8 +100,8 @@ loadTextures = do
|
|||||||
bufferOffset :: Integral a => a -> Ptr b
|
bufferOffset :: Integral a => a -> Ptr b
|
||||||
bufferOffset = plusPtr nullPtr . fromIntegral
|
bufferOffset = plusPtr nullPtr . fromIntegral
|
||||||
|
|
||||||
doPreload' :: IO PreloadData
|
preloadRender :: IO RenderData
|
||||||
doPreload' = do
|
preloadRender = do
|
||||||
-- compile shader programs
|
-- compile shader programs
|
||||||
bs <- makeBasicShader
|
bs <- makeBasicShader
|
||||||
ts <- makeTextureShader
|
ts <- makeTextureShader
|
||||||
@@ -172,7 +172,7 @@ doPreload' = do
|
|||||||
wallvao <- setupVAO [(posVBO,0,4),(colVBO,1,4)]
|
wallvao <- setupVAO [(posVBO,0,4),(colVBO,1,4)]
|
||||||
fadecircvao <- setupVAO [(posVBO,0,4)]
|
fadecircvao <- setupVAO [(posVBO,0,4)]
|
||||||
|
|
||||||
return $ PreloadData
|
return $ RenderData
|
||||||
{ -- _charMap = convertRGBA8 cmap
|
{ -- _charMap = convertRGBA8 cmap
|
||||||
_textures = [chartex,dirttex]
|
_textures = [chartex,dirttex]
|
||||||
,_basicShader = bs
|
,_basicShader = bs
|
||||||
@@ -207,8 +207,8 @@ doPreload' = do
|
|||||||
vaoPointers :: VAO -> [Ptr Float]
|
vaoPointers :: VAO -> [Ptr Float]
|
||||||
vaoPointers = (\(_,ps,_) -> ps) . unzip3 . _vaoBufferTargets
|
vaoPointers = (\(_,ps,_) -> ps) . unzip3 . _vaoBufferTargets
|
||||||
|
|
||||||
cleanUpPreload :: PreloadData -> IO ()
|
cleanUpRenderPreload :: RenderData -> IO ()
|
||||||
cleanUpPreload pd = do
|
cleanUpRenderPreload pd = do
|
||||||
mapM_ free $ vaoPointers $ _triVAO pd
|
mapM_ free $ vaoPointers $ _triVAO pd
|
||||||
mapM_ free $ vaoPointers $ _textVAO pd
|
mapM_ free $ vaoPointers $ _textVAO pd
|
||||||
mapM_ free $ vaoPointers $ _circVAO pd
|
mapM_ free $ vaoPointers $ _circVAO pd
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ threePtrsVAO :: VAO -> (Ptr Float, Ptr Float,Ptr Float)
|
|||||||
threePtrsVAO vao = case (\(_,ps,_) -> ps) $ unzip3 $ _vaoBufferTargets vao of
|
threePtrsVAO vao = case (\(_,ps,_) -> ps) $ unzip3 $ _vaoBufferTargets vao of
|
||||||
(a:b:c:_) -> (a,b,c)
|
(a:b:c:_) -> (a,b,c)
|
||||||
|
|
||||||
renderPicture' :: PreloadData -> Float -> Float -> (Float,Float) -> (Float,Float) ->
|
renderPicture' :: RenderData -> Float -> Float -> (Float,Float) -> (Float,Float) ->
|
||||||
[(Point2,Point2,Point2,Point2)] -> [Point4] -> Picture -> IO ()
|
[(Point2,Point2,Point2,Point2)] -> [Point4] -> Picture -> IO ()
|
||||||
renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints pic = do
|
renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints pic = do
|
||||||
depthFunc $= Just Lequal
|
depthFunc $= Just Lequal
|
||||||
@@ -349,7 +349,7 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints p
|
|||||||
bufferOffset :: Integral a => a -> Ptr b
|
bufferOffset :: Integral a => a -> Ptr b
|
||||||
bufferOffset = plusPtr nullPtr . fromIntegral
|
bufferOffset = plusPtr nullPtr . fromIntegral
|
||||||
|
|
||||||
renderPicture :: PreloadData -> Float -> Float -> (Float,Float) -> (Float,Float) -> Picture -> IO ()
|
renderPicture :: RenderData -> Float -> Float -> (Float,Float) -> (Float,Float) -> Picture -> IO ()
|
||||||
renderPicture pdata rot zoom (tranx,trany) (winx,winy) pic = do
|
renderPicture pdata rot zoom (tranx,trany) (winx,winy) pic = do
|
||||||
let firstIndex = 0
|
let firstIndex = 0
|
||||||
|
|
||||||
|
|||||||
@@ -4,4 +4,10 @@ import qualified SDL.Mixer as Mix
|
|||||||
|
|
||||||
import qualified Data.IntMap as IM
|
import qualified Data.IntMap as IM
|
||||||
|
|
||||||
type LoadedSounds = IM.IntMap Mix.Chunk
|
type SoundData = IM.IntMap Mix.Chunk
|
||||||
|
|
||||||
|
preloadSound :: IO SoundData
|
||||||
|
preloadSound = return IM.empty
|
||||||
|
|
||||||
|
cleanUpSoundPreload :: SoundData -> IO ()
|
||||||
|
cleanUpSoundPreload sd = return ()
|
||||||
|
|||||||
Reference in New Issue
Block a user