Class: WebGLState

WebGLState

new WebGLState(gl)

WebGL 状态管理,减少 api 调用

Name Type Description
gl WebGLRenderingContext

Members Show Inherited

Name Type Default Description
className String WebGLState
isWebGLState Boolean true
systemFramebuffer null true

系统framebuffer

isWebGL2 Boolean false

是否是 WebGL2

gl WebGLRenderingContext

gl

Methods Show Inherited

重置状态

enable(capability)

enable

Name Type Description
capability GLenum

disable(capability)

disable

Name Type Description
capability GLenum

bindFramebuffer(target, framebuffer)

bindFramebuffer

Name Type Description
target GLenum
framebuffer WebGLFramebuffer

bindSystemFramebuffer()

绑定系统framebuffer

useProgram(program)

useProgram

Name Type Description
program WebGLProgram

depthFunc(func)

depthFunc

Name Type Description
func GLenum

depthMask(flag)

depthMask

Name Type Description
flag GLenum

clear

Name Type Description
mask Number

depthRange(zNear, zFar)

depthRange

Name Type Description
zNear Number
zFar Number

stencilFunc(func, ref, mask)

stencilFunc

Name Type Description
func GLenum
ref Number
mask Number

stencilMask(mask)

stencilMask

Name Type Description
mask Number

stencilOp(fail, zfail, zpass)

stencilOp

Name Type Description
fail GLenum
zfail GLenum
zpass GLenum

colorMask(red, green, blue, alpha)

colorMask

Name Type Description
red Boolean
green Boolean
blue Boolean
alpha Boolean

cullFace

Name Type Description
mode GLenum

frontFace(mode)

frontFace

Name Type Description
mode GLenum

blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha)

blendFuncSeparate

Name Type Description
srcRGB GLenum
dstRGB GLenum
srcAlpha GLenum
dstAlpha GLenum

blendEquationSeparate(modeRGB, modeAlpha)

blendEquationSeparate

Name Type Description
modeRGB GLenum
modeAlpha GLenum

pixelStorei(pname, param)

pixelStorei

Name Type Description
pname GLenum
param GLenum

viewport(x, y, width, height)

viewport

Name Type Description
x Number
y Number
width Number
height Number

activeTexture(texture)

activeTexture

Name Type Description
texture GLenum

bindTexture(target, texture)

bindTexture

Name Type Description
target GLenum
texture WebGLTexture

getActiveTextureUnit(){GLenum}

获取当前激活的纹理对象

Returns:
Type Description
GLenum