This commit is contained in:
2023-03-23 14:14:54 +00:00
parent 02ee4b01c9
commit ecd7a0fae0
6 changed files with 4 additions and 72 deletions
+1 -22
View File
@@ -16,17 +16,14 @@ import Data.Preload.Render
import qualified Data.Vector.Unboxed.Mutable as UMV import qualified Data.Vector.Unboxed.Mutable as UMV
import Dodge.Data.Universe import Dodge.Data.Universe
import Dodge.Render.Lights import Dodge.Render.Lights
import Dodge.Render.Picture
import Dodge.Render.ShapePicture import Dodge.Render.ShapePicture
import Dodge.Render.Walls import Dodge.Render.Walls
import Foreign import Foreign
import Geometry import Geometry
import Graphics.GL.Core45 import Graphics.GL.Core45
import MatrixHelper import MatrixHelper
import Picture.Base
import Render import Render
import qualified SDL import qualified SDL
--import qualified SDL
import Shader import Shader
import Shader.Bind import Shader.Bind
import Shader.Data import Shader.Data
@@ -87,7 +84,7 @@ doDrawing' win pdata u = do
ws ws
) )
-- bind wall points, silhouette data, surface geometry -- bind wall points, silhouette data, surface geometry
bindShaderLayers shadV layerCounts bufferShaderLayers shadV layerCounts
uncurry (zipWithM_ bufferPokedVBO) $ uncurry (zipWithM_ bufferPokedVBO) $
unzip unzip
[ (pdata ^. vboWalls, nWalls) [ (pdata ^. vboWalls, nWalls)
@@ -374,26 +371,8 @@ doDrawing' win pdata u = do
glBindBufferBase GL_UNIFORM_BUFFER 0 (pdata ^. orthonormalMatUBO) glBindBufferBase GL_UNIFORM_BUFFER 0 (pdata ^. orthonormalMatUBO)
renderLayer FixedCoordLayer shadV layerCounts renderLayer FixedCoordLayer shadV layerCounts
glDepthMask GL_TRUE glDepthMask GL_TRUE
-- when (debugOn Show_ms_frame $ _uvConfig u) $
-- renderFoldable
-- (_pictureShaders pdata)
-- ( setDepth (-1)
-- . translate (-0.5) (-0.8)
-- . scale 0.0005 0.0005
-- $ fpsText (u ^. uvFrameTicks - u ^. uvLastFrameTicks)
-- )
SDL.glSwapWindow win SDL.glSwapWindow win
fpsText :: (Show a, Ord a, Num a) => a -> Picture
fpsText x = color col $ text $ "ms/frame " ++ show x
where
col
| x < 22 = blue
| x < 30 = green
| x < 40 = yellow
| x < 50 = orange
| otherwise = red
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- note: currently assume there is only one UBO, we only bind it once at setup -- note: currently assume there is only one UBO, we only bind it once at setup
--bufferUBO :: GLuint -> [Float] -> IO () --bufferUBO :: GLuint -> [Float] -> IO ()
-2
View File
@@ -14,8 +14,6 @@ import qualified Data.Set as Set
import Dodge.Base import Dodge.Base
import Dodge.Creature.Picture import Dodge.Creature.Picture
import Dodge.Creature.Picture.Awareness import Dodge.Creature.Picture.Awareness
import Dodge.Data.Config
import Dodge.Data.World
import Dodge.Debug.Picture import Dodge.Debug.Picture
import Dodge.Draw import Dodge.Draw
import Dodge.Flare import Dodge.Flare
-1
View File
@@ -1,6 +1,5 @@
module Dodge.TestString where module Dodge.TestString where
import Dodge.Render.ShapePicture
import Dodge.Render.Lights import Dodge.Render.Lights
import Data.Aeson (ToJSON) import Data.Aeson (ToJSON)
import Data.ByteString.Lazy.Char8 (unpack) import Data.ByteString.Lazy.Char8 (unpack)
-11
View File
@@ -1,6 +1,5 @@
module Render ( module Render (
createLightMap, createLightMap,
renderFoldable,
renderLayer, renderLayer,
pingPongBetween, pingPongBetween,
bindTO, bindTO,
@@ -351,16 +350,6 @@ pingPongBetween (fb1, to1) (fb2, to2) fs = do
glBindTexture GL_TEXTURE_2D (_unTO to2) glBindTexture GL_TEXTURE_2D (_unTO to2)
drawShader fs 4 drawShader fs 4
renderFoldable ::
MV.MVector (PrimState IO) (Shader,VBO) ->
Picture ->
IO ()
renderFoldable shadV struct = do
counts <- UMV.replicate 6 0
pokeBindFoldable shadV counts struct
MV.imapM_ (drawShaderLay 0 counts) shadV
------------------------------end renderFoldable
renderLayer :: renderLayer ::
Layer -> Layer ->
MV.MVector (PrimState IO) (Shader,VBO) -> MV.MVector (PrimState IO) (Shader,VBO) ->
-26
View File
@@ -3,24 +3,16 @@ module Shader (
drawShaderLay, drawShaderLay,
shadVBOptr, shadVBOptr,
drawShader, drawShader,
pokeBindFoldable,
pokeBindFoldableLayer,
) where ) where
import Control.Lens import Control.Lens
import Control.Monad import Control.Monad
import Control.Monad.Primitive import Control.Monad.Primitive
--import qualified Data.Vector as V
import qualified Data.Vector.Mutable as MV
--import qualified Data.Vector.Unboxed as UV
import qualified Data.Vector.Unboxed.Mutable as UMV import qualified Data.Vector.Unboxed.Mutable as UMV
import Foreign import Foreign
import Graphics.GL.Core45 import Graphics.GL.Core45
import Picture.Data
import Shader.Bind
import Shader.Data import Shader.Data
import Shader.Parameters import Shader.Parameters
import Shader.Poke
drawShaderLay :: Int -> UMV.MVector (PrimState IO) Int -> Int -> (Shader, VBO) -> IO () drawShaderLay :: Int -> UMV.MVector (PrimState IO) Int -> Int -> (Shader, VBO) -> IO ()
{-# INLINE drawShaderLay #-} {-# INLINE drawShaderLay #-}
@@ -48,24 +40,6 @@ drawShader fs i = do
freeShaderPointers' :: (Shader, VBO) -> IO () freeShaderPointers' :: (Shader, VBO) -> IO ()
freeShaderPointers' = free . _vboPtr . snd freeShaderPointers' = free . _vboPtr . snd
pokeBindFoldable ::
MV.MVector (PrimState IO) (Shader, VBO) ->
UMV.MVector (PrimState IO) Int ->
Picture ->
IO ()
pokeBindFoldable shadV counts m = do
pokeVerxs shadV counts m
bufferShaderVector shadV counts
pokeBindFoldableLayer ::
MV.MVector (PrimState IO) (Shader, VBO) ->
UMV.MVector (PrimState IO) Int ->
Picture ->
IO ()
pokeBindFoldableLayer shadV counts m = do
pokeLayVerxs shadV counts m
bindShaderLayers shadV counts
shadVBOptr :: (Shader, VBO) -> Ptr Float shadVBOptr :: (Shader, VBO) -> Ptr Float
{-# INLINE shadVBOptr #-} {-# INLINE shadVBOptr #-}
shadVBOptr = _vboPtr . snd shadVBOptr = _vboPtr . snd
+3 -10
View File
@@ -1,8 +1,6 @@
module Shader.Bind ( module Shader.Bind (
bindShaderLayers, bufferShaderLayers,
--, bindShaderBuffers
bufferPokedVBO, bufferPokedVBO,
bufferShaderVector,
) where ) where
import Control.Monad.Primitive import Control.Monad.Primitive
@@ -24,8 +22,8 @@ bufferPokedVBO theVBO numVs =
(fromIntegral $ floatSize * numVs * _vboVertexSize theVBO) (fromIntegral $ floatSize * numVs * _vboVertexSize theVBO)
(_vboPtr theVBO) (_vboPtr theVBO)
bindShaderLayers :: MV.MVector (PrimState IO) (Shader, VBO) -> UMV.MVector (PrimState IO) Int -> IO () bufferShaderLayers :: MV.MVector (PrimState IO) (Shader, VBO) -> UMV.MVector (PrimState IO) Int -> IO ()
bindShaderLayers shads counts = MV.imapM_ f shads bufferShaderLayers shads counts = MV.imapM_ f shads
where where
f i shad = do f i shad = do
let theVBO = snd shad let theVBO = snd shad
@@ -42,8 +40,3 @@ bindShaderLayers shads counts = MV.imapM_ f shads
glNamedBufferSubDataH :: GLuint -> GLintptr -> GLsizeiptr -> Ptr a -> IO () glNamedBufferSubDataH :: GLuint -> GLintptr -> GLsizeiptr -> Ptr a -> IO ()
glNamedBufferSubDataH = glNamedBufferSubData glNamedBufferSubDataH = glNamedBufferSubData
bufferShaderVector :: MV.MVector (PrimState IO) (Shader, VBO) -> UMV.MVector (PrimState IO) Int -> IO ()
bufferShaderVector shads counts = MV.imapM_ f shads
where
f i shad = UMV.read counts i >>= bufferPokedVBO (snd shad)