WebGLRenderingContext.getParameter() 方法在 WebGL API returns a value for the passed parameter name.

句法

any gl.getParameter(pname);
			

参数

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

返回值

Depends on the parameter.

Parameter names

WebGL 1

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

常量 Returned type 描述
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.

当使用 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

当使用 WEBGL_compressed_texture_s3tc_srgb extension:

  • ext.COMPRESSED_SRGB_S3TC_DXT1_EXT
  • ext.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
  • ext.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
  • ext.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
当使用 WEBGL_compressed_texture_etc 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
当使用 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
当使用 WEBGL_compressed_texture_etc1 extension:
  • ext.COMPRESSED_RGB_ETC1_WEBGL
当使用 WEBGL_compressed_texture_atc extension:
  • ext.COMPRESSED_RGB_ATC_WEBGL
  • ext.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL
  • ext.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL
当使用 WEBGL_compressed_texture_astc extension:
  • ext.COMPRESSED_RGBA_ASTC_4x4_KHR
  • ext.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR
  • ext.COMPRESSED_RGBA_ASTC_5x4_KHR
  • ext.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR
  • ext.COMPRESSED_RGBA_ASTC_5x5_KHR
  • ext.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR
  • ext.COMPRESSED_RGBA_ASTC_6x5_KHR
  • ext.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR
  • ext.COMPRESSED_RGBA_ASTC_6x6_KHR
  • ext.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR
  • ext.COMPRESSED_RGBA_ASTC_8x5_KHR
  • ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR
  • ext.COMPRESSED_RGBA_ASTC_8x6_KHR
  • ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR
  • ext.COMPRESSED_RGBA_ASTC_8x8_KHR
  • ext.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR
  • ext.COMPRESSED_RGBA_ASTC_10x5_KHR
  • ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR
  • ext.COMPRESSED_RGBA_ASTC_10x6_KHR
  • ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR
  • ext.COMPRESSED_RGBA_ASTC_10x6_KHR
  • ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR
  • ext.COMPRESSED_RGBA_ASTC_10x10_KHR
  • ext.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR
  • ext.COMPRESSED_RGBA_ASTC_12x10_KHR
  • ext.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR
  • ext.COMPRESSED_RGBA_ASTC_12x12_KHR
  • ext.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
gl.CULL_FACE GLboolean
gl.CULL_FACE_MODE GLenum gl.FRONT , gl.BACK or gl.FRONT_AND_BACK 。另请参阅 cullFace
gl.CURRENT_PROGRAM WebGLProgram or null useProgram .
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 or null null corresponds to a binding to the default framebuffer. See also bindFramebuffer .
gl.FRONT_FACE GLenum gl.CW or gl.CCW 。另请参阅 frontFace .
gl.GENERATE_MIPMAP_HINT GLenum gl.FASTEST , gl.NICEST or gl.DONT_CARE 。另请参阅 hint .
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 or null bindRenderbuffer .
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 or null
gl.TEXTURE_BINDING_CUBE_MAP WebGLTexture or null
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 .

