Use texture array for character rendering, condense rendering

This commit is contained in:
2023-03-23 14:08:07 +00:00
parent 68b43f29ff
commit 3350a8dc30
9 changed files with 80 additions and 42 deletions
+15
View File
@@ -2,6 +2,7 @@ module Shader.AuxAddition
( addSamplerTexture2D
, vaddTextureNoFilter
, addTextureArray
, addTextureArray'
, initTexture2D
, initTexture2DArray
, tilesToLine
@@ -127,6 +128,20 @@ addTextureArray texturePath (shad,vbo) = do
return (shad & shaderTextures .:~ TO texname
, vbo)
addTextureArray' :: String -> GLsizei -> GLsizei -> GLsizei -> GLsizei -> GLenum -> GLenum
-> Shader -> IO Shader
addTextureArray' fp nlev w h d minfilt magfilt shad = do
Right cmap <- readImage fp
let texdata = convertRGBA8 cmap
texname <- mglCreate $ glCreateTextures GL_TEXTURE_2D_ARRAY
glTextureStorage3D texname nlev GL_RGBA8 w h d
VS.unsafeWith (imageData texdata) $ \ptr -> do
glTextureSubImage3D texname 0 0 0 0 w h d GL_RGBA GL_UNSIGNED_BYTE ptr
glGenerateTextureMipmap texname
glTextureParameteri texname GL_TEXTURE_MIN_FILTER (unsafeCoerce minfilt)
glTextureParameteri texname GL_TEXTURE_MAG_FILTER (unsafeCoerce magfilt)
return (shad & shaderTextures .:~ TO texname )
tilesToLine
:: Int -- ^ Parameter a
-> Int -- ^ Parameter b