Poke word8 colors for shapes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
module Shader.Parameters
|
||||
( floatSize
|
||||
, ubyteSize
|
||||
, numDrawableElements
|
||||
, numSubElements
|
||||
, glushortSize
|
||||
@@ -8,6 +9,10 @@ module Shader.Parameters
|
||||
import Graphics.GL.Core45
|
||||
import Foreign
|
||||
|
||||
ubyteSize :: Int
|
||||
ubyteSize = sizeOf (5 :: Word8)
|
||||
{-# INLINE ubyteSize #-}
|
||||
|
||||
floatSize :: Int
|
||||
floatSize = sizeOf (0.5 :: GLfloat)
|
||||
{-# INLINE floatSize #-}
|
||||
|
||||
+10
-6
@@ -9,6 +9,7 @@ module Shader.Poke (
|
||||
pokeFloors,
|
||||
) where
|
||||
|
||||
import Color
|
||||
import Control.Monad.Primitive
|
||||
import qualified Data.Vector as V
|
||||
import qualified Data.Vector.Fusion.Stream.Monadic as VFSM
|
||||
@@ -426,10 +427,11 @@ pokeJustV ::
|
||||
IO Int
|
||||
{-# INLINE pokeJustV #-}
|
||||
pokeJustV xdata cp col ptr nv sh = do
|
||||
UV.imapM_ f $ UV.fromList [x, y, z, xdata, r, g, b, a, nx, ny, nz, 1]
|
||||
pokeByteOff ptr (nv * shapeVerxSize) (V4 x y z xdata)
|
||||
pokeByteOff ptr (nv *shapeVerxSize + 4 * floatSize) (toColor8 col)
|
||||
pokeByteOff ptr (nv *shapeVerxSize + 4 * (floatSize + ubyteSize)) (V4 nx ny nz 1)
|
||||
return (nv + 1)
|
||||
where
|
||||
f i = pokeElemOff ptr (nv * nShapeVerxComp + i)
|
||||
V3 x y z = sh
|
||||
V4 r g b a = col
|
||||
V3 nx ny nz = cp
|
||||
@@ -444,10 +446,11 @@ pokeJustVInvNormal ::
|
||||
IO Int
|
||||
{-# INLINE pokeJustVInvNormal #-}
|
||||
pokeJustVInvNormal xdata cp col ptr nv sh = do
|
||||
UV.imapM_ f $ UV.fromList [x, y, z, xdata, r, g, b, a, nx, ny, nz, 1]
|
||||
pokeByteOff ptr (nv * shapeVerxSize) (V4 x y z xdata)
|
||||
pokeByteOff ptr (nv *shapeVerxSize + 4 * floatSize) (toColor8 col)
|
||||
pokeByteOff ptr (nv *shapeVerxSize + 4 * (floatSize + ubyteSize)) (V4 nx ny nz 1)
|
||||
return (nv + 1)
|
||||
where
|
||||
f i = pokeElemOff ptr (nv * nShapeVerxComp + i)
|
||||
V3 x y z = sh
|
||||
V4 r g b a = col
|
||||
V3 nx ny nz = (2 * sh) - cp
|
||||
@@ -462,10 +465,11 @@ pokeFlatV ::
|
||||
IO Int
|
||||
{-# INLINE pokeFlatV #-}
|
||||
pokeFlatV xdata norm col ptr nv sh = do
|
||||
UV.imapM_ f $ UV.fromList [x, y, z, xdata, r, g, b, a, nx, ny, nz, 1]
|
||||
pokeByteOff ptr (nv * shapeVerxSize) (V4 x y z xdata)
|
||||
pokeByteOff ptr (nv *shapeVerxSize + 4 * floatSize) (toColor8 col)
|
||||
pokeByteOff ptr (nv *shapeVerxSize + 4 * (floatSize + ubyteSize)) (V4 nx ny nz 1)
|
||||
return (nv + 1)
|
||||
where
|
||||
f i = pokeElemOff ptr (nv * nShapeVerxComp + i)
|
||||
V3 x y z = sh
|
||||
V4 r g b a = col
|
||||
V3 nx ny nz = sh - norm
|
||||
|
||||
Reference in New Issue
Block a user