Exhibit #2: Getting Info about WebGL Context
Parameters
Extensions
What We Did
- The WebGL context has a number of constant fields. You can access them in two ways.
Let's try this out in the console.
-
Some of these constants are names for the parameters of the WebGL context.
Some parameters indicate the limit of what the context can do.
- How large can a texture be?
- How many textures can you use at the same time?
- How many uniforms for varying variables you can use in your program?
- etc.
- To get the values of these parameters, use
gl.getParameter( ... intert-parameter-constant ... )
.
For example,
gl.getParameter(gl.MAX_TEXTURE_SIZE)
gl.getParameter(gl["MAX_TEXTURE_SIZE"])
-
The WebGL implementation on your terminal might support extensions.
An extension is a set of functionality that is not part of the official WebGL specification.
It is disabled by default. You have to turn it on to use it.
-
To get the names of supported extensions, use
gl.getSupportedExtensions()
.