Remove unused shader code

This commit is contained in:
2025-11-14 11:27:16 +00:00
parent 836fefb9a5
commit 91917dbddd
9 changed files with 20 additions and 120 deletions
+7 -106
View File
@@ -1,16 +1,13 @@
module Shader.Compile (
setupVBO,
setupVBOStatic,
makeShaderEBO,
-- makeShaderEBO,
makeShaderVBO,
makeShaderUsingVBO,
-- makeShaderUsingVBO,
makeShaderProgram,
-- makeByteStringShaderUsingVAO,
makeShaderUsingVAO,
setupVAOUsingVBO,
setupEBO,
-- makeShaderUsingVAO,
-- setupVAOUsingVBO,
-- setupEBO,
toFloatVAs,
setupStaticVBOVAO,
-- setupStaticVBOVAO,
makeSourcedShader,
) where
@@ -20,7 +17,6 @@ import qualified Data.ByteString as BS
import qualified Data.ByteString.Unsafe as BU
import Foreign
import Foreign.C.String
import Foreign.C.Types
import GLHelp
import Graphics.GL.Core45
import Graphics.GL.Types
@@ -52,36 +48,6 @@ makeShaderVBO s shaderlist sizes pm = do
, vbo
)
makeShaderEBO ::
-- | First part of the name of the shader
String ->
-- | shader types
[GLenum] ->
-- | The input vertex sizes
[VertexAttribute] ->
PrimitiveMode ->
VBO ->
IO (Shader, UintBO)
makeShaderEBO s shaderlist sizes pm vbo = do
shad <- makeShaderUsingVBO s shaderlist sizes pm vbo
ebo <- setupEBO (shad ^. shaderVAO)
glVertexArrayElementBuffer (shad ^. shaderVAO . vaoName) (ebo ^. uiboName)
return (shad, ebo)
makeShaderUsingVBO ::
-- | First part of the name of the shader
String ->
-- | shader types
[GLenum] ->
-- | The input vertex sizes
[VertexAttribute] ->
PrimitiveMode ->
VBO ->
IO Shader
makeShaderUsingVBO s shaderlist sizes pm vbo = do
vao <- setupVAOUsingVBO sizes vbo
makeShaderUsingVAO s shaderlist pm vao
setupVBO :: Int -> IO VBO
setupVBO vertexsize = do
vboname <- mglCreate glCreateBuffers
@@ -98,58 +64,6 @@ setupVBO vertexsize = do
GL_DYNAMIC_STORAGE_BIT
return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexBytes = vertexsize}
-- the input ptr is assumed to contain the correct amount of data according to
-- the specified number and type of vertices
-- note the VBO here does not have a sensible ptr value
setupStaticVBOVAO :: Storable a => [VertexAttribute] -> [a] -> IO (VBO, VAO)
setupStaticVBOVAO vas vdata = withArrayLen vdata $ \i ptr -> do
vboname <- mglCreate glCreateBuffers
glNamedBufferStorage
vboname
(CPtrdiff (fromIntegral (i * sizeOf (head vdata))))
ptr
0
let vbo =
VBO
{ _vboName = vboname
, _vboPtr = nullPtr
, _vboVertexBytes = vasTightStride vas
}
vao <- setupVAOUsingVBO vas vbo
return (vbo, vao)
setupVBOStatic :: Int -> IO VBO
setupVBOStatic vertexsize = do
vboname <- mglCreate glCreateBuffers
thePtr <- mallocBytes (vertexsize * numDrawableVertices)
-- Allocate space
--glNamedBufferData
glNamedBufferStorage
vboname
(fromIntegral $ numDrawableVertices * vertexsize)
nullPtr
GL_DYNAMIC_STORAGE_BIT
--GL_STATIC_DRAW
return VBO{_vboName = vboname, _vboPtr = thePtr, _vboVertexBytes = vertexsize}
-- | Takes the VAO from elsewhere
makeShaderUsingVAO ::
-- | First part of the name of the shader
String ->
-- | shader types
[GLenum] ->
PrimitiveMode ->
VAO ->
IO Shader
makeShaderUsingVAO s shaderlist pm theVAO = do
prog <- makeSourcedShader s shaderlist
return
Shader
{ _shaderUINT = prog
, _shaderVAO = theVAO
, _shaderPrimitive = pm
}
{- | Compile shader and get its uniform locations.
supposes the shader code is in the shader folder, with the string names
followed by .vert/.geom/.frag.
@@ -176,26 +90,13 @@ setupVAOUsingVBO vas vbo = do
vaoname
vas
(fromIntegral strd)
return VAO{_vaoName = vaoname}
setupEBO :: VAO -> IO UintBO
setupEBO vao = do
eboptr <- mallocArray 65536 -- so we can go back to glushort...
eboname <- mglCreate glCreateBuffers
glNamedBufferStorage
eboname
(fromIntegral $ gluintSize * 65536)
nullPtr
GL_DYNAMIC_STORAGE_BIT
glVertexArrayElementBuffer (vao ^. vaoName) eboname
return $ UintBO eboname eboptr
return $ VAO vaoname
setupVBOVAO :: [VertexAttribute] -> IO (VAO, VBO)
setupVBOVAO vas = do
vaoname <- mglCreate glCreateVertexArrays
glBindVertexArray vaoname
vbo <- setupVBO strd
--vao <- setupVAOvbo (toFloatVAs sizes) (sum sizes) (vbo ^. vboName)
vao <- setupVAOUsingVBO vas vbo
return (vao, vbo)
where
+1 -1
View File
@@ -61,7 +61,7 @@ newtype TO = TO {_unTO :: GLuint}
{- | Vertex array object: contains the reference to the object,
and its buffer targets.
-}
newtype VAO = VAO { _vaoName :: GLuint }
newtype VAO = VAO { _unVAO :: GLuint }
data VertexAttribute = VertexAttribute
{ _vaCount :: GLint
-1
View File
@@ -5,7 +5,6 @@ module Shader.Poke.Cloud (pokeCloud, pokeDust) where
import Shader.Parameters
import Color
import Control.Lens
--import qualified Data.Vector.Unboxed as UV
import Dodge.Data.Cloud
import Dodge.Material.Color
import Foreign