some data moving
This commit is contained in:
parent
5a9fa0300e
commit
96476ac52e
3 changed files with 38 additions and 10 deletions
14
app/Main.hs
14
app/Main.hs
|
@ -54,14 +54,13 @@ loadState = do
|
|||
<$> (SubWindow <$> newTVarIO [])
|
||||
<*> (SubMouse <$> newTVarIO [])
|
||||
|
||||
rawImg <- readImage "assets/img/lynx.jpg"
|
||||
let img = case eRawImg of
|
||||
Left err -> error err
|
||||
Right dynImg -> convertRGBA8 dynImg
|
||||
spriteDetails <- loadSprites
|
||||
|
||||
return UserData
|
||||
{ udSubsystems = subs
|
||||
, udAssetSprites = M.singleton "lynx" (Sprite (V2 0 0) img)
|
||||
, udRenderAssets = RenderAssets
|
||||
{ assetSprites = spriteDetails
|
||||
}
|
||||
}
|
||||
|
||||
handle = return ()
|
||||
|
@ -69,5 +68,6 @@ handle = return ()
|
|||
updateLoop = return ()
|
||||
|
||||
drawLoop = do
|
||||
ud@(UserData subs sprites) <- getAffection
|
||||
draw
|
||||
ud@(UserData subs rassets) <- getAffection
|
||||
let (RenderAssets sDetails@(svo sso sdo)) = rassets
|
||||
mapM_ (draw svo sso) (assocs sdo)
|
||||
|
|
|
@ -68,3 +68,21 @@ initSpriteShaderObjects = do
|
|||
GL.attachShader shaderProgram fragmentShader
|
||||
|
||||
GL.linkProgram shaderProgram
|
||||
|
||||
return (SpriteShaderObjects vertexShader fragmentShader shaderProgram)
|
||||
|
||||
loadSprites :: IO (AssetDetails SpriteRenderObjects SpriteShaderObjects Sprite)
|
||||
loadSprites = do
|
||||
rawImg <- readImage "assets/img/lynx.jpg"
|
||||
let img = case eRawImg of
|
||||
Left err -> error err
|
||||
Right dynImg -> convertRGBA8 dynImg
|
||||
|
||||
vertObj <- initSpriteRenderObjects
|
||||
shadObj <- initSpriteShaderobjects
|
||||
|
||||
return AssetDetails
|
||||
{ adVertObj = vertObj
|
||||
, adShadObj = shadObj
|
||||
, adDataObj = M.singleton "lynx" (Sprite (V2 0 0) img)
|
||||
}
|
||||
|
|
|
@ -17,11 +17,21 @@ import Codec.Picture
|
|||
import Types.Sprite
|
||||
|
||||
data UserData = UserData
|
||||
{ udSubsystems :: Subsystems
|
||||
, udAssetSprites :: M.Map ImgId Sprite
|
||||
{ udSubsystems :: Subsystems
|
||||
, udRenderAssets :: RenderAssets
|
||||
}
|
||||
|
||||
type ImgId = String
|
||||
data RenderAssets = RenderAssets
|
||||
{ assetSprites :: AssetDetails SpriteRenderObjects SpriteShaderObjects Sprite
|
||||
}
|
||||
|
||||
data Renderable dat => AssetDetails vo so dat = AssetDetails
|
||||
{ adVertObj :: vo
|
||||
, adShadObj :: so
|
||||
, adDataObj :: M.Map AssetId dat
|
||||
}
|
||||
|
||||
type AssetId = String
|
||||
|
||||
data Subsystems = Subsystems
|
||||
{ subWindow :: SubWindow
|
||||
|
|
Loading…
Reference in a new issue