WebGLState constructor
WebGLState(
- RenderingContext gl,
- WebGLExtensions extensions,
- WebGLCapabilities capabilities
Implementation
WebGLState(this.gl, this.extensions, this.capabilities) {
isWebGL2 = capabilities.isWebGL2;
colorBuffer = ColorBuffer(gl);
depthBuffer = DepthBuffer(gl);
stencilBuffer = StencilBuffer(gl);
colorBuffer.enable = enable;
colorBuffer.disable = disable;
depthBuffer.enable = enable;
depthBuffer.disable = disable;
stencilBuffer.enable = enable;
stencilBuffer.disable = disable;
maxTextures = gl.getParameter(WebGL.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
emptyTextures[WebGL.TEXTURE_2D] = createTexture(WebGL.TEXTURE_2D, WebGL.TEXTURE_2D, 1);
emptyTextures[WebGL.TEXTURE_CUBE_MAP] = createTexture(WebGL.TEXTURE_CUBE_MAP, WebGL.TEXTURE_CUBE_MAP_POSITIVE_X, 6);
// init
colorBuffer.setClear(0, 0, 0, 1, false);
depthBuffer.setClear(1);
stencilBuffer.setClear(0);
enable(WebGL.DEPTH_TEST);
depthBuffer.setFunc(LessEqualDepth);
setFlipSided(false);
setCullFace(CullFaceBack);
enable(WebGL.CULL_FACE);
setBlending(NoBlending, null, null, null, null, null, null, false);
equationToGL = {
AddEquation: WebGL.FUNC_ADD,
SubtractEquation: WebGL.FUNC_SUBTRACT,
ReverseSubtractEquation: WebGL.FUNC_REVERSE_SUBTRACT
};
equationToGL[MinEquation] = WebGL.MIN;
equationToGL[MaxEquation] = WebGL.MAX;
factorToGL = {
ZeroFactor: WebGL.ZERO,
OneFactor: WebGL.ONE,
SrcColorFactor: WebGL.SRC_COLOR,
SrcAlphaFactor: WebGL.SRC_ALPHA,
SrcAlphaSaturateFactor: WebGL.SRC_ALPHA_SATURATE,
DstColorFactor: WebGL.DST_COLOR,
DstAlphaFactor: WebGL.DST_ALPHA,
OneMinusSrcColorFactor: WebGL.ONE_MINUS_SRC_COLOR,
OneMinusSrcAlphaFactor: WebGL.ONE_MINUS_SRC_ALPHA,
OneMinusDstColorFactor: WebGL.ONE_MINUS_DST_COLOR,
OneMinusDstAlphaFactor: WebGL.ONE_MINUS_DST_ALPHA
};
scissorParam = gl.getParameter(WebGL.SCISSOR_BOX);
viewportParam = gl.getParameter(WebGL.VIEWPORT);
// currentScissor = Vector4.identity().copyFromArray( scissorParam );
// currentViewport = Vector4.identity().copyFromArray( viewportParam );
currentScissor = Vector4.identity();
currentViewport = Vector4.identity();
}