Remove glTexImage

This commit is contained in:
jgk
2021-07-18 21:31:50 +02:00
parent 9407c7af2a
commit 595cb6e9a8
6 changed files with 39 additions and 88 deletions
+19 -3
View File
@@ -1,5 +1,6 @@
module Shader.AuxAddition
( addTexture
, addTextureNoFilter
, addTextureArray
, addUniforms
) where
@@ -26,11 +27,26 @@ addTexture texturePath shad = do
let texData = V.toList $ imageData tex
wtex = fromIntegral $ imageWidth tex
htex = fromIntegral $ imageHeight tex
glTexStorage2D GL_TEXTURE_2D 3 GL_RGBA8 wtex htex
withArray texData $ \ptr -> do
texImage2D Texture2D NoProxy 0 RGBA8 (TextureSize2D wtex htex) 0
(PixelData RGBA UnsignedByte ptr)
glTexSubImage2D GL_TEXTURE_2D 0 0 0 wtex htex GL_RGBA GL_UNSIGNED_BYTE ptr
textureFilter Texture2DArray $= ((Linear',Just Linear') , Linear')
generateMipmap' Texture2D
textureFilter Texture2D $= ((Linear',Just Linear') , Nearest)
return $ shad & shaderTexture ?~ ShaderTexture {_textureObject = textureOb}
addTextureNoFilter :: String -> FullShader -> IO FullShader
addTextureNoFilter texturePath shad = do
Right cmap <- readImage texturePath
let tex = convertRGBA8 cmap
textureOb <- genObjectName
textureBinding Texture2D $= Just textureOb
let texData = V.toList $ imageData tex
wtex = fromIntegral $ imageWidth tex
htex = fromIntegral $ imageHeight tex
glTexStorage2D GL_TEXTURE_2D 1 GL_RGBA8 wtex htex
withArray texData $ \ptr -> do
glTexSubImage2D GL_TEXTURE_2D 0 0 0 wtex htex GL_RGBA GL_UNSIGNED_BYTE ptr
textureFilter Texture2DArray $= ((Nearest,Nothing) , Nearest)
return $ shad & shaderTexture ?~ ShaderTexture {_textureObject = textureOb}
addTextureArray :: String -> FullShader -> IO FullShader