Use ssbo/vertex pulling for lighting cap shader
Not yet sure whether the colour vector is correctly input into the ssbo
This commit is contained in:
+1
-1
@@ -30,7 +30,7 @@ bufferEBO ebo numis =
|
||||
glNamedBufferSubData
|
||||
(ebo ^. eboName)
|
||||
0
|
||||
(fromIntegral $ glushortSize * numis)
|
||||
(fromIntegral $ gluintSize * numis)
|
||||
(ebo ^. eboPtr)
|
||||
|
||||
bufferShaderLayers :: MV.MVector (PrimState IO) (Shader, VBO) -> UMV.MVector (PrimState IO) Int -> IO ()
|
||||
|
||||
@@ -191,12 +191,12 @@ setupVAOUsingVBO vas vbo = do
|
||||
|
||||
setupEBO :: VAO -> IO EBO
|
||||
setupEBO vao = do
|
||||
eboptr <- mallocArray numGLushort
|
||||
eboptr <- mallocArray 65536 -- so we can go back to glushort...
|
||||
eboname <- mglCreate glCreateBuffers
|
||||
--glNamedBufferData
|
||||
glNamedBufferStorage
|
||||
eboname
|
||||
(fromIntegral $ glushortSize * numGLushort)
|
||||
(fromIntegral $ gluintSize * 65536)
|
||||
nullPtr
|
||||
GL_DYNAMIC_STORAGE_BIT
|
||||
--GL_STREAM_DRAW
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ data FloatBO = FloatBO
|
||||
|
||||
data EBO = EBO
|
||||
{ _eboName :: GLuint
|
||||
, _eboPtr :: Ptr GLushort
|
||||
, _eboPtr :: Ptr GLuint
|
||||
}
|
||||
|
||||
-- | Datatype containing the reference to a texture object.
|
||||
|
||||
@@ -3,8 +3,8 @@ module Shader.Parameters
|
||||
, ubyteSize
|
||||
, numDrawableVertices
|
||||
, numSubElements
|
||||
, glushortSize
|
||||
, numGLushort
|
||||
, gluintSize
|
||||
, numGLuint
|
||||
) where
|
||||
--import Picture.Data
|
||||
import Graphics.GL.Core45
|
||||
@@ -22,13 +22,13 @@ floatSize = sizeOf (0.5 :: GLfloat)
|
||||
--intSize = sizeOf (1 :: GLuint)
|
||||
--{-# INLINE intSize #-}
|
||||
|
||||
glushortSize :: Int
|
||||
glushortSize = sizeOf (0 :: GLushort)
|
||||
{-# INLINE glushortSize #-}
|
||||
gluintSize :: Int
|
||||
gluintSize = sizeOf (0 :: GLuint)
|
||||
{-# INLINE gluintSize #-}
|
||||
|
||||
numGLushort :: Int
|
||||
numGLushort = fromIntegral (maxBound :: GLushort) + 1
|
||||
{-# INLINE numGLushort #-}
|
||||
numGLuint :: Int
|
||||
numGLuint = fromIntegral (maxBound :: GLint) + 1
|
||||
{-# INLINE numGLuint #-}
|
||||
|
||||
-- why 6?
|
||||
numDrawableVertices :: Int
|
||||
|
||||
+11
-11
@@ -111,8 +111,8 @@ pokeW ptr i' ((V2 a b, V2 c d), V4 e f g h) = do
|
||||
pokeShape ::
|
||||
(Surface -> Bool) ->
|
||||
Ptr Float ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLuint ->
|
||||
Ptr GLuint ->
|
||||
(Int, Int, Int) ->
|
||||
[Surface] ->
|
||||
IO (Int, Int, Int)
|
||||
@@ -124,8 +124,8 @@ pokeShape shadowtest ptr iptr ieptr is =
|
||||
pokeShapeObj ::
|
||||
(Surface -> Bool) ->
|
||||
Ptr Float ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLuint ->
|
||||
Ptr GLuint ->
|
||||
(Int, Int, Int) ->
|
||||
Surface ->
|
||||
IO (Int, Int, Int)
|
||||
@@ -142,8 +142,8 @@ pokeRoundedFaces ::
|
||||
Point4 ->
|
||||
Int ->
|
||||
Ptr Float ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLuint ->
|
||||
Ptr GLuint ->
|
||||
(Int, Int, Int) ->
|
||||
[Point3] ->
|
||||
IO (Int, Int, Int)
|
||||
@@ -174,8 +174,8 @@ pokeCylinder ::
|
||||
Point4 ->
|
||||
Int ->
|
||||
Ptr Float ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLuint ->
|
||||
Ptr GLuint ->
|
||||
(Int, Int, Int) ->
|
||||
[Point3] ->
|
||||
IO (Int, Int, Int)
|
||||
@@ -229,8 +229,8 @@ pokeBox ::
|
||||
Point4 ->
|
||||
Int ->
|
||||
Ptr Float ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLuint ->
|
||||
Ptr GLuint ->
|
||||
(Int, Int, Int) ->
|
||||
[Point3] ->
|
||||
IO (Int, Int, Int)
|
||||
@@ -297,7 +297,7 @@ boxSurfacesIndices n =
|
||||
pokeIndex ::
|
||||
-- | base index
|
||||
Int ->
|
||||
Ptr GLushort ->
|
||||
Ptr GLuint ->
|
||||
-- | number poked
|
||||
Int ->
|
||||
-- | index offset
|
||||
|
||||
@@ -12,10 +12,10 @@ import Geometry.Data
|
||||
import Graphics.GL.Core45
|
||||
import Linear
|
||||
|
||||
pokeCloud :: Ptr Float -> Ptr GLushort -> (Int, Int) -> Cloud -> IO (Int, Int)
|
||||
pokeCloud :: Ptr Float -> Ptr GLuint -> (Int, Int) -> Cloud -> IO (Int, Int)
|
||||
pokeCloud vptr iptr (nv, ni) = pokeCloudLike vptr iptr (nv, ni) . mkCloudCloudLike
|
||||
|
||||
pokeDust :: Ptr Float -> Ptr GLushort -> (Int, Int) -> Dust -> IO (Int, Int)
|
||||
pokeDust :: Ptr Float -> Ptr GLuint -> (Int, Int) -> Dust -> IO (Int, Int)
|
||||
pokeDust vptr iptr (nv, ni) = pokeCloudLike vptr iptr (nv, ni) . mkDustCloudLike
|
||||
|
||||
mkCloudCloudLike :: Cloud -> (Point3, Point4)
|
||||
@@ -31,7 +31,7 @@ mkDustCloudLike x = (x ^. dsPos, V4 r g b a)
|
||||
a = a' * min 1 (fromIntegral (_dsTimer x) / 100)
|
||||
|
||||
pokeCloudLike ::
|
||||
Ptr Float -> Ptr GLushort -> (Int, Int) -> (Point3, Point4) -> IO (Int, Int)
|
||||
Ptr Float -> Ptr GLuint -> (Int, Int) -> (Point3, Point4) -> IO (Int, Int)
|
||||
pokeCloudLike vptr iptr (nv, ni) x = do
|
||||
UV.imapM_ (pokeCloudLikeVerx vptr x nv) $
|
||||
UV.fromList [(1, 1), (-1, 1), (-1, -1), (1, -1)]
|
||||
@@ -57,7 +57,7 @@ pokeCloudFloat :: Ptr Float -> Int -> Int -> Float -> IO ()
|
||||
{-# INLINE pokeCloudFloat #-}
|
||||
pokeCloudFloat ptr nv i = pokeElemOff ptr (nv * 12 + i)
|
||||
|
||||
pokeCloudIndex :: Ptr GLushort -> Int -> Int -> Int -> Int -> IO ()
|
||||
pokeCloudIndex :: Ptr GLuint -> Int -> Int -> Int -> Int -> IO ()
|
||||
{-# INLINE pokeCloudIndex #-}
|
||||
pokeCloudIndex ptr nv ni ioff voff = pokeElemOff ptr (ni + ioff) (fromIntegral $ nv + voff)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user