WebGLRenderingContext.stencilOp() - Web APIs | MDN
文章推薦指數: 80 %
The WebGLRenderingContext.stencilOp() method of the WebGL API sets both the front and back-facing stencil test actions. SkiptomaincontentSkiptosearchSkiptoselectlanguageReferencesWebAPIsWebGLRenderingContextWebGLRenderingContext.stencilOp()SyntaxConstantsExamplesSpecificationsBrowsercompatibilitySeealsoRelatedTopicsWebGLAPIWebGLRenderingContextPropertiescanvasdrawingBufferHeightdrawingBufferWidthMethodsactiveTexture()attachShader()bindAttribLocation()bindBuffer()bindFramebuffer()bindRenderbuffer()bindTexture()blendColor()blendEquation()blendEquationSeparate()blendFunc()blendFuncSeparate()bufferData()bufferSubData()checkFramebufferStatus()clear()clearColor()clearDepth()clearStencil()colorMask() Experimental commit()compileShader()compressedTexImage[23]D()compressedTexSubImage2D()copyTexImage2D()copyTexSubImage2D()createBuffer()createFramebuffer()createProgram()createRenderbuffer()createShader()createTexture()cullFace()deleteBuffer()deleteFramebuffer()deleteProgram()deleteRenderbuffer()deleteShader()deleteTexture()depthFunc()depthMask()depthRange()detachShader()disable()disableVertexAttribArray()drawArrays()drawElements()enable()enableVertexAttribArray()finish()flush()framebufferRenderbuffer()framebufferTexture2D()frontFace()generateMipmap()getActiveAttrib()getActiveUniform()getAttachedShaders()getAttribLocation()getBufferParameter()getContextAttributes()getError()getExtension()getFramebufferAttachmentParameter()getParameter()getProgramInfoLog()getProgramParameter()getRenderbufferParameter()getShaderInfoLog()getShaderParameter()getShaderPrecisionFormat()getShaderSource()getSupportedExtensions()getTexParameter()getUniform()getUniformLocation()getVertexAttrib()getVertexAttribOffset()hint()isBuffer()isContextLost()isEnabled()isFramebuffer()isProgram()isRenderbuffer()isShader()isTexture()lineWidth()linkProgram()makeXRCompatible()pixelStorei()polygonOffset()readPixels()renderbufferStorage()sampleCoverage()scissor()shaderSource()stencilFunc()stencilFuncSeparate()stencilMask()stencilMaskSeparate()stencilOp()stencilOpSeparate()texImage2D()texParameter[fi]()texSubImage2D()uniform[1234][fi][v]()uniformMatrix[234]fv()useProgram()validateProgram()vertexAttrib[1234]f[v]()vertexAttribPointer()viewport()RelatedpagesforWebGLANGLE_instanced_arraysEXT_blend_minmaxEXT_color_buffer_half_floatEXT_disjoint_timer_queryEXT_frag_depthEXT_sRGBEXT_shader_texture_lodEXT_texture_filter_anisotropicOES_element_index_uintOES_standard_derivativesOES_texture_floatOES_texture_float_linearOES_texture_half_floatOES_texture_half_float_linearOES_vertex_array_objectWEBGL_color_buffer_floatWEBGL_compressed_texture_etc1WEBGL_compressed_texture_pvrtcWEBGL_compressed_texture_s3tcWEBGL_compressed_texture_s3tc_srgbWEBGL_debug_renderer_infoWEBGL_debug_shadersWEBGL_depth_textureWEBGL_draw_buffersWEBGL_lose_contextWebGL2RenderingContextWebGLActiveInfoWebGLBufferWebGLContextEventWebGLFramebufferWebGLObjectWebGLProgramWebGLQueryWebGLRenderbufferWebGLSamplerWebGLShaderWebGLShaderPrecisionFormatWebGLSyncWebGLTextureWebGLTransformFeedbackWebGLUniformLocationWebGLVertexArrayObjectSyntaxConstantsExamplesSpecificationsBrowsercompatibilitySeealsoWebGLRenderingContext.stencilOp() TheWebGLRenderingContext.stencilOp()methodoftheWebGLAPIsetsboththefrontandback-facing stenciltestactions. SyntaxstencilOp(fail,zfail,zpass) ParametersAllthreeparametersacceptallconstantslistedbelow. fail AGLenumspecifyingthefunctiontousewhenthestenciltestfails. Thedefaultvalueisgl.KEEP. zfail AGLenumspecifyingthefunctiontousewhenthestenciltestpasses, butthedepthtestfails.Thedefaultvalueisgl.KEEP. zpass AGLenumspecifyingthefunctiontousewhenboththestenciltest andthedepthtestpass,orwhenthestenciltestpassesandthereisnodepthbuffer ordepthtestingisdisabled.Thedefaultvalueisgl.KEEP. ReturnvalueNone(undefined).Constants gl.KEEP Keepsthecurrentvalue. gl.ZERO Setsthestencilbuffervalueto0. gl.REPLACE Setsthestencilbuffervaluetothereferencevalueasspecifiedby WebGLRenderingContext.stencilFunc(). gl.INCR Incrementsthecurrentstencilbuffervalue.Clampstothemaximumrepresentable unsignedvalue. gl.INCR_WRAP Incrementsthecurrentstencilbuffervalue.Wrapsstencilbuffervaluetozerowhen incrementingthemaximumrepresentableunsignedvalue. gl.DECR Decrementsthecurrentstencilbuffervalue.Clampsto0. gl.DECR_WRAP Decrementsthecurrentstencilbuffervalue.Wrapsstencilbuffervaluetothe maximumrepresentableunsignedvaluewhendecrementingastencilbuffervalueof0. gl.INVERT Invertsthecurrentstencilbuffervaluebitwise. Examples Thestenciltestingisdisabledbydefault.Toenableordisablestenciltesting,use theenable()and disable()methodswiththeargument gl.STENCIL_TEST. gl.enable(gl.STENCIL_TEST); gl.stencilOp(gl.INCR,gl.DECR,gl.INVERT); Togetthecurrentinformationaboutstencilanddepthpassorfail,querythe followingconstantswithgetParameter(). gl.getParameter(gl.STENCIL_FAIL); gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS); gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL); gl.getParameter(gl.STENCIL_BACK_FAIL); gl.getParameter(gl.STENCIL_BACK_PASS_DEPTH_PASS); gl.getParameter(gl.STENCIL_BACK_PASS_DEPTH_FAIL); gl.getParameter(gl.STENCIL_BITS); SpecificationsSpecificationWebGLSpecification#5.14.3BrowsercompatibilityBCDtablesonlyloadinthebrowserSeealso WebGLRenderingContext.stencilOpSeparate() WebGLRenderingContext.stencilFunc() WebGLRenderingContext.stencilFuncSeparate() WebGLRenderingContext.stencilMask() WebGLRenderingContext.stencilMaskSeparate() Foundaproblemwiththispage?EditonGitHubSourceonGitHubReportaproblemwiththiscontentonGitHubWanttofixtheproblemyourself?SeeourContributionguide.Lastmodified:May4,2022,byMDNcontributors
延伸文章資訊
- 1WebGLRenderingContext.stencilOp() - Web APIs | MDN
The WebGLRenderingContext.stencilOp() method of the WebGL API sets both the front and back-facing...
- 2How to use the stencil buffer - WebGL Fundamentals
How I can use to stencil buffer for my easiest program? ... To use the stencil buffer you have to...
- 3WebGL绘制详解之五:Stencil Buffer | JZ's Blog
WebGL中的stencil buffer(模板缓冲区)的作用也是类似的,可以在Buffer中指定一个形状作为模板,接着通过stencil test(模板测试)过程让位于形状 ...
- 4How stencil buffer and masking work? - webgl - Stack Overflow
Your program works absolute correctly, but you have to tell the getContext function to create a s...
- 5Stencil buffer doesn't work on WebGL2 - Unity Answers
If you want to use stencil buffer in WebGL use it via render feature and specify masks and events...