diff --git a/data/music/ct1000ad.mid b/data/music/ct1000ad.mid new file mode 100644 index 000000000..fdbedfd07 Binary files /dev/null and b/data/music/ct1000ad.mid differ diff --git a/data/music/ctundsea.mid b/data/music/ctundsea.mid new file mode 100644 index 000000000..68460ce35 Binary files /dev/null and b/data/music/ctundsea.mid differ diff --git a/data/music/jupiter.mid b/data/music/jupiter.mid new file mode 100644 index 000000000..0959e183c Binary files /dev/null and b/data/music/jupiter.mid differ diff --git a/data/texture/ayene_wooden_floor_transformed.png b/data/texture/ayene_wooden_floor_transformed.png new file mode 100644 index 000000000..2d918d980 Binary files /dev/null and b/data/texture/ayene_wooden_floor_transformed.png differ diff --git a/data/texture/ayene_wooden_floora.png b/data/texture/ayene_wooden_floora.png new file mode 100644 index 000000000..5ac0ed583 Binary files /dev/null and b/data/texture/ayene_wooden_floora.png differ diff --git a/data/texture/grayscaleDirta.png b/data/texture/grayscaleDirta.png new file mode 100644 index 000000000..729f30e6b Binary files /dev/null and b/data/texture/grayscaleDirta.png differ diff --git a/src/Preload/Render.hs b/src/Preload/Render.hs index 1dd35cbe0..5bd457212 100644 --- a/src/Preload/Render.hs +++ b/src/Preload/Render.hs @@ -90,7 +90,8 @@ preloadRender = do >>= addTexture "data/texture/grayscaleDirt.png" ---- texture array shader textArrayShad <- makeShader "texture/array" [vert,frag] [3,3] ETriangles - >>= addTextureArray "data/texture/ayene_wooden_floor.png" + >>= addTextureArray "data/texture/ayene_wooden_floor_transformed.png" + -- >>= addTextureArray "data/texture/ayene_wooden_floor.png" -- bind fixed vertex data bindShaderBuffers [fsShad,fullscreenAlphaHalveShad] [4,4] framebuf2 <- setupTextureFramebuffer 800 600 diff --git a/src/Shader/AuxAddition.hs b/src/Shader/AuxAddition.hs index acf83fa94..451a19d11 100644 --- a/src/Shader/AuxAddition.hs +++ b/src/Shader/AuxAddition.hs @@ -4,11 +4,12 @@ module Shader.AuxAddition , vaddTextureNoFilter , addTextureArray , addUniforms + , tilesToLine -- ^ kept in case it is needed in the future ) where import Shader.Data import Data.List.Extra -import Foreign +--import Foreign import Codec.Picture import qualified Data.Vector.Storable as V import Control.Lens @@ -41,8 +42,7 @@ vaddTextureNoFilter texturePath shad = do textureOb <- genObjectName textureBinding Texture2D $= Just textureOb textureFilter Texture2D $= ((Nearest,Nothing) , Nearest) - let texData = V.toList $ imageData tex - wtex = fromIntegral $ imageWidth tex + let wtex = fromIntegral $ imageWidth tex htex = fromIntegral $ imageHeight tex glTexStorage2D GL_TEXTURE_2D 1 GL_RGBA8 wtex htex --withArray texData $ \ptr -> do @@ -57,25 +57,29 @@ addTextureNoFilter texturePath shad = do textureOb <- genObjectName textureBinding Texture2D $= Just textureOb textureFilter Texture2D $= ((Nearest,Nothing) , Nearest) - let texData = V.toList $ imageData tex - wtex = fromIntegral $ imageWidth tex + let wtex = fromIntegral $ imageWidth tex htex = fromIntegral $ imageHeight tex glTexStorage2D GL_TEXTURE_2D 1 GL_RGBA8 wtex htex - --withArray texData $ \ptr -> do V.unsafeWith (imageData tex) $ \ptr -> do glTexSubImage2D GL_TEXTURE_2D 0 0 0 wtex htex GL_RGBA GL_UNSIGNED_BYTE ptr return $ shad & shaderTexture ?~ ShaderTexture {_textureObject = textureOb} +-- | for transforming a 256x256 image containing 64 tiles of 16x16 pixels into +-- an image that was directly readable by glTexSubImage3D, used the +-- transformation tilesToLine 8 128 on the underlying pixels. addTextureArray :: String -> FullShader -> IO FullShader addTextureArray texturePath shad = do textureOb <- genObjectName textureBinding Texture2DArray $= Just textureOb Right cmap <- readImage texturePath let tex = convertRGBA8 cmap - let texData = tilesToLine 128 8 . - V.toList $ imageData tex + --let texData = tilesToLine 8 128 . + --let texData = tilesToLine 8 128 . + -- V.toList $ imageData tex glTexStorage3D GL_TEXTURE_2D_ARRAY 3 GL_RGBA8 32 32 64 - withArray texData $ \ptr -> do + --writePng "atest.png" ((Image 256 256 (V.fromList texData)) :: Image PixelRGBA8) + --withArray texData $ \ptr -> do + V.unsafeWith (imageData tex) $ \ptr -> do --glTexSubImage3D GL_TEXTURE_2D_ARRAY 0 0 0 0 32 32 64 GL_RGBA GL_UNSIGNED_BYTE ptr glTexSubImage3D GL_TEXTURE_2D_ARRAY 0 0 0 0 32 32 64 GL_RGBA GL_UNSIGNED_BYTE ptr textureFilter Texture2DArray $= ((Linear',Just Linear') , Linear') @@ -88,14 +92,7 @@ tilesToLine -> Int -- ^ Parameter b -> [a] -> [a] -tilesToLine w n = concat . concat . transpose . chunksOf n . chunksOf w -tilesToLineV - :: Int -- ^ Parameter a - -> Int -- ^ Parameter b - -> V.Vector a - -> V.Vector a -tilesToLineV w n = undefined - +tilesToLine n w = concat . concat . transpose . chunksOf n . chunksOf w addUniforms :: [String] -> FullShader -> IO FullShader addUniforms uniStrings shad = do