terminate :: Descriptor -> IO ()
terminate (Descriptor vertexBuffer attributes indexBuffer program _ _) = do
    currentProgram $= Nothing

    shaders <- get $ attachedShaders program
    mapM_ releaseShader shaders
    deleteObjectName program

    deleteObjectName indexBuffer
    deleteObjectName attributes
    deleteObjectName vertexBuffer

    checkError "terminate"

  where
    releaseShader shader = do
        detachShader program shader
        deleteObjectName shader


-- | A world matrix for the rectangle.
terminate :: Descriptor -> IO ()
terminate (Descriptor vertexBuffer attributes indexBuffer program _ _) = do
    currentProgram $= Nothing

    shaders <- get $ attachedShaders program
    mapM_ releaseShader shaders
    deleteObjectName program

    deleteObjectName indexBuffer
    deleteObjectName attributes
    deleteObjectName vertexBuffer

    checkError "terminate"

  where
    releaseShader shader = do
        detachShader program shader
        deleteObjectName shader


-- | A world matrix for the rectangle.
terminate (Descriptor vertexBuffer attributes indexBuffer program _ _) = do
    currentProgram $= Nothing

    shaders <- get $ attachedShaders program
    mapM_ releaseShader shaders
    deleteObjectName program

    deleteObjectName indexBuffer
    deleteObjectName attributes
    deleteObjectName vertexBuffer

    checkError "terminate"

  where
    releaseShader shader = do
        detachShader program shader
        deleteObjectName shader


-- | A world matrix for the rectangle.