render :: Descriptor -- ^ a descriptor
    -> AM.RectangleData -- ^ data of the rectangle
    -> IO ()
render (Descriptor _ attributes indexBuffer program rectangleOffset rectangleNumIndices) td = do
    worldLocation <- get $ uniformLocation program "world"
    UL.uniformMatrix4fv worldLocation $= [worldMatrix td]

    clear [ ColorBuffer ]

    bindVertexArrayObject $= Just attributes
    bindBuffer ElementArrayBuffer $= Just indexBuffer

    drawElements Triangles rectangleNumIndices UnsignedShort (bufferOffset rectangleOffset)

    bindBuffer ElementArrayBuffer $= Nothing
    bindVertexArrayObject $= Nothing

    flush

    checkError "render"
render :: Descriptor -- ^ a descriptor
    -> AM.RectangleData -- ^ data of the rectangle
    -> IO ()
render (Descriptor _ attributes indexBuffer program rectangleOffset rectangleNumIndices) td = do
    worldLocation <- get $ uniformLocation program "world"
    UL.uniformMatrix4fv worldLocation $= [worldMatrix td]

    clear [ ColorBuffer ]

    bindVertexArrayObject $= Just attributes
    bindBuffer ElementArrayBuffer $= Just indexBuffer

    drawElements Triangles rectangleNumIndices UnsignedShort (bufferOffset rectangleOffset)

    bindBuffer ElementArrayBuffer $= Nothing
    bindVertexArrayObject $= Nothing

    flush

    checkError "render"
render (Descriptor _ attributes indexBuffer program rectangleOffset rectangleNumIndices) td = do
    worldLocation <- get $ uniformLocation program "world"
    UL.uniformMatrix4fv worldLocation $= [worldMatrix td]

    clear [ ColorBuffer ]

    bindVertexArrayObject $= Just attributes
    bindBuffer ElementArrayBuffer $= Just indexBuffer

    drawElements Triangles rectangleNumIndices UnsignedShort (bufferOffset rectangleOffset)

    bindBuffer ElementArrayBuffer $= Nothing
    bindVertexArrayObject $= Nothing

    flush

    checkError "render"