This manual page documents the OpenGL-specific functions exported by Agar.
These functions are available if Agar was compiled with OpenGL support
HAVE_OPENGL is defined after including the headers above).
Those functions are mostly useful for implementing new OpenGL-based Agar drivers (see AG_Driver(3)). Some of these functions are also useful to simplify texture management when implementing OpenGL-specific Agar-GUI widgets.
OPENGL CONTEXT MANAGEMENT
The AG_GL_InitContext() function is to be invoked by OpenGL-specific Agar drivers to initialize the GL context for rendering Agar GUI elements. This involves setting the projection and view matrices as well as various OpenGL options. AG_GL_InitContext() saves the current OpenGL state so that it can be later restored. The gl argument should point to an uninitialized AG_GL_Context structure.
The AG_GL_SetViewPort() function configures the GL viewport. In addition to invoking glViewport(3), this function also updates internal resolution-dependent states.
The AG_GL_DestroyContext() routines frees Agar's internal OpenGL state (restoring the state previously saved in AG_GL_InitContext()).
Multiple-window drivers will typically create a single OpenGL context per window, but single-window drivers may initialize and destroy the GL state more than once (see the AG_DRIVER_SW_OVERLAY option in AG_DriverSw(3)).
The AG_GL_UploadTexture() operation converts the specified AG_Surface(3) to an OpenGL texture, returning the GL texture handle in texName. Texture coordinates are returned into tc if non-NULL (i.e., X/Y coordinates are 0.0 and width/height are computed from the original dimensions divided by the texture's power-of-two dimensions).
The AG_GL_UpdateTexture() operation uploads a new surface as the specified texture ID. Similarly to AG_GL_UploadTexture(), texture coordinates are returned into tc if non-NULL.
The AG_GL_DeleteTexture() operation arranges for the specified GL texture to be deleted as soon as possible. Unlike a direct call to glDeleteTextures(3), using the AG_GL_DeleteTexture() function is thread-safe.
Similarly, AG_GL_DeleteList() arranges for the given GL display list to be deleted as soon as possible.
The remaining functions AG_GL_BlitSurface(), AG_GL_BlitSurfaceFrom(), etc. are generic OpenGL backends to the corresponding driver surface/texture operations (i.e., blitSurface(), blitSurfaceFrom(), etc.) See AG_Driver(3) for details.
These functions are generic OpenGL backends to the corresponding driver surface/texture operations (e.g., fillRect(), putPixel(), etc); see AG_Driver(3) for details.
|AG_Driver(3), AG_Intro(3), AG_Widget(3), AG_Window(3)|
|The AG_GL interface first appeared in Agar 1.4.0.|