module Graphics.Rendering.OpenGL.GL.QueryObject (
QueryObject(..), noQueryObject
) where
import Foreign.Marshal.Array
import Graphics.Rendering.OpenGL.GL.GLboolean
import Graphics.Rendering.OpenGL.GL.ObjectName
import Graphics.Rendering.OpenGL.Raw
newtype QueryObject = QueryObject { queryID :: GLuint }
deriving ( Eq, Ord, Show )
noQueryObject :: QueryObject
noQueryObject = QueryObject 0
instance ObjectName QueryObject where
isObjectName = fmap unmarshalGLboolean . glIsQuery . queryID
deleteObjectNames queryObjects =
withArrayLen (map queryID queryObjects) $
glDeleteQueries . fromIntegral
instance GeneratableObjectName QueryObject where
genObjectNames n =
allocaArray n $ \buf -> do
glGenQueries (fromIntegral n) buf
fmap (map QueryObject) $ peekArray n buf