常量 Returned type 描述
gl.COPY_READ_BUFFER_BINDING WebGLBuffer or null bindBuffer .
gl.COPY_WRITE_BUFFER_BINDING WebGLBuffer or null bindBuffer .
gl.DRAW_BUFFER i GLenum gl.BACK , gl.NONE or gl.COLOR_ATTACHMENT{0-15} 。另请参阅 drawBuffers .
gl.DRAW_FRAMEBUFFER_BINDING WebGLFramebuffer or null null corresponds to a binding to the default framebuffer. See also bindFramebuffer .
gl.FRAGMENT_SHADER_DERIVATIVE_HINT GLenum gl.FASTEST , gl.NICEST or gl.DONT_CARE 。另请参阅 hint .
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 pixelStorei .
gl.PACK_SKIP_PIXELS GLint pixelStorei .
gl.PACK_SKIP_ROWS GLint pixelStorei .
gl.PIXEL_PACK_BUFFER_BINDING WebGLBuffer or null bindBuffer .
gl.PIXEL_UNPACK_BUFFER_BINDING WebGLBuffer or null bindBuffer .
gl.RASTERIZER_DISCARD GLboolean
gl.READ_BUFFER GLenum
gl.READ_FRAMEBUFFER_BINDING WebGLFramebuffer or null null corresponds to a binding to the default framebuffer. See also bindFramebuffer .
gl.SAMPLE_ALPHA_TO_COVERAGE GLboolean
gl.SAMPLE_COVERAGE GLboolean
gl.SAMPLER_BINDING WebGLSampler or null bindSampler .
gl.TEXTURE_BINDING_2D_ARRAY WebGLTexture or null bindTexture .
gl.TEXTURE_BINDING_3D WebGLTexture or null bindTexture .
gl.TRANSFORM_FEEDBACK_ACTIVE GLboolean
gl.TRANSFORM_FEEDBACK_BINDING WebGLTransformFeedback or null bindTransformFeedback .
gl.TRANSFORM_FEEDBACK_BUFFER_BINDING WebGLBuffer or null bindBuffer .
gl.TRANSFORM_FEEDBACK_PAUSED GLboolean
gl.UNIFORM_BUFFER_BINDING WebGLBuffer or null bindBuffer .
gl.UNIFORM_BUFFER_OFFSET_ALIGNMENT GLint pixelStorei .
gl.UNPACK_IMAGE_HEIGHT GLint pixelStorei .
gl.UNPACK_ROW_LENGTH GLint pixelStorei .
gl.UNPACK_SKIP_IMAGES GLint pixelStorei .
gl.UNPACK_SKIP_PIXELS GLint pixelStorei .
gl.UNPACK_SKIP_ROWS GLint pixelStorei .
gl.VERTEX_ARRAY_BINDING WebGLVertexArrayObject or null bindVertexArray .

WebGL extensions

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

常量 Returned type Extension 描述
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 ,和 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.
ext.MAX_VIEWS_OVR GLint OVR_multiview2 Maximum number of views.

范例

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

规范

规范 状态 注释
WebGL 1.0
The definition of 'getParameter' in that specification.
推荐 初始定义。
WebGL 2.0
The definition of 'getParameter' in that specification.
编者草案 Adds additional parameter names.
OpenGL ES 2.0
The definition of 'glGet' in that specification.
标准 Man page of the (similar) OpenGL API.

浏览器兼容性

更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
getParameter Chrome 9 Edge 12 Firefox 4 IE 11 Opera 12 Safari 5.1 WebView Android Yes Chrome Android 25 Firefox Android Yes Opera Android 12 Safari iOS 8 Samsung Internet Android 1.5

图例

完整支持

另请参阅

