OpenGL ES 3.0 maintains “state information” that includes the values of internal variables required for rendering. You’ll need to compile and link shader programs, initialize vertex arrays and attribute bindings, specify uniform values, and probably load and bind texture—and that only scratches the surface.
There are also a large number of values that are intrinsic to OpenGL ES 3.0’s operation. You might need to determine the maximum size of viewport that is supported or the maximum number of texture units, for example. All of those values can be queried by your application.
This chapter describes the functions your applications can use to obtain values from OpenGL ES 3.0, and the parameters that you can query.
One of the most fundamental queries that you will need to perform in your (well-written) applications is to obtain information about the underlying OpenGL ES 3.0 implementation, such as which version of OpenGL ES is supported, whose implementation it is, and which extensions are available. These characteristics are all returned as ASCII strings from the glGetString
function.
The GL_VENDOR
and GL_RENDERER
queries are formatted for human consumption and have no set format; they are initialized with whatever the implementer felt were useful descriptions.
The GL_VERSION
query will return a string starting with “OpenGL ES 3.0” for all OpenGL ES 3.0 implementations. The version string can additionally include vendor-specific information after those tokens, and will always have the following format:
OpenGL ES <version> <vendor-specific information>
with <version>
being the version number (e.g., 3.0), composed of a major release number, followed by a period and the minor release number, and optionally another period and a tertiary release value (often used by vendors to represent an OpenGL ES 3.0 driver’s revision number).
Likewise, the GL_SHADING_LANGUAGE_VERSION
query will always return a string starting with “OpenGL ES GLSL ES 3.00.” This string can also have vendor-specific information appended to it, and will take the following form:
OpenGL ES GLSL ES <version> <vendor-specific information>
with a similar formatting for the <version>
value.
Implementations that support OpenGL ES 3.0 must also support OpenGL ES GLSL ES 1.00.
When OpenGL ES is updated to the next version, these version numbers will change accordingly.
Finally, the GL_EXTENSIONS
query will return a space-separated list of all extensions supported by the implementation, or the NULL
string if the implementation is not extended.
Many rendering parameters depend on the underlying capabilities of the OpenGL ES implementation—for example, how many texture units are available to a shader, or what the maximum size for a texture map or aliased point is. Values of those types are queried using one of the functions shown here:
A number of implementation-dependent parameters can be queried, as listed in Table 15-1.
Your application can modify many parameters to affect OpenGL ES 3.0’s operation. Although it’s usually more efficient for an application to track these values when it modifies them, you can retrieve any of the values listed in Table 15-2 from the currently bound context. For each token, the appropriate OpenGL ES 3.0 get function is provided.
OpenGL ES 3.0 uses hints to modify the operation of features, allowing a bias toward either performance or quality. You can specify a preference by calling the following function:
The current value of any hint can be retrieved by calling glGetIntegerv
using the appropriate hint enumerated value.
OpenGL ES 3.0 references numerous entities that you define—textures, shaders, programs, vertex buffers, sampler objects, query objects, sync objects, vertex array objects, transform feedback objects, framebuffers, and renderbuffers—by integer names. You can determine if a name is currently in use (and therefore a valid entity) by calling one of the following functions:
Much of OpenGL ES 3.0’s rasterization functionality, like blending or back-face culling, is controlled by turning on and off the features you need. The functions controlling the various operations are mentioned here.
Additionally, you can determine if a feature is in use by calling the following function:
The capabilities controlled by glEnable
and glDisable
are listed in Table 15-3.
OpenGL ES 3.0 shaders and programs have a considerable amount of state information that you can retrieve regarding their configuration, and the attributes and uniform variables used by them. Numerous functions are provided for querying the state associated with shaders. To determine the shaders attached to a program, call the following function:
To retrieve the source code for a shader, call the following function:
To retrieve a value associated with a uniform variable at a particular uniform location associated with a shader program, call the following function:
Finally, to query the range and precision of OpenGL ES 3.0 shader language types, call the following function:
State information for vertex attribute arrays can also be retrieved from the current OpenGL ES 3.0 context. To obtain the pointer to the current generic vertex attributes for a specific index, call the following function:
The associated state for accessing the data elements in the vertex attribute array, such as value type or stride, can be obtained by calling the following function:
OpenGL ES 3.0 texture objects store a texture’s image data, along with settings describing how the texels in the image should be sampled. The texture filter state, which includes the minification and magnification texture filters and texture-coordinate wrap modes, can be queried from the currently bound texture object. The following call retrieves the texture filter settings:
State information for sampler objects can be retrieved from the current OpenGL ES 3.0 context by calling the following function:
Information about a query object can be retrieved from the current OpenGL ES 3.0 context by calling the following function:
The state of a query object can be retrieved by calling the following function:
The properties of a sync object can be retrieved from the current OpenGL ES 3.0 context by calling the following function:
Vertex buffer objects have associated state information describing the state and usage of the buffer. Those parameters can be retrieved by calling the following function:
Additionally, you can retrieve the current pointer address for a mapped buffer by calling the following function:
Characteristics of an allocated renderbuffer can be retrieved by calling the following function:
Likewise, the current attachments to a framebuffer can be queried by calling the following function:
As there is a large amount of state information in OpenGL ES 3.0, in this chapter we provided a reference for the various state queries that your applications can make. Next, in the final chapter you will learn how to build the OpenGL ES sample code in this book for various OpenGL ES platforms.