MCPcopy Create free account
hub / github.com/microsoft/SandDance / resetToInitialState

Function resetToInitialState

docs/tests/v2/es6/js/sanddance.js:34695–34798  ·  view source on GitHub ↗
(ctx)

Source from the content-addressed store, hash-verified

34693}
34694
34695function resetToInitialState(ctx) {
34696 var isWebGL2RenderingContext = !!ctx.createTransformFeedback;
34697
34698 if (isWebGL2RenderingContext) {
34699 ctx.bindVertexArray(null);
34700 }
34701
34702 var numAttribs = ctx.getParameter(ctx.MAX_VERTEX_ATTRIBS);
34703 var tmp = ctx.createBuffer();
34704 ctx.bindBuffer(ctx.ARRAY_BUFFER, tmp);
34705 for (var ii = 0; ii < numAttribs; ++ii) {
34706 ctx.disableVertexAttribArray(ii);
34707 ctx.vertexAttribPointer(ii, 4, ctx.FLOAT, false, 0, 0);
34708 ctx.vertexAttrib1f(ii, 0);
34709 if (isWebGL2RenderingContext) {
34710 ctx.vertexAttribDivisor(ii, 0);
34711 }
34712 }
34713 ctx.deleteBuffer(tmp);
34714
34715 var numTextureUnits = ctx.getParameter(ctx.MAX_TEXTURE_IMAGE_UNITS);
34716 for (var ii = 0; ii < numTextureUnits; ++ii) {
34717 ctx.activeTexture(ctx.TEXTURE0 + ii);
34718 ctx.bindTexture(ctx.TEXTURE_CUBE_MAP, null);
34719 ctx.bindTexture(ctx.TEXTURE_2D, null);
34720 if (isWebGL2RenderingContext) {
34721 ctx.bindTexture(ctx.TEXTURE_2D_ARRAY, null);
34722 ctx.bindTexture(ctx.TEXTURE_3D, null);
34723 ctx.bindSampler(ii, null);
34724 }
34725 }
34726
34727 ctx.activeTexture(ctx.TEXTURE0);
34728 ctx.useProgram(null);
34729 ctx.bindBuffer(ctx.ARRAY_BUFFER, null);
34730 ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, null);
34731 ctx.bindFramebuffer(ctx.FRAMEBUFFER, null);
34732 ctx.bindRenderbuffer(ctx.RENDERBUFFER, null);
34733 ctx.disable(ctx.BLEND);
34734 ctx.disable(ctx.CULL_FACE);
34735 ctx.disable(ctx.DEPTH_TEST);
34736 ctx.disable(ctx.DITHER);
34737 ctx.disable(ctx.SCISSOR_TEST);
34738 ctx.blendColor(0, 0, 0, 0);
34739 ctx.blendEquation(ctx.FUNC_ADD);
34740 ctx.blendFunc(ctx.ONE, ctx.ZERO);
34741 ctx.clearColor(0, 0, 0, 0);
34742 ctx.clearDepth(1);
34743 ctx.clearStencil(-1);
34744 ctx.colorMask(true, true, true, true);
34745 ctx.cullFace(ctx.BACK);
34746 ctx.depthFunc(ctx.LESS);
34747 ctx.depthMask(true);
34748 ctx.depthRange(0, 1);
34749 ctx.frontFace(ctx.CCW);
34750 ctx.hint(ctx.GENERATE_MIPMAP_HINT, ctx.DONT_CARE);
34751 ctx.lineWidth(1);
34752 ctx.pixelStorei(ctx.PACK_ALIGNMENT, 4);

Callers 1

Calls 1

clearMethod · 0.65

Tested by

no test coverage detected