元数据

  1. WebGL API
  2. WebGLRenderingContext
  3. 特性
    1. canvas
    2. drawingBufferHeight
    3. drawingBufferWidth
  4. 方法
    1. activeTexture()
    2. attachShader()
    3. bindAttribLocation()
    4. bindBuffer()
    5. bindFramebuffer()
    6. bindRenderbuffer()
    7. bindTexture()
    8. blendColor()
    9. blendEquation()
    10. blendEquationSeparate()
    11. blendFunc()
    12. blendFuncSeparate()
    13. bufferData()
    14. bufferSubData()
    15. checkFramebufferStatus()
    16. clear()
    17. clearColor()
    18. clearDepth()
    19. clearStencil()
    20. colorMask()
    21. commit()
    22. compileShader()
    23. compressedTexImage[23]D()
    24. compressedTexSubImage2D()
    25. copyTexImage2D()
    26. copyTexSubImage2D()
    27. createBuffer()
    28. createFramebuffer()
    29. createProgram()
    30. createRenderbuffer()
    31. createShader()
    32. createTexture()
    33. cullFace()
    34. deleteBuffer()
    35. deleteFramebuffer()
    36. deleteProgram()
    37. deleteRenderbuffer()
    38. deleteShader()
    39. deleteTexture()
    40. depthFunc()
    41. depthMask()
    42. depthRange()
    43. detachShader()
    44. disable()
    45. disableVertexAttribArray()
    46. drawArrays()
    47. drawElements()
    48. enable()
    49. enableVertexAttribArray()
    50. finish()
    51. flush()
    52. framebufferRenderbuffer()
    53. framebufferTexture2D()
    54. frontFace()
    55. generateMipmap()
    56. getActiveAttrib()
    57. getActiveUniform()
    58. getAttachedShaders()
    59. getAttribLocation()
    60. getBufferParameter()
    61. getContextAttributes()
    62. getError()
    63. getExtension()
    64. getFramebufferAttachmentParameter()
    65. getParameter()
    66. getProgramInfoLog()
    67. getProgramParameter()
    68. getRenderbufferParameter()
    69. getShaderInfoLog()
    70. getShaderParameter()
    71. getShaderPrecisionFormat()
    72. getShaderSource()
    73. getSupportedExtensions()
    74. getTexParameter()
    75. getUniform()
    76. getUniformLocation()
    77. getVertexAttrib()
    78. getVertexAttribOffset()
    79. hint()
    80. isBuffer()
    81. isContextLost()
    82. isEnabled()
    83. isFramebuffer()
    84. isProgram()
    85. isRenderbuffer()
    86. isShader()
    87. isTexture()
    88. lineWidth()
    89. linkProgram()
    90. pixelStorei()
    91. polygonOffset()
    92. readPixels()
    93. renderbufferStorage()
    94. sampleCoverage()
    95. scissor()
    96. shaderSource()
    97. stencilFunc()
    98. stencilFuncSeparate()
    99. stencilMask()
    100. stencilMaskSeparate()
    101. stencilOp()
    102. stencilOpSeparate()
    103. texImage2D()
    104. texParameter[fi]()
    105. texSubImage2D()
    106. uniform[1234][fi][v]()
    107. uniformMatrix[234]fv()
    108. useProgram()
    109. validateProgram()
    110. vertexAttrib[1234]f[v]()
    111. vertexAttribPointer()
    112. viewport()
  5. WebGL 相关页面
    1. ANGLE_instanced_arrays
    2. EXT_blend_minmax
    3. EXT_color_buffer_half_float
    4. EXT_disjoint_timer_query
    5. EXT_frag_depth
    6. EXT_sRGB
    7. EXT_shader_texture_lod
    8. EXT_texture_filter_anisotropic
    9. OES_element_index_uint
    10. OES_standard_derivatives
    11. OES_texture_float
    12. OES_texture_float_linear
    13. OES_texture_half_float
    14. OES_texture_half_float_linear
    15. OES_vertex_array_object
    16. WEBGL_color_buffer_float
    17. WEBGL_compressed_texture_atc
    18. WEBGL_compressed_texture_etc1
    19. WEBGL_compressed_texture_pvrtc
    20. WEBGL_compressed_texture_s3tc
    21. WEBGL_compressed_texture_s3tc_srgb
    22. WEBGL_debug_renderer_info
    23. WEBGL_debug_shaders
    24. WEBGL_depth_texture
    25. WEBGL_draw_buffers
    26. WEBGL_lose_context
    27. WebGL2RenderingContext
    28. WebGLActiveInfo
    29. WebGLBuffer
    30. WebGLContextEvent
    31. WebGLFramebuffer
    32. WebGLObject
    33. WebGLProgram
    34. WebGLQuery
    35. WebGLRenderbuffer
    36. WebGLSampler
    37. WebGLShader
    38. WebGLShaderPrecisionFormat
    39. WebGLSync
    40. WebGLTexture
    41. WebGLTransformFeedback
    42. WebGLUniformLocation
    43. WebGLVertexArrayObject