Define shape datatype
This commit is contained in:
@@ -16,6 +16,7 @@ import Control.Monad.Primitive
|
||||
import Control.Monad
|
||||
|
||||
bindArrayBuffers :: Int -> VBO -> IO ()
|
||||
{-# INLINABLE bindArrayBuffers #-}
|
||||
bindArrayBuffers numVs theVBO = do
|
||||
bindBuffer ArrayBuffer $= Just (_vbo theVBO)
|
||||
bufferSubData
|
||||
|
||||
@@ -7,10 +7,13 @@ module Shader.Poke
|
||||
, pokePoint3s
|
||||
, pokePoint33s
|
||||
, poke224s
|
||||
, pokeShape
|
||||
, pokeShapeVs
|
||||
) where
|
||||
import Shader.Data
|
||||
import Shader.Parameters
|
||||
import Picture.Data
|
||||
import Shape.Data
|
||||
import Geometry.Data
|
||||
|
||||
import Foreign
|
||||
@@ -37,6 +40,40 @@ pokeVerx vbos offsets Verx{_vxPos=thePos,_vxCol=theCol,_vxExt=ext,_vxShadNum=the
|
||||
where
|
||||
sn = _unShadNum theShadNum
|
||||
|
||||
pokeShape :: Ptr Float -> Ptr Float -> Shape -> IO (Int,Int)
|
||||
pokeShape vptr eptr sh = do
|
||||
nVs <- pokeShapeVs vptr (_shVertices sh)
|
||||
nEs <- pokeShapeEs eptr (_shEdges sh)
|
||||
return (nVs,nEs)
|
||||
|
||||
pokeShapeVs :: Ptr Float -> [ShapeV] -> IO Int
|
||||
pokeShapeVs ptr vals0 = go vals0 0
|
||||
where
|
||||
go [] n = return n
|
||||
go ( sh:vals) !n = do
|
||||
pokeElemOff ptr (off 0) a
|
||||
pokeElemOff ptr (off 1) b
|
||||
pokeElemOff ptr (off 2) c
|
||||
pokeElemOff ptr (off 3) d
|
||||
pokeElemOff ptr (off 4) e
|
||||
pokeElemOff ptr (off 5) f
|
||||
pokeElemOff ptr (off 6) g
|
||||
go vals (n+1)
|
||||
where
|
||||
off i = n*7 + i
|
||||
V3 a b c = _svPos sh
|
||||
V4 d e f g = _svCol sh
|
||||
|
||||
pokeShapeEs :: Ptr Float -> [Point3] -> IO Int
|
||||
pokeShapeEs ptr vals0 = go vals0 0
|
||||
where
|
||||
go [] n = return n
|
||||
go ((V3 a b c) :vals) !n = do
|
||||
pokeElemOff ptr (n * 3) a
|
||||
pokeElemOff ptr (n * 3 + 1) b
|
||||
pokeElemOff ptr (n * 3 + 2) c
|
||||
go vals (n+1)
|
||||
|
||||
pokeLayVerxs
|
||||
:: MV.MVector (PrimState IO) FullShader
|
||||
-> UMV.MVector (PrimState IO) Int
|
||||
|
||||
Reference in New Issue
Block a user