Refactor shader types
This commit is contained in:
@@ -4,24 +4,23 @@ module Shader.AuxAddition
|
||||
, addTextureArray
|
||||
, initTexture2D
|
||||
, initTexture2DArray
|
||||
, tilesToLine -- ^ kept in case it is needed in the future
|
||||
, tilesToLine
|
||||
) where
|
||||
import Data.Preload.Render
|
||||
import LensHelp
|
||||
import Unsafe.Coerce
|
||||
import Shader.Data
|
||||
import Data.List.Extra
|
||||
import Codec.Picture
|
||||
import qualified Data.Vector.Storable as VS
|
||||
import Control.Lens
|
||||
import Graphics.GL.Core45
|
||||
import GLHelp
|
||||
|
||||
-- I am not sure if this assumes that the shader is constructed directly before
|
||||
-- the texture is added...
|
||||
addSamplerTexture2D :: String -> FullShader -> IO FullShader
|
||||
addSamplerTexture2D :: String -> Shader -> IO Shader
|
||||
addSamplerTexture2D = addTexture2D 3 GL_LINEAR_MIPMAP_LINEAR GL_LINEAR
|
||||
|
||||
vaddTextureNoFilter :: String -> FullShader -> IO FullShader
|
||||
vaddTextureNoFilter :: String -> Shader -> IO Shader
|
||||
vaddTextureNoFilter = addTexture2D 1 GL_NEAREST GL_NEAREST
|
||||
|
||||
addTexture2D
|
||||
@@ -29,7 +28,7 @@ addTexture2D
|
||||
-> GLenum -- minfilter
|
||||
-> GLenum -- magfilter
|
||||
-> String -- path to image
|
||||
-> FullShader -> IO FullShader
|
||||
-> Shader -> IO Shader
|
||||
addTexture2D nlev minfilt magfilt texpath shad = do
|
||||
Right cmap <- readImage texpath
|
||||
let texdata = convertRGBA8 cmap
|
||||
@@ -42,8 +41,7 @@ addTexture2D nlev minfilt magfilt texpath shad = do
|
||||
glGenerateTextureMipmap texname
|
||||
glTextureParameteri texname GL_TEXTURE_MIN_FILTER (unsafeCoerce minfilt)
|
||||
glTextureParameteri texname GL_TEXTURE_MAG_FILTER (unsafeCoerce magfilt)
|
||||
return $ shad & shadTex' ?~ ShaderTexture
|
||||
{_textureObject = texname }
|
||||
return $ shad & shaderTextures .:~ TO texname
|
||||
-- alloca $ \nameptr -> do
|
||||
-- glCreateTextures GL_TEXTURE_2D 1 nameptr
|
||||
-- texname <- peek nameptr
|
||||
@@ -113,7 +111,7 @@ initTexture2DArray nlev minfilt magfilt fp = do
|
||||
-- | 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,VBO) -> IO (FullShader,VBO)
|
||||
addTextureArray :: String -> (Shader,VBO) -> IO (Shader,VBO)
|
||||
addTextureArray texturePath (shad,vbo) = do
|
||||
err <- glGetError
|
||||
print err
|
||||
@@ -126,11 +124,9 @@ addTextureArray texturePath (shad,vbo) = do
|
||||
glGenerateTextureMipmap texname
|
||||
glTextureParameteri texname GL_TEXTURE_MIN_FILTER (unsafeCoerce GL_LINEAR_MIPMAP_LINEAR)
|
||||
glTextureParameteri texname GL_TEXTURE_MAG_FILTER (unsafeCoerce GL_LINEAR)
|
||||
return (shad & shadTex' ?~ ShaderTexture
|
||||
{ _textureObject = texname}
|
||||
return (shad & shaderTextures .:~ TO texname
|
||||
, vbo)
|
||||
|
||||
-- I am completely unclear on why this works with its current parameters
|
||||
tilesToLine
|
||||
:: Int -- ^ Parameter a
|
||||
-> Int -- ^ Parameter b
|
||||
|
||||
Reference in New Issue
Block a user