OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010, Google Inc. | 2 * Copyright 2010, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 o3d.State.STENCIL_INVERT = 5; | 245 o3d.State.STENCIL_INVERT = 5; |
246 o3d.State.STENCIL_INCREMENT = 6; | 246 o3d.State.STENCIL_INCREMENT = 6; |
247 o3d.State.STENCIL_DECREMENT = 7; | 247 o3d.State.STENCIL_DECREMENT = 7; |
248 | 248 |
249 | 249 |
250 | 250 |
251 /** | 251 /** |
252 * Returns a Param for a given state. If the param does not already exist it | 252 * Returns a Param for a given state. If the param does not already exist it |
253 * will be created. If the state_name is invalid it will return null. | 253 * will be created. If the state_name is invalid it will return null. |
254 * @param {string} state_name name of the state | 254 * @param {string} state_name name of the state |
255 * @returns {o3d.Param} param or null if no matching state. | 255 * @return {o3d.Param} param or null if no matching state. |
256 * | 256 * |
257 * Example: | 257 * Example: |
258 * | 258 * |
259 * | 259 * |
260 * g_o3d = document.o3d.o3d; | 260 * g_o3d = document.o3d.o3d; |
261 * ... | 261 * ... |
262 * | 262 * |
263 * var state = my_pack.createState("my_state"); | 263 * var state = my_pack.createState("my_state"); |
264 * | 264 * |
265 * | 265 * |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 break; | 494 break; |
495 } | 495 } |
496 return this.gl.KEEP; | 496 return this.gl.KEEP; |
497 }; | 497 }; |
498 | 498 |
499 | 499 |
500 o3d.State.prototype.set = function() { | 500 o3d.State.prototype.set = function() { |
501 var stateParams = this.state_params_; | 501 var stateParams = this.state_params_; |
502 | 502 |
503 if (stateParams['AlphaBlendEnable'].value) { | 503 if (stateParams['AlphaBlendEnable'].value) { |
504 this.gl.enable(this.gl.ALPHA); | 504 this.gl.enable(this.gl.BLEND); |
505 } else { | 505 } else { |
506 this.gl.disable(this.gl.ALPHA); | 506 this.gl.disable(this.gl.BLEND); |
507 } | 507 } |
508 | 508 |
509 if (stateParams['SeparateAlphaBlendEnable'].value) { | 509 if (stateParams['SeparateAlphaBlendEnable'].value) { |
510 this.gl.blendFuncSeparate( | 510 this.gl.blendFuncSeparate( |
511 this.convertBlendFunc(stateParams['SourceBlendFunction'].value), | 511 this.convertBlendFunc(stateParams['SourceBlendFunction'].value), |
512 this.convertBlendFunc(stateParams['DestinationBlendFunction'].value), | 512 this.convertBlendFunc(stateParams['DestinationBlendFunction'].value), |
513 this.convertBlendFunc(stateParams['SourceBlendAlphaFunction'].value), | 513 this.convertBlendFunc(stateParams['SourceBlendAlphaFunction'].value), |
514 this.convertBlendFunc( | 514 this.convertBlendFunc( |
515 stateParams['DestinationBlendAlphaFunction'].value)); | 515 stateParams['DestinationBlendAlphaFunction'].value)); |
| 516 this.gl.blendEquationSeparate( |
| 517 this.convertBlendEquation(stateParams['BlendEquation'].value), |
| 518 this.convertBlendEquation(stateParams['BlendAlphaEquation'].value)); |
516 } else { | 519 } else { |
517 this.gl.blendFuncSeparate( | 520 this.gl.blendFunc( |
518 this.convertBlendFunc(stateParams['SourceBlendFunction'].value), | 521 this.convertBlendFunc(stateParams['SourceBlendFunction'].value), |
519 this.convertBlendFunc(stateParams['DestinationBlendFunction'].value)); | 522 this.convertBlendFunc(stateParams['DestinationBlendFunction'].value)); |
| 523 this.gl.blendEquation( |
| 524 this.convertBlendEquation(stateParams['BlendEquation'].value)); |
520 } | 525 } |
521 | 526 |
522 switch (stateParams['CullMode'].value) { | 527 switch (stateParams['CullMode'].value) { |
523 case o3d.State.CULL_CW: | 528 case o3d.State.CULL_CW: |
524 this.gl.enable(this.gl.CULL_FACE); | 529 this.gl.enable(this.gl.CULL_FACE); |
525 this.gl.cullFace(this.gl.BACK); | 530 this.gl.cullFace(this.gl.BACK); |
526 break; | 531 break; |
527 case o3d.State.CULL_CCW: | 532 case o3d.State.CULL_CCW: |
528 this.gl.enable(this.gl.CULL_FACE); | 533 this.gl.enable(this.gl.CULL_FACE); |
529 this.gl.cullFace(this.gl.FRONT); | 534 this.gl.cullFace(this.gl.FRONT); |
530 break; | 535 break; |
531 default: | 536 default: |
532 this.gl.disable(this.gl.CULL_FACE); | 537 this.gl.disable(this.gl.CULL_FACE); |
533 break; | 538 break; |
534 } | 539 } |
535 | 540 |
536 if (stateParams['SeparateAlphaBlendEnable'].value) { | |
537 this.gl.blendEquationSeparate( | |
538 this.convertBlendEquation(stateParams['BlendEquation'].value), | |
539 this.convertBlendEquation(stateParams['BlendAlphaEquation'].value)); | |
540 } else { | |
541 this.gl.blendEquation( | |
542 this.convertBlendEquation(stateParams['BlendEquation'].value)); | |
543 } | |
544 | |
545 if (stateParams['DitherEnable'].value) { | 541 if (stateParams['DitherEnable'].value) { |
546 this.gl.enable(this.gl.DITHER); | 542 this.gl.enable(this.gl.DITHER); |
547 } else { | 543 } else { |
548 this.gl.disable(this.gl.DITHER); | 544 this.gl.disable(this.gl.DITHER); |
549 } | 545 } |
550 | 546 |
551 if (stateParams['ZEnable'].value) { | 547 if (stateParams['ZEnable'].value) { |
552 this.gl.enable(this.gl.DEPTH_TEST); | 548 this.gl.enable(this.gl.DEPTH_TEST); |
553 this.gl.depthFunc( | 549 this.gl.depthFunc( |
554 this.convertCmpFunc(stateParams['ZComparisonFunction'].value)); | 550 this.convertCmpFunc(stateParams['ZComparisonFunction'].value)); |
555 } else { | 551 } else { |
556 this.gl.disable(this.gl.DEPTH_TEST); | 552 this.gl.disable(this.gl.DEPTH_TEST); |
557 } | 553 } |
558 | 554 |
559 if (stateParams['StencilEnable'].value) { | 555 if (stateParams['StencilEnable'].value) { |
560 this.gl.enable(this.gl.STENCIL_TEST); | 556 this.gl.enable(this.gl.STENCIL_TEST); |
561 this.gl.stencilFunc( | 557 this.gl.stencilFunc( |
562 this.convertCmpFunc(stateParams['StencilComparisonFunction'].value)); | 558 this.convertCmpFunc(stateParams['StencilComparisonFunction'].value)); |
563 } else { | 559 } else { |
564 this.gl.disable(this.gl.STENCIL_TEST); | 560 this.gl.disable(this.gl.STENCIL_TEST); |
565 } | 561 } |
566 }; | 562 }; |
567 | 563 |
OLD | NEW |