Safe Haskell | None |
---|---|
Language | Haskell2010 |
Caramia resources.
Resources in Caramia encapsulate OpenGL resources which have some constraints on their use:
- They are, in the general case, only valid in a specific operating system thread.
- They need an implicit OpenGL context active to be used.
This module helps with the correct finalization of OpenGL resources as according to those constraints.
Most of the time, Caramia keeps Resource
objects hidden so you, the user,
is unlikely to see these directly.
Documentation
:: IO a | Action that returns the raw, unmanaged resource. Good place to create it. |
-> (a -> IO ()) | OpenGL finalizer. Will only be called in
the same thread as this |
-> IO () | 'Ordinary' finalizer. This will be called immediately when garbage collector collects the resource which means before the OpenGL finalizer and in a separate thread. If this finalizer throws an exception then the OpenGL finalizer is cancelled and the resource is marked as finalized. This will be run even if the OpenGL context is gone. |
-> IO (Resource a) |
Creates a new resource.
Must be called in a thread that has an OpenGL context active. Otherwise, an error will be thrown.
If you throw an exception in the OpenGL finalizer, then this will disrupt Caramia context and make it invalid. So try not to throw those exceptions?