module Texture (textureSet) where import Graphics.Rendering.OpenGL import Graphics.UI.GLUT import Foreign import Data.Maybe import Data.Bitmap.IO import Data.Bitmap.OpenGL import Codec.Image.STB import System.Exit import Data.IORef import States import qualified Data.Map as Map ------テクスチャグループのセット textureSet :: (IORef TexObjGrp) -> IO () textureSet tObjs = do let fname00 = "./images/gboard.png" fname10 = "./images/stone_1.png" fname11 = "./images/stone_2.png" fname20 = "./images/reset.jpg" fname30 = "./images/0.gif" ; fname31 = "./images/1.gif" fname32 = "./images/2.gif" ; fname33 = "./images/3.gif" fname34 = "./images/4.gif" ; fname35 = "./images/5.gif" fname36 = "./images/6.gif" ; fname37 = "./images/7.gif" fname38 = "./images/8.gif" ; fname39 = "./images/9.gif" fname3x = "./images/batsu.gif" fname40 = "./images/oth2.png" fname50 = "./images/oth1.png" texObj00 <- setTexObj fname00 texObj10 <- setTexObj fname10 texObj11 <- setTexObj fname11 texObj20 <- setTexObj fname20 texObj30 <- setTexObj fname30 texObj31 <- setTexObj fname31 texObj32 <- setTexObj fname32 texObj33 <- setTexObj fname33 texObj34 <- setTexObj fname34 texObj35 <- setTexObj fname35 texObj36 <- setTexObj fname36 texObj37 <- setTexObj fname37 texObj38 <- setTexObj fname38 texObj39 <- setTexObj fname39 texObj3x <- setTexObj fname3x texObj40 <- setTexObj fname40 texObj50 <- setTexObj fname50 tObjs $= Map.fromList [(KeyTexStone , [texObj10 , texObj11]) , (KeyTexGameBoard , [texObj00]) , (KeyTexNum , [texObj30 , texObj31 , texObj32 , texObj33 , texObj34 , texObj35 , texObj36 , texObj37 , texObj38 , texObj39 , texObj3x ]) , (KeyButtonStart1P , [texObj40]) , (KeyButtonStart2P , [texObj50]) ] setTexObj :: FilePath -> (IO TextureObject) setTexObj fname = do teximg <- loadImage fname >>= \result -> case result of Left err -> putStrLn err >> exitFailure Right img -> return img texObj <- makeSimpleBitmapTexture teximg return texObj