diff options
Diffstat (limited to 'Render.hs')
-rw-r--r-- | Render.hs | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -3,6 +3,7 @@ module Render ( setup ) where +import Paths_htanks import Game import Level import Texture @@ -28,12 +29,13 @@ import Graphics.Rendering.OpenGL.GL.Texturing.Specification (TextureTarget(..)) import Graphics.Rendering.OpenGL.GL.VertexSpec -texturePath :: Texture -> String -texturePath t - | t == TextureWood = "tex/Wood.png" - | t == TextureTank = "tex/Tank.png" - | t == TextureCannon = "tex/Cannon.png" - | t == TextureBullet = "tex/Bullet.png" +texturePath :: Texture -> IO FilePath +texturePath t = getDataFileName $ path t + where + path TextureWood = "tex/Wood.png" + path TextureTank = "tex/Tank.png" + path TextureCannon = "tex/Cannon.png" + path TextureBullet = "tex/Bullet.png" getTexture :: Texture -> Game TextureObject getTexture t = do @@ -44,7 +46,8 @@ getTexture t = do then return $ fromJust tobj else do - tex <- liftIO $ pngBind (texturePath t) BuildMipmap Alpha (Repeated, Repeat) (Linear', Just Linear') Linear' >>= return . TextureObject . fromIntegral . fst + path <- liftIO $ texturePath t + tex <- liftIO $ pngBind path BuildMipmap Alpha (Repeated, Repeat) (Linear', Just Linear') Linear' >>= return . TextureObject . fromIntegral . fst modify $ \state -> state {textures = M.insert t tex ts} return tex |