Continue work on texture binding
This commit is contained in:
@@ -86,27 +86,13 @@ initTexture2DArray nlev minfilt magfilt fp = do
|
|||||||
let wtex = fromIntegral $ imageWidth texdata
|
let wtex = fromIntegral $ imageWidth texdata
|
||||||
htex = fromIntegral $ imageHeight texdata
|
htex = fromIntegral $ imageHeight texdata
|
||||||
z = htex `div` wtex
|
z = htex `div` wtex
|
||||||
checkGLError
|
|
||||||
putStrLn "x"
|
|
||||||
texname <- mglCreate $ glCreateTextures GL_TEXTURE_2D_ARRAY
|
texname <- mglCreate $ glCreateTextures GL_TEXTURE_2D_ARRAY
|
||||||
checkGLError
|
|
||||||
putStrLn "y"
|
|
||||||
glTextureStorage3D texname nlev GL_RGBA8 wtex wtex z
|
glTextureStorage3D texname nlev GL_RGBA8 wtex wtex z
|
||||||
checkGLError
|
|
||||||
putStrLn "z"
|
|
||||||
VS.unsafeWith (imageData texdata) $ \ptr -> do
|
VS.unsafeWith (imageData texdata) $ \ptr -> do
|
||||||
glTextureSubImage3D texname 0 0 0 0 wtex wtex z GL_RGBA GL_UNSIGNED_BYTE ptr
|
glTextureSubImage3D texname 0 0 0 0 wtex wtex z GL_RGBA GL_UNSIGNED_BYTE ptr
|
||||||
checkGLError
|
|
||||||
putStrLn "i"
|
|
||||||
glGenerateTextureMipmap texname
|
glGenerateTextureMipmap texname
|
||||||
checkGLError
|
|
||||||
putStrLn "q"
|
|
||||||
glTextureParameteri texname GL_TEXTURE_MIN_FILTER (unsafeCoerce minfilt)
|
glTextureParameteri texname GL_TEXTURE_MIN_FILTER (unsafeCoerce minfilt)
|
||||||
checkGLError
|
|
||||||
putStrLn "w"
|
|
||||||
glTextureParameteri texname GL_TEXTURE_MAG_FILTER (unsafeCoerce magfilt)
|
glTextureParameteri texname GL_TEXTURE_MAG_FILTER (unsafeCoerce magfilt)
|
||||||
checkGLError
|
|
||||||
putStrLn "e"
|
|
||||||
return $ TO texname
|
return $ TO texname
|
||||||
|
|
||||||
-- | for transforming a 256x256 image containing 64 tiles of 16x16 pixels into
|
-- | for transforming a 256x256 image containing 64 tiles of 16x16 pixels into
|
||||||
@@ -133,6 +119,11 @@ addBindTextureArray :: GLuint -> String -> GLsizei -> GLsizei -> GLsizei -> GLsi
|
|||||||
addBindTextureArray bindpoint fp nlev w h d minfilt magfilt = do
|
addBindTextureArray bindpoint fp nlev w h d minfilt magfilt = do
|
||||||
Right cmap <- readImage fp
|
Right cmap <- readImage fp
|
||||||
let texdata = convertRGBA8 cmap
|
let texdata = convertRGBA8 cmap
|
||||||
|
initTexture2DArrayData bindpoint texdata nlev w h d minfilt magfilt
|
||||||
|
|
||||||
|
initTexture2DArrayData :: GLuint -> Image PixelRGBA8 -> GLsizei -> GLsizei -> GLsizei -> GLsizei -> GLenum -> GLenum
|
||||||
|
-> IO ()
|
||||||
|
initTexture2DArrayData bindpoint texdata nlev w h d minfilt magfilt = do
|
||||||
texname <- mglCreate $ glCreateTextures GL_TEXTURE_2D_ARRAY
|
texname <- mglCreate $ glCreateTextures GL_TEXTURE_2D_ARRAY
|
||||||
glTextureStorage3D texname nlev GL_RGBA8 w h d
|
glTextureStorage3D texname nlev GL_RGBA8 w h d
|
||||||
VS.unsafeWith (imageData texdata) $ \ptr -> do
|
VS.unsafeWith (imageData texdata) $ \ptr -> do
|
||||||
|
|||||||
Reference in New Issue
Block a user