WebGLState constructor
WebGLState(
- dynamic 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(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
emptyTextures[gl.TEXTURE_2D] =
createTexture(gl.TEXTURE_2D, gl.TEXTURE_2D, 1);
emptyTextures[gl.TEXTURE_CUBE_MAP] =
createTexture(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6);
// init
colorBuffer.setClear(0, 0, 0, 1, false);
depthBuffer.setClear(1);
stencilBuffer.setClear(0);
enable(gl.DEPTH_TEST);
depthBuffer.setFunc(LessEqualDepth);
setFlipSided(false);
setCullFace(CullFaceBack);
enable(gl.CULL_FACE);
setBlending(NoBlending, null, null, null, null, null, null, false);
equationToGL = {
AddEquation: gl.FUNC_ADD,
SubtractEquation: gl.FUNC_SUBTRACT,
ReverseSubtractEquation: gl.FUNC_REVERSE_SUBTRACT
};
equationToGL[MinEquation] = gl.MIN;
equationToGL[MaxEquation] = gl.MAX;
factorToGL = {
ZeroFactor: gl.ZERO,
OneFactor: gl.ONE,
SrcColorFactor: gl.SRC_COLOR,
SrcAlphaFactor: gl.SRC_ALPHA,
SrcAlphaSaturateFactor: gl.SRC_ALPHA_SATURATE,
DstColorFactor: gl.DST_COLOR,
DstAlphaFactor: gl.DST_ALPHA,
OneMinusSrcColorFactor: gl.ONE_MINUS_SRC_COLOR,
OneMinusSrcAlphaFactor: gl.ONE_MINUS_SRC_ALPHA,
OneMinusDstColorFactor: gl.ONE_MINUS_DST_COLOR,
OneMinusDstAlphaFactor: gl.ONE_MINUS_DST_ALPHA
};
scissorParam = gl.getParameter(gl.SCISSOR_BOX);
viewportParam = gl.getParameter(gl.VIEWPORT);
// currentScissor = new Vector4.init().fromArray( scissorParam );
// currentViewport = new Vector4.init().fromArray( viewportParam );
currentScissor = Vector4.init();
currentViewport = Vector4.init();
}