WebGLRenderingContext.getParameter()

The WebGLRenderingContext.getParameter() method of the WebGL API returns a value for the passed parameter name.

Syntax

any gl.getParameter(pname);

Parameters

pname
A GLenum specifying which parameter value to return. See below for possible values.

Return value

Depends on the parameter.

Parameter names

WebGL 1

You can query the following pname parameters when using a WebGLRenderingContext.

Constant Returned type Description
gl.ACTIVE_TEXTURE GLenum  
gl.ALIASED_LINE_WIDTH_RANGE Float32Array (with 2 elements)  
gl.ALIASED_POINT_SIZE_RANGE Float32Array (with 2 elements)  
gl.ALPHA_BITS GLint  
gl.ARRAY_BUFFER_BINDING WebGLBuffer  
gl.BLEND GLboolean  
gl.BLEND_COLOR Float32Array (with 4 values)  
gl.BLEND_DST_ALPHA GLenum  
gl.BLEND_DST_RGB GLenum  
gl.BLEND_EQUATION GLenum  
gl.BLEND_EQUATION_ALPHA GLenum  
gl.BLEND_EQUATION_RGB GLenum  
gl.BLEND_SRC_ALPHA GLenum  
gl.BLEND_SRC_RGB GLenum  
gl.BLUE_BITS GLint  
gl.COLOR_CLEAR_VALUE Float32Array (with 4 values)  
gl.COLOR_WRITEMASK sequence<GLboolean> (with 4 values)  
gl.COMPRESSED_TEXTURE_FORMATS Uint32Array Returns the compressed texture formats.

When using the WEBGL_compressed_texture_s3tc extension:
  • ext.COMPRESSED_RGB_S3TC_DXT1_EXT
  • ext.COMPRESSED_RGBA_S3TC_DXT1_EXT
  • ext.COMPRESSED_RGBA_S3TC_DXT3_EXT
  • ext.COMPRESSED_RGBA_S3TC_DXT5_EXT
When using the WEBGL_compressed_texture_es3 extension:
  • ext.COMPRESSED_R11_EAC
  • ext.COMPRESSED_SIGNED_R11_EAC
  • ext.COMPRESSED_RG11_EAC
  • ext.COMPRESSED_SIGNED_RG11_EAC
  • ext.COMPRESSED_RGB8_ETC2
  • ext.COMPRESSED_RGBA8_ETC2_EAC
  • ext.COMPRESSED_SRGB8_ETC2
  • ext.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
  • ext.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
  • ext.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2
When using the WEBGL_compressed_texture_pvrtc extension:
  • ext.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
  • ext.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
  • ext.COMPRESSED_RGB_PVRTC_2BPPV1_IMG
  • ext.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
When using the WEBGL_compressed_texture_etc1 extension:
  • ext.COMPRESSED_RGB_ETC1_WEBGL
When using the WEBGL_compressed_texture_atc extension:
  • ext.COMPRESSED_RGB_ATC_WEBGL
  • ext.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL
  • ext.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL
