WebGLRenderingContext.getParameter() - Web APIs 编辑

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.

ConstantReturned typeDescription
gl.ACTIVE_TEXTUREGLenum
gl.ALIASED_LINE_WIDTH_RANGEFloat32Array (with 2 elements)
gl.ALIASED_POINT_SIZE_RANGEFloat32Array (with 2 elements)
gl.ALPHA_BITSGLint
gl.ARRAY_BUFFER_BINDINGWebGLBuffer
gl.BLENDGLboolean
gl.BLEND_COLORFloat32Array (with 4 values)
gl.BLEND_DST_ALPHAGLenum
gl.BLEND_DST_RGBGLenum
gl.BLEND_EQUATIONGLenum
gl.BLEND_EQUATION_ALPHAGLenum
gl.BLEND_EQUATION_RGBGLenum
gl.BLEND_SRC_ALPHAGLenum
gl.BLEND_SRC_RGBGLenum
gl.BLUE_BITSGLint
gl.COLOR_CLEAR_VALUEFloat32Array (with 4 values)
gl.COLOR_WRITEMASKsequence<GLboolean> (with 4 values)
gl.COMPRESSED_TEXTURE_FORMATSUint32ArrayReturns 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_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
When using the 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
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
When using the 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_FACEGLboolean
gl.CULL_FACE_MODEGLenumgl.FRONT, gl.BACK or gl.FRONT_AND_BACK. See also cullFace
gl.CURRENT_PROGRAMWebGLProgram or nullSee useProgram.
gl.DEPTH_BITSGLint
gl.DEPTH_CLEAR_VALUEGLfloat
gl.DEPTH_FUNCGLenum
gl.DEPTH_RANGEFloat32Array (with 2 elements)
gl.DEPTH_TESTGLboolean
gl.DEPTH_WRITEMASKGLboolean
gl.DITHERGLboolean
gl.ELEMENT_ARRAY_BUFFER_BINDINGWebGLBuffer
gl.FRAMEBUFFER_BINDINGWebGLFramebuffer or nullnull corresponds to a binding to the default framebuffer. See also bindFramebuffer.
gl.FRONT_FACEGLenumgl.CW or gl.CCW. See also frontFace.
gl.GENERATE_MIPMAP_HINTGLenumgl.FASTEST, gl.NICEST or gl.DONT_CARE. See also hint.
gl.GREEN_BITSGLint
gl.IMPLEMENTATION_COLOR_READ_FORMATGLenum
gl.IMPLEMENTATION_COLOR_READ_TYPEGLenum
gl.LINE_WIDTHGLfloat
gl.MAX_COMBINED_TEXTURE_IMAGE_UNITSGLint
gl.MAX_CUBE_MAP_TEXTURE_SIZEGLint
gl.MAX_FRAGMENT_UNIFORM_VECTORSGLint
gl.MAX_RENDERBUFFER_SIZEGLint
gl.MAX_TEXTURE_IMAGE_UNITSGLint
gl.MAX_TEXTURE_SIZEGLint
gl.MAX_VARYING_VECTORSGLint
gl.MAX_VERTEX_ATTRIBSGLint
gl.MAX_VERTEX_TEXTURE_IMAGE_UNITSGLint
gl.MAX_VERTEX_UNIFORM_VECTORSGLint
gl.MAX_VIEWPORT_DIMSInt32Array (with 2 elements)
gl.PACK_ALIGNMENTGLint
gl.POLYGON_OFFSET_FACTORGLfloat
gl.POLYGON_OFFSET_FILLGLboolean
gl.POLYGON_OFFSET_UNITSGLfloat
gl.RED_BITSGLint
gl.RENDERBUFFER_BINDINGWebGLRenderbuffer or nullSee bindRenderbuffer.
gl.RENDERERDOMString
gl.SAMPLE_BUFFERSGLint
gl.SAMPLE_COVERAGE_INVERTGLboolean
gl.SAMPLE_COVERAGE_VALUEGLfloat
gl.SAMPLESGLint
gl.SCISSOR_BOXInt32Array (with 4 elements)
gl.SCISSOR_TESTGLboolean
gl.SHADING_LANGUAGE_VERSIONDOMString
gl.STENCIL_BACK_FAILGLenum
gl.STENCIL_BACK_FUNCGLenum
gl.STENCIL_BACK_PASS_DEPTH_FAILGLenum
gl.STENCIL_BACK_PASS_DEPTH_PASSGLenum
gl.STENCIL_BACK_REFGLint
gl.STENCIL_BACK_VALUE_MASKGLuint
gl.STENCIL_BACK_WRITEMASKGLuint
gl.STENCIL_BITSGLint
gl.STENCIL_CLEAR_VALUEGLint
gl.STENCIL_FAILGLenum
gl.STENCIL_FUNCGLenum
gl.STENCIL_PASS_DEPTH_FAILGLenum
gl.STENCIL_PASS_DEPTH_PASSGLenum
gl.STENCIL_REFGLint
gl.STENCIL_TESTGLboolean
gl.STENCIL_VALUE_MASKGLuint
gl.STENCIL_WRITEMASKGLuint
gl.SUBPIXEL_BITSGLint
gl.TEXTURE_BINDING_2DWebGLTexture or null
gl.TEXTURE_BINDING_CUBE_MAPWebGLTexture or null
gl.UNPACK_ALIGNMENTGLint
gl.UNPACK_COLORSPACE_CONVERSION_WEBGLGLenum
gl.UNPACK_FLIP_Y_WEBGLGLboolean
gl.UNPACK_PREMULTIPLY_ALPHA_WEBGLGLboolean
gl.VENDORDOMString
gl.VERSIONDOMString
gl.VIEWPORTInt32Array (with 4 elements)

