{-# LANGUAGE TypeFamilies #-}
module Types.Graphics.VertexArray where

import qualified Graphics.Rendering.OpenGL as GL

import SDL (($=), get)

import qualified Data.Vector as V

import Foreign (sizeOf)
import Foreign.Ptr

import Control.Concurrent.STM

import Control.Monad (void)

-- internal imports

import Classes.Graphics.Bindable
import Classes.Graphics.Buffer
import Types.Graphics.VertexBuffer

newtype VertexArray = VertexArray
  { vArrId :: GL.VertexArrayObject
  }
  deriving (Eq, Show)

instance Bindable VertexArray where

  bind va = GL.bindVertexArrayObject $= Just (vArrId va)

  unbind va = GL.bindVertexArrayObject $= Nothing

newVertexArray :: IO VertexArray
newVertexArray = VertexArray
  <$> GL.genObjectName