gl.CULL_FACE GLboolean  
gl.CULL_FACE_MODE GLenum  
gl.CURRENT_PROGRAM WebGLProgram  
gl.DEPTH_BITS GLint  
gl.DEPTH_CLEAR_VALUE GLfloat  
gl.DEPTH_FUNC GLenum  
gl.DEPTH_RANGE Float32Array (with 2 elements)  
gl.DEPTH_TEST GLboolean  
gl.DEPTH_WRITEMASK GLboolean  
gl.DITHER GLboolean  
gl.ELEMENT_ARRAY_BUFFER_BINDING WebGLBuffer  
gl.FRAMEBUFFER_BINDING WebGLFramebuffer  
gl.FRONT_FACE GLenum  
gl.GENERATE_MIPMAP_HINT GLenum  
gl.GREEN_BITS GLint  
gl.IMPLEMENTATION_COLOR_READ_FORMAT GLenum  
gl.IMPLEMENTATION_COLOR_READ_TYPE GLenum  
gl.LINE_WIDTH GLfloat  
gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS GLint  
gl.MAX_CUBE_MAP_TEXTURE_SIZE GLint  
gl.MAX_FRAGMENT_UNIFORM_VECTORS GLint  
gl.MAX_RENDERBUFFER_SIZE GLint  
gl.MAX_TEXTURE_IMAGE_UNITS GLint  
gl.MAX_TEXTURE_SIZE GLint  
gl.MAX_VARYING_VECTORS GLint  
gl.MAX_VERTEX_ATTRIBS GLint  
gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS GLint  
gl.MAX_VERTEX_UNIFORM_VECTORS GLint  
gl.MAX_VIEWPORT_DIMS Int32Array (with 2 elements)  
gl.PACK_ALIGNMENT GLint  
gl.POLYGON_OFFSET_FACTOR GLfloat  
gl.POLYGON_OFFSET_FILL GLboolean  
gl.POLYGON_OFFSET_UNITS GLfloat  
gl.RED_BITS GLint  
gl.RENDERBUFFER_BINDING WebGLRenderbuffer  
gl.RENDERER DOMString  
gl.SAMPLE_BUFFERS GLint  
gl.SAMPLE_COVERAGE_INVERT GLboolean  
gl.SAMPLE_COVERAGE_VALUE GLfloat  
gl.SAMPLES GLint  
gl.SCISSOR_BOX Int32Array (with 4 elements)  
gl.SCISSOR_TEST GLboolean  
gl.SHADING_LANGUAGE_VERSION DOMString  
gl.STENCIL_BACK_FAIL GLenum  
gl.STENCIL_BACK_FUNC GLenum  
gl.STENCIL_BACK_PASS_DEPTH_FAIL GLenum  
gl.STENCIL_BACK_PASS_DEPTH_PASS GLenum  
gl.STENCIL_BACK_REF GLint  
gl.STENCIL_BACK_VALUE_MASK GLuint  
gl.STENCIL_BACK_WRITEMASK GLuint  
gl.STENCIL_BITS GLint  
gl.STENCIL_CLEAR_VALUE GLint  
gl.STENCIL_FAIL GLenum  
gl.STENCIL_FUNC GLenum  
gl.STENCIL_PASS_DEPTH_FAIL GLenum  
gl.STENCIL_PASS_DEPTH_PASS GLenum  
gl.STENCIL_REF GLint  
gl.STENCIL_TEST GLboolean  
gl.STENCIL_VALUE_MASK GLuint  
gl.STENCIL_WRITEMASK GLuint  
gl.SUBPIXEL_BITS GLint  
gl.TEXTURE_BINDING_2D WebGLTexture  
gl.TEXTURE_BINDING_CUBE_MAP WebGLTexture  
gl.UNPACK_ALIGNMENT GLint  
gl.UNPACK_COLORSPACE_CONVERSION_WEBGL GLenum  
gl.UNPACK_FLIP_Y_WEBGL GLboolean  
gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL GLboolean  
gl.VENDOR DOMString  
gl.VERSION DOMString  
gl.VIEWPORT Int32Array (with 4 elements)  

WebGL 2

You can query the following pname parameters when using a WebGL2RenderingContext.

Constant Returned type Description
gl.COPY_READ_BUFFER_BINDING WebGLBuffer  
gl.COPY_WRITE_BUFFER_BINDING WebGLBuffer  
gl.DRAW_BUFFERi GLenum  
gl.DRAW_FRAMEBUFFER_BINDING WebGLFramebuffer  
gl.FRAGMENT_SHADER_DERIVATIVE_HINT GLenum  
gl.MAX_3D_TEXTURE_SIZE GLint  
gl.MAX_ARRAY_TEXTURE_LAYERS GLint  
gl.MAX_CLIENT_WAIT_TIMEOUT_WEBGL GLint64  
gl.MAX_COLOR_ATTACHMENTS GLint  
gl.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS GLint64  
gl.MAX_COMBINED_UNIFORM_BLOCKS GLint  
gl.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS GLint64  
gl.MAX_DRAW_BUFFERS GLint  
gl.MAX_ELEMENT_INDEX GLint64  
gl.MAX_ELEMENTS_INDICES GLint  
gl.MAX_ELEMENTS_VERTICES GLint  
gl.MAX_FRAGMENT_INPUT_COMPONENTS GLint  
gl.MAX_FRAGMENT_UNIFORM_BLOCKS GLint  
gl.MAX_FRAGMENT_UNIFORM_COMPONENTS GLint  
gl.MAX_PROGRAM_TEXEL_OFFSET GLint  
gl.MAX_SAMPLES GLint  
gl.MAX_SERVER_WAIT_TIMEOUT GLint64  
gl.MAX_TEXTURE_LOD_BIAS GLfloat  
gl.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS GLint  
gl.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS GLint  
gl.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS GLint  
gl.MAX_UNIFORM_BLOCK_SIZE GLint64  
gl.MAX_UNIFORM_BUFFER_BINDINGS GLint  
gl.MAX_VARYING_COMPONENTS GLint  
gl.MAX_VERTEX_OUTPUT_COMPONENTS GLint  
gl.MAX_VERTEX_UNIFORM_BLOCKS GLint  
gl.MAX_VERTEX_UNIFORM_COMPONENTS GLint  
gl.MIN_PROGRAM_TEXEL_OFFSET GLint  
gl.PACK_ROW_LENGTH GLint  
gl.PACK_SKIP_PIXELS GLint  
gl.PACK_SKIP_ROWS GLint  
gl.PIXEL_PACK_BUFFER_BINDING WebGLBuffer  
gl.PIXEL_UNPACK_BUFFER_BINDING WebGLBuffer  
gl.RASTERIZER_DISCARD GLboolean  
gl.READ_BUFFER GLenum  
gl.READ_FRAMEBUFFER_BINDING WebGLFramebuffer  
gl.SAMPLE_ALPHA_TO_COVERAGE GLboolean  
gl.SAMPLE_COVERAGE GLboolean  
gl.SAMPLER_BINDING WebGLSampler  
gl.TEXTURE_BINDING_2D_ARRAY WebGLTexture  
gl.TEXTURE_BINDING_3D WebGLTexture  
gl.TRANSFORM_FEEDBACK_ACTIVE GLboolean  
gl.TRANSFORM_FEEDBACK_BINDING WebGLTransformFeedback  
gl.TRANSFORM_FEEDBACK_BUFFER_BINDING WebGLBuffer  
gl.TRANSFORM_FEEDBACK_PAUSED GLboolean  
gl.UNIFORM_BUFFER_BINDING WebGLBuffer  
gl.UNIFORM_BUFFER_OFFSET_ALIGNMENT GLint  
gl.UNPACK_IMAGE_HEIGHT GLint  
gl.UNPACK_ROW_LENGTH GLint  
gl.UNPACK_SKIP_IMAGES GLint  
gl.UNPACK_SKIP_PIXELS GLint  
gl.UNPACK_SKIP_ROWS GLint  
gl.VERTEX_ARRAY_BINDING WebGLVertexArrayObject  

