Trial is heavily based on the OpenGL graphics API. GL can be rather difficult to deal with at times, and Trial includes a bunch of tools to ease handling its various complications.
Which GL features are even available depends a lot on the target system, and can only be known once the GL context has been executed. So, once the
context is established, you can use
gl-extension-p to test whether an extension is available, or directly run varying branches with
Branching based on available extensions allows you to implement optional features or fast paths for more recent OpenGL additions without dropping backwards compatibility.
The set of available extensions is also logged on context creation, though under the
OpenGL allows you to disable and enable various features at runtime. Trial tries to keep track of this feature set to ensure that, in the cases that knowing the set of features matters, the information can't drift.
To disable or enable features, you should use Trial's
enable-feature functions, rather than directly calling GL's. You can then also use
pop-features, or simply
with-pushed-features to ensure that changes to the set of enabled features don't escape your local context.
For instance, to disable depth testing for a particular draw, you could wrap it in
(with-pushed-features (disable-feature :depth-test) ...)
You can fetch the name of the current graphics vendor with
gl-vendor. It'll return either:
This also includes the former ATI
Sometimes it may be necessary to implement specific hardware vendor hacks to work around driver bugs.
One of the most complicated areas of OpenGL is the texture formats and pixel data. Trial includes the following functions to allow you to deal with them a bit more easily. It also uses these functions internally to provide sane defaults for the
texture and associated classes.
Returns the number of color channel components
Returns a suitable pixel format to upload to the internal format
Returns a suitable pixel type to upload to the internal format
Returns the number of octets per pixel
Infer an appropriate internal format from a pixel type and format
Infer an appropriate swizzling method for a given pixel type
Infer an appropriate swizzling method for a given list of used channels
Infer an appropriate pixel type for a given depth and base type
Convert the pixel type to an appropriate cl type to use as backing storage