WebGL 2

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

ConstantReturned typeDescription
gl.COPY_READ_BUFFER_BINDINGWebGLBuffer or nullSee bindBuffer.
gl.COPY_WRITE_BUFFER_BINDINGWebGLBuffer or nullSee bindBuffer.
gl.DRAW_BUFFERiGLenumgl.BACK, gl.NONE or gl.COLOR_ATTACHMENT{0-15}. See also drawBuffers.
gl.DRAW_FRAMEBUFFER_BINDINGWebGLFramebuffer or nullnull corresponds to a binding to the default framebuffer. See also bindFramebuffer.
gl.FRAGMENT_SHADER_DERIVATIVE_HINTGLenumgl.FASTEST, gl.NICEST or gl.DONT_CARE. See also hint.
gl.MAX_3D_TEXTURE_SIZEGLint
gl.MAX_ARRAY_TEXTURE_LAYERSGLint
gl.MAX_CLIENT_WAIT_TIMEOUT_WEBGLGLint64
gl.MAX_COLOR_ATTACHMENTSGLint
gl.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTSGLint64
gl.MAX_COMBINED_UNIFORM_BLOCKSGLint
gl.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTSGLint64
gl.MAX_DRAW_BUFFERSGLint
gl.MAX_ELEMENT_INDEXGLint64
gl.MAX_ELEMENTS_INDICESGLint
gl.MAX_ELEMENTS_VERTICESGLint
gl.MAX_FRAGMENT_INPUT_COMPONENTSGLint
gl.MAX_FRAGMENT_UNIFORM_BLOCKSGLint
gl.MAX_FRAGMENT_UNIFORM_COMPONENTSGLint
gl.MAX_PROGRAM_TEXEL_OFFSETGLint
gl.MAX_SAMPLESGLint
gl.MAX_SERVER_WAIT_TIMEOUTGLint64
gl.MAX_TEXTURE_LOD_BIASGLfloat
gl.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTSGLint
gl.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBSGLint
gl.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTSGLint
gl.MAX_UNIFORM_BLOCK_SIZEGLint64
gl.MAX_UNIFORM_BUFFER_BINDINGSGLint
gl.MAX_VARYING_COMPONENTSGLint
gl.MAX_VERTEX_OUTPUT_COMPONENTSGLint
gl.MAX_VERTEX_UNIFORM_BLOCKSGLint
gl.MAX_VERTEX_UNIFORM_COMPONENTSGLint
gl.MIN_PROGRAM_TEXEL_OFFSETGLint
gl.PACK_ROW_LENGTHGLintSee pixelStorei.
gl.PACK_SKIP_PIXELSGLintSee pixelStorei.
gl.PACK_SKIP_ROWSGLintSee pixelStorei.
gl.PIXEL_PACK_BUFFER_BINDINGWebGLBuffer or nullSee bindBuffer.
gl.PIXEL_UNPACK_BUFFER_BINDINGWebGLBuffer or nullSee bindBuffer.
gl.RASTERIZER_DISCARDGLboolean
gl.READ_BUFFERGLenum
gl.READ_FRAMEBUFFER_BINDINGWebGLFramebuffer or nullnull corresponds to a binding to the default framebuffer. See also bindFramebuffer.
gl.SAMPLE_ALPHA_TO_COVERAGEGLboolean
gl.SAMPLE_COVERAGEGLboolean
gl.SAMPLER_BINDINGWebGLSampler or nullSee bindSampler.
gl.TEXTURE_BINDING_2D_ARRAYWebGLTexture or nullSee bindTexture.
gl.TEXTURE_BINDING_3DWebGLTexture or nullSee bindTexture.
gl.TRANSFORM_FEEDBACK_ACTIVEGLboolean
gl.TRANSFORM_FEEDBACK_BINDINGWebGLTransformFeedback or nullSee bindTransformFeedback.
gl.TRANSFORM_FEEDBACK_BUFFER_BINDINGWebGLBuffer or nullSee bindBuffer.
gl.TRANSFORM_FEEDBACK_PAUSEDGLboolean
gl.UNIFORM_BUFFER_BINDINGWebGLBuffer or nullSee bindBuffer.
gl.UNIFORM_BUFFER_OFFSET_ALIGNMENTGLintSee pixelStorei.
gl.UNPACK_IMAGE_HEIGHTGLintSee pixelStorei.
gl.UNPACK_ROW_LENGTHGLintSee pixelStorei.
gl.UNPACK_SKIP_IMAGESGLintSee pixelStorei.
gl.UNPACK_SKIP_PIXELSGLintSee pixelStorei.
gl.UNPACK_SKIP_ROWSGLintSee pixelStorei.
gl.VERTEX_ARRAY_BINDINGWebGLVertexArrayObject or nullSee bindVertexArray.

