Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mygl=mygl||(function(){
- function copy_object(a) {
- var b={};
- for(var k in a) {
- if(a[k] instanceof Array) {
- b[k]=a[k].slice();
- } else {
- b[k]=a[k];
- }
- }
- return b;
- }
- var state_initial = {
- "cull_face" : false,
- "blend" : false,
- "stencil_test" : false,
- "depth_test" : false,
- "polygon_offset_fill" : false,
- "dither" : true,
- "scissor_test" : false,
- "blend_color" : [0,0,0,0],
- "blend_equation_rgb" : 0x8006, //gl.FUNC_ADD
- "blend_equation_alpha" : 0x8006, //gl.FUNC_ADD
- "blend_src_rgb" : 1, //gl.ONE
- "blend_dst_rgb" : 0, //gl.ZERO
- "blend_src_alpha" : 1, //gl.ONE
- "blend_dst_alpha" : 0, //gl.ZERO
- "color_writemask" : [true,true,true,true],
- "cull_face_mode" : 0x0405, //gl.BACK
- "depth_func" : 0x0201, //gl.LESS
- "depth_writemask" : true,
- "depth_range" : [0,1],
- "front_face" : 0x0901, //gl.CCW
- "polygon_offset_factor" : 0,
- "polygon_offset_units" : 0,
- "stencil_back_func" : 0x0207, //gl.ALWAYS
- "stencil_back_ref" : 0,
- "stencil_back_value_mask" : 0xffffffff,
- "stencil_func" : 0x0207, //gl.ALWAYS
- "stencil_ref" : 0,
- "stencil_value_mask" : 0xffffffff,
- "stencil_back_writemask" : 0xffffffff,
- "stencil_writemask" : 0xffffffff,
- "stencil_back_pass_depth_fail" : 0x1E00, //gl.KEEP
- "stencil_back_pass_depth_pass" : 0x1E00, //gl.KEEP
- "stencil_back_fail" : 0x1E00, //gl.KEEP
- "stencil_pass_depth_fail" : 0x1E00, //gl.KEEP
- "stencil_pass_depth_pass" : 0x1E00, //gl.KEEP
- "stencil_fail" : 0x1E00, //gl.KEEP
- "scissor_box" : [0,0,0,0],
- "line_width" : 1,
- };
- var state_current = copy_object(state_initial);
- var state_to = copy_object(state_initial);
- function state_clear() {
- //console.log(state_to.depth_test);
- state_to = copy_object(state_initial);
- //console.log(state_to.depth_test);
- }
- function state_sync() {
- //
- state_current.cull_face=gl.getParameter(gl.CULL_FACE);
- state_current.blend=gl.getParameter(gl.BLEND);
- state_current.stencil_test=gl.getParameter(gl.STENCIL_TEST);
- state_current.depth_test=gl.getParameter(gl.DEPTH_TEST);
- state_current.polygon_offset_fill=gl.getParameter(gl.POLYGON_OFFSET_FILL);
- state_current.dither=gl.getParameter(gl.DITHER);
- state_current.scissor_test=gl.getParameter(gl.SCISSOR_TEST);
- //
- state_current.blend_color=gl.getParameter(gl.BLEND_COLOR);
- //blend equation
- state_current.blend_equation_rgb=gl.getParameter(gl.BLEND_EQUATION_RGB);
- state_current.blend_equation_alpha=gl.getParameter(gl.BLEND_EQUATION_ALPHA);
- //blend func
- state_current.blend_src_rgb=gl.getParameter(gl.BLEND_SRC_RGB);
- state_current.blend_dst_rgb=gl.getParameter(gl.BLEND_DST_RGB);
- state_current.blend_src_alpha=gl.getParameter(gl.BLEND_SRC_ALPHA);
- state_current.blend_dst_alpha=gl.getParameter(gl.BLEND_DST_ALPHA);
- //
- state_current.color_writemask=gl.getParameter(gl.COLOR_WRITEMASK);
- state_current.cull_face_mode=gl.getParameter(gl.CULL_FACE_MODE);
- state_current.depth_func=gl.getParameter(gl.DEPTH_FUNC);
- state_current.depth_writemask=gl.getParameter(gl.DEPTH_WRITEMASK);
- state_current.depth_range=gl.getParameter(gl.DEPTH_RANGE);
- state_current.front_face=gl.getParameter(gl.FRONT_FACE);
- //polygonOffset
- state_current.polygon_offset_factor=gl.getParameter(gl.POLYGON_OFFSET_FACTOR);
- state_current.polygon_offset_units=gl.getParameter(gl.POLYGON_OFFSET_UNITS);
- //stencilFuncBack
- state_current.stencil_back_func=gl.getParameter(gl.STENCIL_BACK_FUNC);
- state_current.stencil_back_ref=gl.getParameter(gl.STENCIL_BACK_REF);
- state_current.stencil_back_value_mask=gl.getParameter(gl.STENCIL_BACK_VALUE_MASK);
- //stencilFuncFront
- state_current.stencil_func=gl.getParameter(gl.STENCIL_FUNC);
- state_current.stencil_ref=gl.getParameter(gl.STENCIL_REF);
- state_current.stencil_value_mask=gl.getParameter(gl.STENCIL_VALUE_MASK);
- //stencilMaskBack
- state_current.stencil_back_writemask=gl.getParameter(gl.STENCIL_BACK_WRITEMASK);
- //stencilMaskFront
- state_current.stencil_writemask=gl.getParameter(gl.STENCIL_WRITEMASK);
- //stencilOpBack
- state_current.stencil_back_pass_depth_fail=gl.getParameter(gl.STENCIL_BACK_PASS_DEPTH_FAIL);
- state_current.stencil_back_pass_depth_pass=gl.getParameter(gl.STENCIL_BACK_PASS_DEPTH_PASS);
- state_current.stencil_back_fail=gl.getParameter(gl.STENCIL_BACK_FAIL);
- //stencilOpFront
- state_current.stencil_pass_depth_fail=gl.getParameter(gl.STENCIL_PASS_DEPTH_FAIL);
- state_current.stencil_pass_depth_pass=gl.getParameter(gl.STENCIL_PASS_DEPTH_PASS);
- state_current.stencil_fail=gl.getParameter(gl.STENCIL_FAIL);
- //scissor
- state_current.scissor_box=gl.getParameter(gl.SCISSOR_BOX);
- //lineWidth
- state_current.line_width=gl.getParameter(gl.LINE_WIDTH);
- //
- state_to = copy_object(state_current);
- //
- //for(var k in state_current) { console.log("\"" +k + "\" : " + state_current[k] + "\n"); }
- }
- function state_func_enable(cap) {
- if(cap==gl.CULL_FACE) {
- state_to.cull_face=true;
- } else if(cap==gl.BLEND) {
- state_to.blend=true;
- } else if(cap==gl.DEPTH_TEST) {
- state_to.depth_test=true;
- } else if(cap==gl.STENCIL_TEST) {
- state_to.stencil_test=true;
- } else if(cap==gl.POLYGON_OFFSET_FILL) {
- state_to.polygon_offset_fill=true;
- } else if(cap==gl.DITHER) {
- state_to.dither=true;
- } else if(cap==gl.SCISSOR_TEST) {
- state_to.scissor_test=true;
- }
- }
- function state_func_disable(cap) {
- if(cap==gl.CULL_FACE) {
- state_to.cull_face=false;
- } else if(cap==gl.BLEND) {
- state_to.blend=false;
- } else if(cap==gl.DEPTH_TEST) {
- state_to.depth_test=false;
- } else if(cap==gl.STENCIL_TEST) {
- state_to.stencil_test=false;
- } else if(cap==gl.POLYGON_OFFSET_FILL) {
- state_to.polygon_offset_fill=false;
- } else if(cap==gl.DITHER) {
- state_to.dither=false;
- } else if(cap==gl.SCISSOR_TEST) {
- state_to.scissor_test=false;
- }
- }
- function state_func_blendColor(red,green,blue,alpha) {
- state_to.blend_color[0]=red;
- state_to.blend_color[1]=green;
- state_to.blend_color[2]=blue;
- state_to.blend_color[3]=alpha;
- }
- function state_func_blendEquation(mode) {
- state_to.blend_equation_rgb=mode;
- state_to.blend_equation_alpha=mode;
- }
- function state_func_blendEquationSeparate(modeRGB,modeAlpha) {
- state_to.blend_equation_rgb=modeRGB;
- state_to.blend_equation_alpha=modeAlpha;
- }
- function state_func_blendFunc(sfactor,dfactor) {
- state_to.blend_src_rgb=sfactor;
- state_to.blend_dst_rgb=dfactor;
- state_to.blend_src_alpha=sfactor;
- state_to.blend_dst_alpha=dfactor;
- }
- function state_func_blendFuncSeparate(srcRGB,dstRGB,srcAlpha,dstAlpha) {
- state_to.blend_src_rgb=srcRGB;
- state_to.blend_dst_rgb=dstRGB;
- state_to.blend_src_alpha=srcAlpha;
- state_to.blend_dst_alpha=dstAlpha;
- }
- function state_func_colorMask(red,green,blue,alpha) {
- state_to.color_writemask[0]=red;
- state_to.color_writemask[1]=green;
- state_to.color_writemask[2]=blue;
- state_to.color_writemask[3]=alpha;
- }
- function state_func_cullFace(mode) {
- state_to.cull_face_mode=mode;
- }
- function state_func_depthFunc(func) {
- state_to.depth_func=func;
- }
- function state_func_depthMask(flag) {
- state_to.depth_writemask=flag;
- }
- function state_func_depthRange(zNear,zFar) {
- state_to.depth_range[0]=zNear;
- state_to.depth_range[1]=zFar;
- }
- function state_func_frontFace(mode) {
- state_to.front_face=mode;
- }
- function state_func_polygonOffset(factor,units) {
- state_to.polygon_offset_factor=factor;
- state_to.polygon_offset_units=units;
- }
- function state_func_stencilFunc(func,ref,mask) {
- state_to.stencil_back_func=func;
- state_to.stencil_back_ref=ref;
- state_to.stencil_back_value_mask=mask;
- state_to.stencil_func=func;
- state_to.stencil_ref=ref;
- state_to.stencil_value_mask=mask;
- }
- function state_func_stencilFuncSeparate(face,func,ref,mask) {
- if(face==gl.BACK) {
- state_to.stencil_back_func=func;
- state_to.stencil_back_ref=ref;
- state_to.stencil_back_value_mask=mask;
- } else if(face==gl.FRONT) {
- state_to.stencil_func=func;
- state_to.stencil_ref=ref;
- state_to.stencil_value_mask=mask;
- }
- }
- function state_func_stencilMask(mask) {
- state_to.stencil_back_writemask=mask;
- state_to.stencil_writemask=mask;
- }
- function state_func_stencilMaskSeparate(face,mask) {
- if(face==gl.BACK) {
- state_to.stencil_back_writemask=mask;
- } else if(face==gl.FRONT) {
- state_to.stencil_writemask=mask;
- }
- }
- function state_func_stencilOp(fail,zfail,zpass) {
- state_to.stencil_back_fail=fail;
- state_to.stencil_back_pass_depth_fail=zfail;
- state_to.stencil_back_pass_depth_pass=zpass;
- state_to.stencil_fail=fail;
- state_to.stencil_pass_depth_fail=zfail;
- state_to.stencil_pass_depth_pass=zpass;
- }
- function state_func_stencilOpSeparate(face,fail,zfail,zpass) {
- if(face==gl.BACK) {
- state_to.stencil_back_fail=fail;
- state_to.stencil_back_pass_depth_fail=zfail;
- state_to.stencil_back_pass_depth_pass=zpass;
- } else if(face==gl.FRONT) {
- state_to.stencil_fail=fail;
- state_to.stencil_pass_depth_fail=zfail;
- state_to.stencil_pass_depth_pass=zpass;
- }
- }
- function state_func_scissor(x,y,width,height) {
- state_to.scissor_box[0]=x;
- state_to.scissor_box[1]=y;
- state_to.scissor_box[2]=width;
- state_to.scissor_box[3]=height;
- }
- function state_func_lineWidth(width) {
- state_to.line_width=width;
- }
- function state_apply() {
- //cull_face
- if(state_current.cull_face!=state_to.cull_face) {
- state_current.cull_face=state_to.cull_face;
- if(state_current.cull_face) {
- gl.enable(gl.CULL_FACE);
- } else {
- gl.disable(gl.CULL_FACE);
- }
- }
- //blend
- if(state_current.blend!=state_to.blend) {
- state_current.blend=state_to.blend;
- if(state_current.blend) {
- gl.enable(gl.BLEND);
- } else {
- gl.disable(gl.BLEND);
- }
- }
- //stencil_test
- if(state_current.stencil_test!=state_to.stencil_test) {
- state_current.stencil_test=state_to.stencil_test;
- if(state_current.stencil_test) {
- gl.enable(gl.STENCIL_TEST);
- } else {
- gl.disable(gl.STENCIL_TEST);
- }
- }
- //enable/disable depth_test
- if(state_current.depth_test!=state_to.depth_test) {
- state_current.depth_test=state_to.depth_test;
- if(state_current.depth_test) {
- gl.enable(gl.DEPTH_TEST);
- } else {
- gl.disable(gl.DEPTH_TEST);
- }
- }
- //polygon_offset_fill
- if(state_current.polygon_offset_fill!=state_to.polygon_offset_fill) {
- state_current.polygon_offset_fill=state_to.polygon_offset_fill;
- if(state_current.polygon_offset_fill) {
- gl.enable(gl.POLYGON_OFFSET_FILL);
- } else {
- gl.disable(gl.POLYGON_OFFSET_FILL);
- }
- }
- //dither
- if(state_current.dither!=state_to.dither) {
- state_current.dither=state_to.dither;
- if(state_current.dither) {
- gl.enable(gl.DITHER);
- } else {
- gl.disable(gl.DITHER);
- }
- }
- //scissor_test
- if(state_current.scissor_test!=state_to.scissor_test) {
- state_current.scissor_test=state_to.scissor_test;
- if(state_current.scissor_test) {
- gl.enable(gl.SCISSOR_TEST);
- } else {
- gl.disable(gl.SCISSOR_TEST);
- }
- }
- //blendColor
- if(state_to.blend &&
- (state_current.blend_color[0]!=state_to.blend_color[0] ||
- state_current.blend_color[1]!=state_to.blend_color[1] ||
- state_current.blend_color[2]!=state_to.blend_color[2] ||
- state_current.blend_color[3]!=state_to.blend_color[3])) {
- state_current.blend_color[0]=state_to.blend_color[0];
- state_current.blend_color[1]=state_to.blend_color[1];
- state_current.blend_color[2]=state_to.blend_color[2];
- state_current.blend_color[3]=state_to.blend_color[3];
- gl.blendColor(state_current.blendColor[0],
- state_current.blendColor[1],
- state_current.blendColor[2],
- state_current.blendColor[3]);
- }
- //blendEquationSeparate
- if(state_to.blend &&
- (state_current.blend_equation_rgb != state_to.blend_equation_rgb ||
- state_current.blend_equation_alpha != state_to.blend_equation_alpha)) {
- state_current.blend_equation_rgb = state_to.blend_equation_rgb;
- state_current.blend_equation_alpha = state_to.blend_equation_alpha
- gl.blendEquationSeparate(state_current.blend_equation_rgb,
- state_current.blend_equation_alpha);
- }
- //blendFuncSeparate
- if(state_to.blend &&
- (state_current.blend_src_rgb != state_to.blend_src_rgb ||
- state_current.blend_dst_rgb != state_to.blend_dst_rgb ||
- state_current.blend_src_alpha != state_to.blend_src_alpha ||
- state_current.blend_dst_alpha != state_to.blend_dst_alpha)) {
- state_current.blend_src_rgb = state_to.blend_src_rgb;
- state_current.blend_dst_rgb = state_to.blend_dst_rgb;
- state_current.blend_src_alpha = state_to.blend_src_alpha;
- state_current.blend_dst_alpha = state_to.blend_dst_alpha;
- gl.blendFuncSeparate(state_current.blend_src_rgb,
- state_current.blend_dst_rgb,
- state_current.blend_src_alpha,
- state_current.blend_dst_alpha);
- }
- //colorMask
- if(state_current.color_writemask[0] != state_to.color_writemask[0] ||
- state_current.color_writemask[1] != state_to.color_writemask[1] ||
- state_current.color_writemask[2] != state_to.color_writemask[2] ||
- state_current.color_writemask[3] != state_to.color_writemask[3]) {
- state_current.color_writemask[0] = state_to.color_writemask[0];
- state_current.color_writemask[1] = state_to.color_writemask[1];
- state_current.color_writemask[2] = state_to.color_writemask[2];
- state_current.color_writemask[3] = state_to.color_writemask[3];
- gl.colorMask(state_current.color_writemask[0],
- state_current.color_writemask[1],
- state_current.color_writemask[2],
- state_current.color_writemask[3]);
- }
- //stencilFuncSeparate front
- if(//state_to.stencil_test &&
- (state_current.stencil_func != state_to.stencil_func ||
- state_current.stencil_ref != state_to.stencil_ref ||
- state_current.stencil_value_mask != state_to.stencil_value_mask)) {
- state_current.stencil_func = state_to.stencil_func;
- state_current.stencil_ref = state_to.stencil_ref;
- state_current.stencil_value_mask = state_to.stencil_value_mask;
- gl.stencilFuncSeparate(gl.FRONT,
- state_current.stencil_func,
- state_current.stencil_ref,
- state_current.stencil_value_mask);
- }
- //stencilFuncSeparate back
- if(//state_to.stencil_test &&
- (state_current.stencil_back_func != state_to.stencil_back_func ||
- state_current.stencil_back_ref != state_to.stencil_back_ref ||
- state_current.stencil_back_value_mask != state_to.stencil_back_value_mask)) {
- state_current.stencil_back_func = state_to.stencil_back_func;
- state_current.stencil_back_ref = state_to.stencil_back_ref;
- state_current.stencil_back_value_mask = state_to.stencil_back_value_mask;
- gl.stencilFuncSeparate(gl.BACK,
- state_current.stencil_back_func,
- state_current.stencil_back_ref,
- state_current.stencil_back_value_mask);
- }
- //stencilMaskSeparate front
- if(//state_to.stencil_test &&
- state_current.stencil_writemask != state_to.stencil_writemask) {
- state_current.stencil_writemask = state_to.stencil_writemask;
- gl.stencilMaskSeparate(gl.FRONT,state_current.stencil_writemask);
- }
- //stencilMaskSeparate back
- if(//state_to.stencil_test &&
- state_current.stencil_back_writemask != state_to.stencil_back_writemask) {
- state_current.stencil_back_writemask = state_to.stencil_back_writemask;
- gl.stencilMaskSeparate(gl.BACK,state_current.stencil_back_writemask);
- }
- //stencilOpSeparate front
- if(//state_to.stencil_test &&
- (state_current.stencil_fail != state_to.stencil_fail ||
- state_current.stencil_pass_depth_fail != state_to.stencil_pass_depth_fail ||
- state_current.stencil_pass_depth_pass != state_to.stencil_pass_depth_pass)) {
- state_current.stencil_fail = state_to.stencil_fail;
- state_current.stencil_pass_depth_fail = state_to.stencil_pass_depth_fail;
- state_current.stencil_pass_depth_pass = state_to.stencil_pass_depth_pass;
- gl.stencilOpSeparate(gl.FRONT,
- state_current.stencil_fail,
- state_current.stencil_pass_depth_fail,
- state_current.stencil_pass_depth_pass);
- }
- //stencilOpSeparate back
- if(//state_to.stencil_test &&
- (state_current.stencil_back_fail != state_to.stencil_back_fail ||
- state_current.stencil_back_pass_depth_fail != state_to.stencil_back_pass_depth_fail ||
- state_current.stencil_back_pass_depth_pass != state_to.stencil_back_pass_depth_pass)) {
- state_current.stencil_back_fail = state_to.stencil_back_fail;
- state_current.stencil_back_pass_depth_fail = state_to.stencil_back_pass_depth_fail;
- state_current.stencil_back_pass_depth_pass = state_to.stencil_back_pass_depth_pass;
- gl.stencilOpSeparate(gl.BACK,
- state_current.stencil_back_fail,
- state_current.stencil_back_pass_depth_fail,
- state_current.stencil_back_pass_depth_pass);
- }
- //cullFace
- if(state_to.cull_face &&
- state_current.cull_face_mode != state_to.cull_face_mode) {
- state_current.cull_face_mode=state_to.cull_face_mode;
- gl.cullFace(state_current.cull_face_mode);
- }
- //frontFace
- if(state_current.front_face != state_to.front_face) {
- state_current.front_face = state_to.front_face;
- gl.frontFace(state_current.front_face);
- }
- //polygonOffset
- if(state_to.polygon_offset_fill &&
- (state_current.polygon_offset_factor != state_to.polygon_offset_factor ||
- state_current.polygon_offset_units != state_to.polygon_offset_units)) {
- state_current.polygon_offset_factor = state_to.polygon_offset_factor;
- state_current.polygon_offset_units = state_to.polygon_offset_units;
- gl.polygonOffset(state_current.polygon_offset_factor,state_current.polygon_offset_units);
- }
- //depthFunc
- if(//state_to.depth_test &&
- state_current.depth_func != state_to.depth_func) {
- state_current.depth_func=state_to.depth_func;
- gl.depthFunc(state_current.depth_func);
- }
- //depthMask
- if(//state_to.depth_test &&
- state_current.depth_writemask != state_to.depth_writemask) {
- state_current.depth_writemask = state_to.depth_writemask;
- gl.depthMask(state_current.depth_writemask);
- }
- //depthRange
- if(//state_to.depth_test &&
- (state_current.depth_range[0] != state_to.depth_range[0] ||
- state_current.depth_range[1] != state_to.depth_range[1])) {
- state_current.depth_range[0] = state_to.depth_range[0];
- state_current.depth_range[1] = state_to.depth_range[1];
- gl.depthRange(state_current.depth_range[0],
- state_current.depth_range[1]);
- }
- //scissor
- if(state_to.scissor_test &&
- (state_current.scissor_box[0] != state_to.scissor_box[0] ||
- state_current.scissor_box[1] != state_to.scissor_box[1] ||
- state_current.scissor_box[2] != state_to.scissor_box[2] ||
- state_current.scissor_box[3] != state_to.scissor_box[3])) {
- state_current.scissor_box[0] = state_to.scissor_box[0];
- state_current.scissor_box[1] = state_to.scissor_box[1];
- state_current.scissor_box[2] = state_to.scissor_box[2];
- state_current.scissor_box[3] = state_to.scissor_box[3];
- gl.scissor(state_current.scissor_box[0],
- state_current.scissor_box[1],
- state_current.scissor_box[2],
- state_current.scissor_box[3]);
- }
- //lineWidth
- if(state_current.line_width != state_to.line_width) {
- state_current.line_width = state_to.line_width;
- gl.lineWidth(state_current.line_width);
- }
- }
- //
- function state_func_all_apply(s,clear) {
- if(clear) {
- state_clear();
- }
- //todo: dither, scissor ...
- function enums(x) {return x;}
- //cull_face
- if(s.cull_face!=null) {
- state_to.cull_face=s.cull_face;
- }
- //blend
- if(s.blend!=null) {
- state_to.blend=s.blend;
- }
- //stencil_test
- if(s.stencil_test!=null) {
- state_to.stencil_test=s.stencil_test;
- }
- //depth_test
- if(s.depth_test!=null) {
- state_to.depth_test=s.depth_test;
- }
- //polygon_offset_fill
- if(s.polygon_offset_fill!=null) {
- state_to.polygon_offset_fill=s.polygon_offset_fill;
- }
- //blend_color
- if(s.blend_color!=null) {
- state_to.blend_color[0]=s.blend_color[0];
- state_to.blend_color[1]=s.blend_color[1];
- state_to.blend_color[2]=s.blend_color[2];
- state_to.blend_color[3]=s.blend_color[3];
- }
- //blend_color_red
- if(s.blend_color_red!=null) {
- state_to.blend_color[0]=s.blend_color_red;
- }
- //blend_color_red
- if(s.blend_color_green!=null) {
- state_to.blend_color[1]=s.blend_color_green;
- }
- //blend_color_blue
- if(s.blend_color_blue!=null) {
- state_to.blend_color[2]=s.blend_color_blue;
- }
- //blend_color_alpha
- if(s.blend_color_alpha!=null) {
- state_to.blend_color[3]=s.blend_color_alpha;
- }
- //blend_equation
- if(s.blend_equation!=null) {
- state_to.blend_equation_rgb=enums(s.blend_equation);
- state_to.blend_equation_alpha=enums(s.blend_equation);
- }
- //blend_equation_rgb
- if(s.blend_equation_rgb!=null) {
- state_to.blend_equation_rgb=enums(s.blend_equation_rgb);
- }
- //blend_equation_alpha
- if(s.blend_equation_alpha!=null) {
- state_to.blend_equation_alpha=enums(s.blend_equation_alpha);
- }
- //blend_src
- if(s.blend_src!=null) {
- state_to.blend_src_rgb=enums(s.blend_src);
- state_to.blend_src_alpha=enums(s.blend_src);
- }
- //blend_src_rgb
- if(s.blend_src_rgb!=null) {
- state_to.blend_src_rgb=enums(s.blend_src_rgb);
- }
- //blend_src_alpha
- if(s.blend_src_alpha!=null) {
- state_to.blend_src_alpha=enums(s.blend_src_alpha);
- }
- //blend_dst
- if(s.blend_src!=null) {
- state_to.blend_dst_rgb=enums(s.blend_dst);
- state_to.blend_dst_alpha=enums(s.blend_dst);
- }
- //blend_dst_rgb
- if(s.blend_dst_rgb!=null) {
- state_to.blend_dst_rgb=enums(s.blend_dst_rgb);
- }
- //blend_dst_alpha
- if(s.blend_dst_alpha!=null) {
- state_to.blend_dst_alpha=enums(s.blend_dst_alpha);
- }
- //color_writemask
- if(s.color_writemask!=null) {
- state_to.color_writemask[0]=s.color_writemask[0];
- state_to.color_writemask[1]=s.color_writemask[1];
- state_to.color_writemask[2]=s.color_writemask[2];
- state_to.color_writemask[3]=s.color_writemask[3];
- }
- //color_writemask_red
- if(s.color_writemask_red!=null) {
- state_to.color_writemask[0]=s.color_writemask_red;
- }
- //color_writemask_green
- if(s.color_writemask_green!=null) {
- state_to.color_writemask[1]=s.color_writemask_green;
- }
- //color_writemask_blue
- if(s.color_writemask_blue!=null) {
- state_to.color_writemask[2]=s.color_writemask_blue;
- }
- //color_writemask_alpha
- if(s.color_writemask_alpha!=null) {
- state_to.color_writemask[3]=s.color_writemask_alpha;
- }
- //cull_face_mode
- if(s.cull_face_mode!=null) {
- state_to.cull_face_mode=enums(s.cull_face_mode);
- }
- //depth_func
- if(s.depth_func!=null) {
- state_to.depth_func=enums(s.depth_func);
- }
- //depth_func
- if(s.depth_writemask!=null) {
- state_to.depth_writemask=s.depth_writemask;
- }
- //depth_range
- if(s.depth_range!=null) {
- state_to.depth_range[0]=s.depth_range[0];
- state_to.depth_range[1]=s.depth_range[1];
- }
- //depth_range_znear
- if(s.depth_range_znear!=null) {
- state_to.depth_range[0]=s.depth_range_znear;
- }
- //depth_func
- if(s.depth_range_zfar!=null) {
- state_to.depth_range[1]=s.depth_range_zfar;
- }
- //front_face
- if(s.front_face!=null) {
- state_to.front_face=enums(s.front_face);
- }
- //polygon_offset_factor
- if(s.polygon_offset_factor!=null) {
- state_to.polygon_offset_factor=s.polygon_offset_factor;
- }
- //polygon_offset_units
- if(s.polygon_offset_units!=null) {
- state_to.polygon_offset_units=s.polygon_offset_units;
- }
- //stencil_func
- if(s.stencil_func!=null) {
- state_to.stencil_back_func=enums(s.stencil_func);
- state_to.stencil_func=enums(s.stencil_func);
- }
- //stencil_back_func
- if(s.stencil_back_func!=null) {
- state_to.stencil_back_func=enums(s.stencil_back_func);
- }
- //stencil_front_func
- if(s.stencil_front_func!=null) {
- state_to.stencil_func=enums(s.stencil_front_func);
- }
- //stencil_ref
- if(s.stencil_ref!=null) {
- state_to.stencil_back_ref=s.stencil_ref;
- state_to.stencil_ref=s.stencil_ref;
- }
- //stencil_back_ref
- if(s.stencil_back_ref!=null) {
- state_to.stencil_back_ref=s.stencil_back_ref;
- }
- //stencil_front_ref
- if(s.stencil_front_ref!=null) {
- state_to.stencil_ref=s.stencil_front_ref;
- }
- //stencil_value_mask
- if(s.stencil_value_mask!=null) {
- state_to.stencil_back_value_mask=s.stencil_value_mask;
- state_to.stencil_value_mask=s.stencil_value_mask;
- }
- //stencil_back_value_mask
- if(s.stencil_back_value_mask!=null) {
- state_to.stencil_back_value_mask=s.stencil_back_value_mask;
- }
- //stencil_front_value_mask
- if(s.stencil_front_value_mask!=null) {
- state_to.stencil_value_mask=s.stencil_front_value_mask;
- }
- //stencil_writemask
- if(s.stencil_writemask!=null) {
- state_to.stencil_back_writemask=s.stencil_writemask;
- state_to.stencil_writemask=s.stencil_writemask;
- }
- //stencil_back_writemask
- if(s.stencil_back_writemask!=null) {
- state_to.stencil_back_writemask=s.stencil_back_writemask;
- }
- //stencil_front_writemask
- if(s.stencil_writemask!=null) {
- state_to.stencil_writemask=s.stencil_front_writemask;
- }
- //stencil_pass_depth_fail
- if(s.stencil_pass_depth_fail!=null) {
- state_to.stencil_back_pass_depth_fail=enums(s.stencil_pass_depth_fail);
- state_to.stencil_pass_depth_fail=enums(s.stencil_pass_depth_fail);
- }
- //stencil_back_pass_depth_fail
- if(s.stencil_back_pass_depth_fail!=null) {
- state_to.stencil_back_pass_depth_fail=enums(s.stencil_back_pass_depth_fail);
- }
- //stencil_front_pass_depth_fail
- if(s.stencil_front_pass_depth_fail!=null) {
- state_to.stencil_pass_depth_fail=enums(s.stencil_front_pass_depth_fail);
- }
- //stencil_pass_depth_pass
- if(s.stencil_pass_depth_pass!=null) {
- state_to.stencil_back_pass_depth_pass=enums(s.stencil_pass_depth_pass);
- state_to.stencil_pass_depth_pass=enums(s.stencil_pass_depth_pass);
- }
- //stencil_back_pass_depth_pass
- if(s.stencil_back_pass_depth_pass!=null) {
- state_to.stencil_back_pass_depth_pass=enums(s.stencil_back_pass_depth_pass);
- }
- //stencil_front_pass_depth_pass
- if(s.stencil_front_pass_depth_pass!=null) {
- state_to.stencil_pass_depth_pass=enums(s.stencil_front_pass_depth_pass);
- }
- //stencil_fail
- if(s.stencil_fail!=null) {
- state_to.stencil_back_fail=enums(s.stencil_fail);
- state_to.stencil_fail=enums(s.stencil_fail);
- }
- //stencil_back_fail
- if(s.stencil_back_fail!=null) {
- state_to.stencil_back_fail=enums(s.stencil_back_fail);
- }
- //stencil_front_fail
- if(s.stencil_front_fail!=null) {
- state_to.stencil_fail=enums(s.stencil_front_fail);
- }
- state_apply();
- }
- //===========================================================================
- return {
- "enable" : state_func_enable,
- "disable" : state_func_disable,
- "blendColor" : state_func_blendColor,
- "blendEquation" : state_func_blendEquation,
- "blendEquationSeparate" : state_func_blendEquationSeparate,
- "blendFunc" : state_func_blendFunc,
- "blendFuncSeparate" : state_func_blendFuncSeparate,
- "colorMask" : state_func_colorMask,
- "cullFace" : state_func_cullFace,
- "depthFunc" : state_func_depthFunc,
- "depthMask" : state_func_depthMask,
- "depthRange" : state_func_depthRange,
- "frontFace" : state_func_frontFace,
- "polygonOffset" : state_func_polygonOffset,
- "stencilFunc" : state_func_stencilFunc,
- "stencilFuncSeparate" : state_func_stencilFuncSeparate,
- "stencilMask" : state_func_stencilMask,
- "stencilMaskSeparate" : state_func_stencilMaskSeparate,
- "stencilOp" : state_func_stencilOp,
- "stencilOpSeparate" : state_func_stencilOpSeparate,
- "scissor" : state_func_scissor,
- "lineWidth" : state_func_lineWidth,
- "syncStates" : state_sync,
- "clearStates" : state_clear,
- "applyStates" : state_apply,
- "states" : state_func_all_apply
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement