Some cleanup of rendering/poking, remove forcefield gun

This commit is contained in:
2024-10-01 13:19:34 +01:00
parent 6438da0037
commit d357d5a03c
11 changed files with 64 additions and 148 deletions
+2 -49
View File
@@ -5,13 +5,9 @@ module Shader.Compile (
makeShaderVBO,
makeShaderUsingVBO,
makeByteStringShaderUsingVAO,
makeStaticShader,
makeShaderUsingVAO,
setupVAOUsingVBO,
setupVAOvbo,
setupEBO,
setupVertexAttribPointer,
makeSourcedShader,
toFloatVAs,
setupStaticVBOVAO
) where
@@ -29,8 +25,6 @@ import Graphics.GL.Core45
import Shader.Data
import Shader.Parameters
--import Graphics.GL.Core45
{- |
Compiles a full shader found within the shader directory.
The shader is made up of files begining with the inputted string with extensions .vert, .geom etc.
@@ -70,10 +64,7 @@ makeShaderEBO s shaderlist sizes pm vbo = do
shad <- makeShaderUsingVBO s shaderlist sizes pm vbo
ebo <- setupEBO (shad ^. shaderVAO)
glVertexArrayElementBuffer (shad ^. shaderVAO . vaoName) (ebo ^. eboName)
return
( shad
, ebo
)
return (shad, ebo)
makeShaderUsingVBO ::
-- | First part of the name of the shader
@@ -92,6 +83,7 @@ makeShaderUsingVBO s shaderlist sizes pm vbo = do
setupVBO :: Int -> IO VBO
setupVBO vertexsize = do
vboname <- mglCreate glCreateBuffers
-- unclear whether this should also be multiplied by floatSize
thePtr <- mallocBytes (vertexsize * numDrawableVertices)
-- Allocate space
glNamedBufferData
@@ -120,8 +112,6 @@ setupStaticVBOVAO vas vdata = withArrayLen vdata $ \i ptr -> do
}
vao <- setupVAOUsingVBO vas vbo
return (vbo,vao)
setupVBOStatic :: Int -> IO VBO
setupVBOStatic vertexsize = do
@@ -170,33 +160,6 @@ makeShaderUsingVAO s shaderlist pm theVAO = do
, _shaderPrimitive = pm
}
-- this should be changed to some FIXED STORAGE SHADER
-- I cannot think of any other reason to have it
{- |
Compiles a full shader found within the shader directory.
The shader is made up of files begining with the inputted string with extensions .vert, .geom etc.
-}
makeStaticShader ::
Storable a =>
-- | First part of the name of the shader
String ->
-- | shader types
[GLenum] ->
[VertexAttribute] ->
[a] ->
PrimitiveMode ->
IO Shader
makeStaticShader s shaderlist vas vdata pm = do
prog <- makeSourcedShader s shaderlist
(_, vao) <- setupStaticVBOVAO vas vdata
return
( Shader
{ _shaderUINT = prog
, _shaderVAO = vao
, _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.
@@ -213,16 +176,6 @@ shaderTypeExt GL_FRAGMENT_SHADER = ".frag"
shaderTypeExt GL_COMPUTE_SHADER = ".comp"
shaderTypeExt _ = undefined
setupVAOvbo :: [VertexAttribute] -> Int -> GLuint -> IO VAO
setupVAOvbo sizes strd vbo = do
vaoname <- mglCreate glCreateVertexArrays
glBindVertexArray vaoname
setupVertexAttribs vbo vaoname sizes (fromIntegral strd * fromIntegral floatSize)
return $
VAO
{ _vaoName = vaoname
}
setupVAOUsingVBO :: [VertexAttribute] -> VBO -> IO VAO
setupVAOUsingVBO vas vbo = do
let strd = vbo ^. vboVertexBytes
+3 -1
View File
@@ -6,7 +6,7 @@ module Shader.Parameters
, glushortSize
, numGLushort
) where
import Picture.Data
--import Picture.Data
import Graphics.GL.Core45
import Foreign
@@ -30,10 +30,12 @@ numGLushort :: Int
numGLushort = fromIntegral (maxBound :: GLushort) + 1
{-# INLINE numGLushort #-}
-- why 6?
numDrawableVertices :: Int
{-# INLINE numDrawableVertices #-}
numDrawableVertices = 6 * numSubElements
-- why this number?
numSubElements :: Int
{-# INLINE numSubElements #-}
numSubElements = 65536