The glAsync functions deliver asynchronous OpenGL downloads in the spirit of the SGIX_async extension. The asynchronous execution of certain rendering commands can improve the overall performance of the application. The ARB_sync extension provides now a better way for asynchronous operations.
A second thread uses a shared context to the main context for asynchronous downloads. The application can map more than one context, but only one context can be current at a given time. All commands are executed in the order they are submitted. The asynchronous helper thread is only running when at least one context is mapped.
The functions are not thread-safe. For thread-safety and performance multi-threaded rendering codes are advised to use one glAsync::Thread instance per rendering thread.
Classes | |
class | Thread |
For multi-threaded rendering, use one instance of this class for each rendering thread. More... | |
Functions | |
Bool | XMapContext (Display *display, XVisualInfo *visInfo, GLXContext context) |
Map a context to be used for asynchronous functions. | |
void | XUnmapContext (Display *display, GLXContext context) |
Unmap a context to be used for asynchronous functions. | |
Bool | XMakeCurrent (Display *display, GLXContext context) |
Attach a rendering context to the asynchronous thread. | |
void | bindTexture (GLenum target, GLuint texture) |
Bind a named texture to a texturing target for the following asynchronous texture operations on the target. | |
GLuint | texImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) |
Specify a two-dimensional texture image. | |
GLuint | texImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) |
Specify a three-dimensional texture image. | |
Bool | poll (GLuint marker) |
Poll for the completion of an operation. | |
Bool | isIdle () |
Poll for the completion of all operations. | |
void | finish (GLuint marker) |
Finish an operation. | |
void | finishAll () |
Finish all pending operations. |
Bool glAsync::XMapContext | ( | Display * | display, | |
XVisualInfo * | visInfo, | |||
GLXContext | context | |||
) |
Map a context to be used for asynchronous functions.
This function creates a hidden shared context and drawable to be used the asynchronous functions.
display | the connection to the X server. | |
visInfo | the visual information. | |
context | the GLX rendering context. |
True
on success, False
otherwise. void glAsync::XUnmapContext | ( | Display * | display, | |
GLXContext | context | |||
) |
Unmap a context to be used for asynchronous functions.
This function deregisters the context from the glAsync library and deallocates all associated resources. For performance reasons it does not check that all outstanding commands for this context have been executed. The application has to explicitly wait for the commands to be finished before calling the function.
display | the connection to the X server. | |
context | the GLX rendering context. |
Bool glAsync::XMakeCurrent | ( | Display * | display, | |
GLXContext | context | |||
) |
Attach a rendering context to the asynchronous thread.
display | the connection to the X server. | |
context | the GLX rendering context. |
True
if successful, False
otherwise. void glAsync::bindTexture | ( | GLenum | target, | |
GLuint | texture | |||
) |
Bind a named texture to a texturing target for the following asynchronous texture operations on the target.
GLuint glAsync::texImage2D | ( | GLenum | target, | |
GLint | level, | |||
GLint | internalformat, | |||
GLsizei | width, | |||
GLsizei | height, | |||
GLint | border, | |||
GLenum | format, | |||
GLenum | type, | |||
const GLvoid * | pixels | |||
) |
Specify a two-dimensional texture image.
GLuint glAsync::texImage3D | ( | GLenum | target, | |
GLint | level, | |||
GLint | internalformat, | |||
GLsizei | width, | |||
GLsizei | height, | |||
GLsizei | depth, | |||
GLint | border, | |||
GLenum | format, | |||
GLenum | type, | |||
const GLvoid * | pixels | |||
) |
Specify a three-dimensional texture image.
Bool glAsync::poll | ( | GLuint | marker | ) |
Poll for the completion of an operation.
marker | the marker of the operation. |
True
if the operation has completed, False
if it is in progress. Bool glAsync::isIdle | ( | ) |
Poll for the completion of all operations.
True
if the helper thread is idle, i.e. all operations have completed, False
if there are still outstanding operations. void glAsync::finish | ( | GLuint | marker | ) |
Finish an operation.
Finish blocks until the operation has completed.
marker | the marker of the operation. |
void glAsync::finishAll | ( | ) |
Finish all pending operations.