{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
module Picture.Data
    where
import Geometry.Data

import Control.Lens
import Streaming
data Verx = Verx
    { _vxPos    :: !Point3
    , _vxCol    :: !Point4
    , _vxExt    :: [Float]
    , _vxLayer  :: !Layer
    , _vxShadNum  :: !ShadNum
    }
  deriving (Eq,Ord,Show)
--newtype LayNum  = LayNum  { _unLayNum :: Int }

data Layer
    = BottomLayer
    | MidLayer
    | BloomLayer
    | BloomNoZWrite
    | DebugLayer
    | FixedCoordLayer
  deriving (Eq,Ord,Enum,Bounded,Show)

layerNum :: Layer -> Int
layerNum = fromEnum
numLayers :: Int
numLayers = length [minBound::Layer .. maxBound]
--TODO use synonyms for layer numbers
newtype ShadNum = ShadNum { _unShadNum :: Int }
  deriving (Eq,Ord,Show)
polyNum, polyzNum, bezNum, textNum, arcNum, ellNum :: ShadNum
{-# INLINE polyNum #-}
{-# INLINE polyzNum #-}
{-# INLINE bezNum #-}
{-# INLINE textNum #-}
{-# INLINE arcNum #-}
{-# INLINE ellNum #-}
polyNum     = ShadNum 0
polyzNum    = ShadNum 1
bezNum      = ShadNum 2
textNum     = ShadNum 3
arcNum      = ShadNum 4
ellNum      = ShadNum 5
type Picture = Stream (Of Verx) IO ()
flat2 :: V2 a -> [a]
flat2 (V2 x y) = [x,y]
flat3 :: V3 a -> [a]
flat3 (V3 x y z) = [x,y,z]
flat4 :: V4 a -> [a]
flat4 (V4 x y z w) = [x,y,z,w]
{-# INLINE flat2 #-}
{-# INLINE flat3 #-}
{-# INLINE flat4 #-}
tflat2 :: (a,a) -> [a]
tflat2 (x,y) = [x,y]
tflat3 :: (a,a,a) -> [a]
tflat3 (x,y,z) = [x,y,z]
tflat4 :: (a,a,a,a) -> [a]
tflat4 (x,y,z,w) = [x,y,z,w]
{-# INLINE tflat2 #-}
{-# INLINE tflat3 #-}
{-# INLINE tflat4 #-}
makeLenses ''Verx