WebGL extensions

You can query the following pname parameters when using WebGL extensions:

Constant Returned type Extension Description
ext.MAX_TEXTURE_MAX_ANISOTROPY_EXT GLfloat EXT_texture_filter_anisotropic Maximum available anisotropy.
ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES GLenum OES_standard_derivatives Accuracy of the derivative calculation for the GLSL built-in functions: dFdx, dFdy, and fwidth.
ext.MAX_COLOR_ATTACHMENTS_WEBGL GLint WEBGL_draw_buffers The maximum number of framebuffer color attachment points.
ext.MAX_DRAW_BUFFERS_WEBGL GLint WEBGL_draw_buffers The maximum number of draw buffers.
ext.DRAW_BUFFER0_WEBGL
ext.DRAW_BUFFER1_WEBGL
ext.DRAW_BUFFER2_WEBGL
ext.DRAW_BUFFER3_WEBGL
ext.DRAW_BUFFER4_WEBGL
ext.DRAW_BUFFER5_WEBGL
ext.DRAW_BUFFER6_WEBGL
ext.DRAW_BUFFER7_WEBGL
ext.DRAW_BUFFER8_WEBGL
ext.DRAW_BUFFER9_WEBGL
ext.DRAW_BUFFER10_WEBGL
ext.DRAW_BUFFER11_WEBGL
ext.DRAW_BUFFER12_WEBGL
ext.DRAW_BUFFER13_WEBGL
ext.DRAW_BUFFER14_WEBGL
ext.DRAW_BUFFER15_WEBGL
GLenum WEBGL_draw_buffers Drawing buffers.
ext.VERTEX_ARRAY_BINDING_OES WebGLVertexArrayObjectOES OES_vertex_array_object Bound vertex array object (VAO).
ext.TIMESTAMP_EXT GLuint64EXT

EXT_disjoint_timer_query

The current time.
ext.GPU_DISJOINT_EXT GLboolean EXT_disjoint_timer_query

Returns whether or not the GPU performed any disjoint operation.

Examples

gl.getParameter(gl.DITHER);
gl.getParameter(gl.VERSION);
gl.getParameter(gl.VIEWPORT);

Specifications

Specification Status Comment
WebGL 1.0
The definition of 'getParameter' in that specification.
Recommendation Initial definition.
WebGL 2.0
The definition of 'getParameter' in that specification.
Editor's Draft Adds additional parameter names.
OpenGL ES 2.0
The definition of 'glGet' in that specification.
Standard Man page of the (similar) OpenGL API.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 9 4.0 (2.0) 11 12 5.1
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? 25 (Yes) ? 12 8.1

See also

Document Tags and Contributors

 Contributors to this page: fscholz
 Last updated by: fscholz,