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