module Graphics.Caramia.Buffer.Internal where
import Graphics.Caramia.Prelude
import Graphics.Caramia.Resource
import Graphics.Caramia.Internal.OpenGLCApi
import System.IO.Unsafe
data Buffer = Buffer
{ resource :: !(Resource Buffer_)
, status :: !(IORef BufferStatus)
, viewAllowedMappings :: !AccessFlags
, viewSize :: !Int
, ordIndex :: !Int
}
deriving ( Typeable )
bufferOrdIndex :: IORef Int
bufferOrdIndex = unsafePerformIO $ newIORef 0
instance Ord Buffer where
(ordIndex -> o1) `compare` (ordIndex -> o2) = o1 `compare` o2
data BufferStatus = BufferStatus
{ mapped :: !Bool }
instance Show Buffer where
show (Buffer{..}) =
"<Buffer bytesize(" <> show viewSize <> ") idx(" <>
show ordIndex <> ")>"
instance Eq Buffer where
(resource -> res1) == (resource -> res2) = res1 == res2
newtype Buffer_ = Buffer_ GLuint
data AccessFlags =
ReadAccess
| WriteAccess
| ReadWriteAccess
| NoAccess
deriving ( Eq, Ord, Show, Read )
data MapFlag =
UnSynchronized
deriving ( Eq, Ord, Show, Read, Typeable )