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/diena555.jpg" fname10 = "./images/reset.jpg" fname20 = "./images/line_off.jpg" fname21 = "./images/line_on.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" fname01 = "./images/black.jpg" fname40 = "./images/plus.jpg" fname41 = "./images/minus.jpg" texObj00 <- setTexObj fname00 texObj01 <- setTexObj fname01 texObj10 <- setTexObj fname10 texObj20 <- setTexObj fname20 texObj21 <- setTexObj fname21 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 texObj41 <- setTexObj fname41 tObjs $= Map.fromList [(KeyTexTiles , [texObj00 , texObj01]) , (KeyTexReset , [texObj10]) , (KeyTexLine , [texObj20 , texObj21]) , (KeyTexNum , [texObj30 , texObj31 , texObj32 , texObj33 , texObj34 , texObj35 , texObj36 , texObj37 , texObj38 , texObj39 , texObj3x ]) , (KeyTexAdd , [texObj40 , texObj41]) ] 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