mirror of
https://github.com/visgl/luma.gl.git
synced 2025-12-08 17:36:19 +00:00
GL
Starting from v9, the luma.gl API uses strings instead of GL constants to specify parameters, formats etc, effectively eliminating the need for importing the
@luma.gl/constantsmodule
The @luma.gl/constants module has a single export:
a (big) enum GL that contains all WebGL constants (i.e. the OpenGL API constants).
Usage
import GL from '@luma.gl/constants';
const type = GL.POINTS;
Remarks
- While
GLconstants are exposed on theWebGLRenderingContextinstance, it is often convenient to be able to reference them in code that does not have access to a WebGL context. - A range of constants provided by this module are not available on the WebGL context itself, but would otherwise have to be retrieved from WebGL extension objects.
- Using the GL module ensures that WebGL 2 constants are defined even when working with a WebGL 1 context.
Bundle Size Considerations
Including a big enumeration containing many constants your application might not even be using
does add to your applications bundle size. luma.gl offers a babel plugin that can inline the
GL constants, typically resulting in smaller bundle size than if you used built-in gl.<constants>
on your WebGLRenderingContext directly.