@@ -6,6 +6,7 @@ var Commands = require('./Commands');
66var MATH_CONST = require ( '../../math/const' ) ;
77var GetValue = require ( '../../utils/object/GetValue' ) ;
88var CanvasPool = require ( '../../dom/CanvasPool' ) ;
9+ var Camera = require ( '../../camera/Camera.js' ) ;
910
1011var Graphics = new Class ( {
1112
@@ -42,9 +43,6 @@ var Graphics = new Class({
4243
4344 this . setDefaultStyles ( options ) ;
4445
45- this . dstRenderTexture = null ;
46- this . dstRenderTarget = null ;
47-
4846 var resourceManager = state . game . renderer . resourceManager ;
4947
5048 if ( resourceManager !== undefined )
@@ -382,41 +380,32 @@ var Graphics = new Class({
382380 return this ;
383381 } ,
384382
385- createRenderTarget : function ( width , height )
386- {
387- var resourceManager = this . resourceManager ;
388- if ( this . dstRenderTarget === null )
389- {
390- if ( resourceManager !== undefined )
391- {
392- var gl = this . gl ;
393- this . dstRenderTexture = resourceManager . createTexture ( 0 , gl . LINEAR , gl . LINEAR , gl . CLAMP_TO_EDGE , gl . CLAMP_TO_EDGE , gl . RGBA , null , width , height ) ;
394- this . dstRenderTarget = resourceManager . createRenderTarget ( width , height , this . dstRenderTexture , null ) ;
395- state . game . renderer . currentTexture = null ; // force rebinding of prev texture
396- }
397- else
398- {
399- this . dstRenderTexture = CanvasPool . create2D ( null , width , height ) ;
400- this . dstRenderTarget = this . dstRenderTexture . getContext ( '2d' ) ;
401- }
402- }
403- } ,
404-
405383 generateTexture : function ( key , width , height )
406384 {
407385 width = ( typeof width === 'number' ) ? width : this . state . game . config . width ;
408386 height = ( typeof height === 'number' ) ? height : this . state . game . config . height ;
409387
410388 if ( this . gl )
411389 {
412- this . state . game . textures . create ( key , null , width , height ) ;
390+ var texture = this . state . game . textures . create ( key , null , width , height ) ;
391+ var glTexture = texture . source [ 0 ] . glTexture ;
392+ var renderTarget = this . resourceManager . createRenderTarget ( width , height , glTexture , null ) ;
393+ glTexture . width = width ;
394+ glTexture . height = height ;
413395 }
414396 else
415397 {
416- this . state . game . textures . createCanvas ( key , width , height ) ;
398+ var texture = this . state . game . textures . createCanvas ( key , width , height ) ;
399+ var ctx = texture . source [ 0 ] . image . getContext ( '2d' ) ;
400+ Graphics . TargetCamera . setViewport ( 0 , 0 , width , height ) ;
401+ Graphics . TargetCamera . scrollX = this . x ;
402+ Graphics . TargetCamera . scrollY = this . y ;
403+ this . renderCanvas ( this . state . game . renderer , this , 0 , Graphics . TargetCamera , ctx ) ;
417404 }
418405 }
419406
420407} ) ;
421408
409+ Graphics . TargetCamera = new Camera ( 0 , 0 , 0 , 0 ) ;
410+
422411module . exports = Graphics ;
0 commit comments