[HOpenGL] Re: GL.BufferObjects patch request (1-liner)

Sven Panne Sven.Panne at aedion.de
Sun Apr 26 07:45:55 EDT 2009


Am Donnerstag, 20. November 2008 17:17:43 schrieb Neal Alexander:
> [...] If you use a single thread for OpenGL, but want to offload resource
> loading to a worker thread, you can mapBuffer in the GL thread then send
> the pointer to a worker thread (no GL context), then queue the
> unmapBuffer in the GL thread.
>
> withMappedBuffer locks everything into the calling thread. [...]

I am not 100% convinced that there is no way around this using 
withMappedBuffer (e.g. by passing the pointer from the wrapped action to 
another thread), but nevertheless, I've added mapBuffer and unmapBuffer to the 
exported API of the OpenGL package. Note the signature of mapBuffer:

   mapBuffer :: BufferTarget -> BufferAccess -> IO (Maybe (Ptr a))

Although not strictly necessary, I've explicitly wrapped the resulting pointer 
into a Maybe, making it crystal-clear that the caller should handle errors 
somehow.

For consistency reasons, I've added the beginQuery/endQuery pair as an 
alternative for withQuery, too. Although I'm really striving for API 
minimality, anticipating all possible uses of an API is really hard. Having 2 
ways of achieving things is not nice, but it is probably the safest thing to 
do here. *sigh*

Cheers,
   S.


More information about the HOpenGL mailing list