WebGL extensions

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

ConstantReturned typeExtensionDescription
ext.MAX_TEXTURE_MAX_ANISOTROPY_EXTGLfloatEXT_texture_filter_anisotropicMaximum available anisotropy.
ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OESGLenumOES_standard_derivativesAccuracy of the derivative calculation for the GLSL built-in functions: dFdx, dFdy, and fwidth.
ext.MAX_COLOR_ATTACHMENTS_WEBGLGLintWEBGL_draw_buffersThe maximum number of framebuffer color attachment points.
ext.MAX_DRAW_BUFFERS_WEBGLGLintWEBGL_draw_buffersThe 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
GLenumWEBGL_draw_buffersDrawing buffers.
ext.VERTEX_ARRAY_BINDING_OESWebGLVertexArrayObjectOESOES_vertex_array_objectBound vertex array object (VAO).
ext.TIMESTAMP_EXTGLuint64EXT

EXT_disjoint_timer_query

The current time.
ext.GPU_DISJOINT_EXTGLbooleanEXT_disjoint_timer_query

Returns whether or not the GPU performed any disjoint operation.

ext.MAX_VIEWS_OVRGLintOVR_multiview2Maximum number of views.

Examples

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

Specifications

SpecificationStatusComment
WebGL 1.0
The definition of 'getParameter' in that specification.
RecommendationInitial definition.
WebGL 2.0
The definition of 'getParameter' in that specification.
Editor's DraftAdds additional parameter names.
OpenGL ES 2.0
The definition of 'glGet' in that specification.
StandardMan page of the (similar) OpenGL API.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:136 次

字数:47608

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文