@@ -513,6 +513,37 @@ Phaser.Renderer.WebGL.prototype = {
513513 // Add Post-render hook
514514 } ,
515515
516+ clipX : function ( x )
517+ {
518+ var unit = 2 / this . width ;
519+
520+ return ( unit * x ) - 1 ;
521+ } ,
522+
523+ clipY : function ( y )
524+ {
525+ var unit = 2 / this . height ;
526+
527+ return 1 - ( unit * y ) ;
528+ } ,
529+
530+ getVerticesFromRect : function ( x , y , width , height )
531+ {
532+ return [
533+ // bottom-left
534+ this . clipX ( x ) , this . clipY ( y + height ) ,
535+
536+ // bottom-right
537+ this . clipX ( x + width ) , this . clipY ( y + height ) ,
538+
539+ // top-left
540+ this . clipX ( x ) , this . clipY ( y ) ,
541+
542+ // top-right
543+ this . clipX ( x + width ) , this . clipY ( y )
544+ ] ;
545+ } ,
546+
516547 createFramebuffer : function ( width , height , scaleMode )
517548 {
518549 var gl = this . gl ;
@@ -529,7 +560,9 @@ Phaser.Renderer.WebGL.prototype = {
529560 - 1.0 , 1.0 , //2
530561 1.0 , 1.0 //3
531562 ] ,
532- vertices : [
563+ fsvertices : this . getVerticesFromRect ( 0 , 0 , 800 , 600 ) ,
564+ vertices : this . getVerticesFromRect ( 300 , 100 , 400 , 300 ) ,
565+ __vertices : [
533566 - 1.0 , - 1.0 , // 0 = bottom-left
534567 1.0 , - 1.0 , // 1 = bottom-right
535568 - 1.0 , 1.0 , // 2 = top-left
@@ -540,6 +573,8 @@ Phaser.Renderer.WebGL.prototype = {
540573 ]
541574 } ;
542575
576+ console . log ( this . getVerticesFromRect ( 0 , 0 , 800 , 600 ) ) ;
577+
543578 // ibo = indices buffer object
544579 // vbo = vertices buffer object
545580
0 commit comments