pituicat/src/Classes/Graphics/Buffer.hs

40 lines
1 KiB
Haskell
Raw Normal View History

2020-10-17 14:18:42 +00:00
{-# LANGUAGE TypeFamilies #-}
module Classes.Graphics.Buffer where
import qualified Graphics.Rendering.OpenGL as GL
import SDL (($=), get)
-- internal imports
import Classes.Graphics.Bindable
-- | this aims to be a typeclass for all used buffer objects throughout the
-- game. all buffer objects have to instanciate the Bindable typeclass.
-- think of it as some kind of interface in the object oriented context
2020-10-17 14:18:42 +00:00
class (Bindable a) => Buffer a where
type ObjName a :: *
-- | what buffer target does the buffer bind to
2020-10-17 14:18:42 +00:00
target :: a -> GL.BufferTarget
-- | retrieve ID from buffer object
glId :: a -> IO (ObjName a)
2020-10-17 14:18:42 +00:00
-- | bind the buffer object and fill it with null data
2020-10-17 14:18:42 +00:00
initialize :: a -> IO ()
-- | fill the buffer with actual data
write
:: a
-> Word -- ^ write offset from beginning of buffer in bytes
-> b -- ^ Data to write
-> IO ()
-- | expand the buffer to double of it's previous size.
expand :: a -> IO ()
-- | free resources and delete the object
delete :: a -> IO ()