@@ -29,15 +29,15 @@ var TileSprite = new Class({
2929
3030 function TileSprite ( scene , x , y , width , height , texture , frame )
3131 {
32- var resourceManager = scene . sys . game . renderer . resourceManager ;
32+ var renderer = scene . sys . game . renderer ;
3333
3434 GameObject . call ( this , scene , 'TileSprite' ) ;
3535
3636 this . tilePositionX = 0 ;
3737 this . tilePositionY = 0 ;
3838 this . dirty = true ;
3939 this . tileTexture = null ;
40- this . renderer = null ;
40+ this . renderer = renderer ;
4141
4242 this . setTexture ( texture , frame ) ;
4343 this . setPosition ( x , y ) ;
@@ -47,26 +47,16 @@ var TileSprite = new Class({
4747 this . potWidth = GetPowerOfTwo ( this . frame . width ) ;
4848 this . potHeight = GetPowerOfTwo ( this . frame . height ) ;
4949 this . canvasPattern = null ;
50-
51- if ( resourceManager )
52- {
53- this . renderer = scene . sys . game . renderer ;
54- var gl = scene . sys . game . renderer . gl ;
55-
56- this . tileTexture = resourceManager . createTexture ( 0 , gl . LINEAR , gl . LINEAR , gl . REPEAT , gl . REPEAT , gl . RGBA , this . canvasBuffer , this . potWidth , this . potHeight ) ;
57- }
58-
5950 this . canvasBuffer = CanvasPool . create2D ( null , this . potWidth , this . potHeight ) ;
6051 this . canvasBufferCtx = this . canvasBuffer . getContext ( '2d' ) ;
6152
6253 this . updateTileTexture ( ) ;
6354
64- var _this = this ;
6555 scene . sys . game . renderer . onContextRestored ( function ( renderer ) {
66- _this . tileTexture = null ;
67- _this . dirty = true ;
68- _this . tileTexture = resourceManager . createTexture ( 0 , gl . LINEAR , gl . LINEAR , gl . REPEAT , gl . REPEAT , gl . RGBA , _this . canvasBuffer , _this . potWidth , _this . potHeight ) ;
69- } ) ;
56+ this . tileTexture = null ;
57+ this . dirty = true ;
58+ this . tileTexture = renderer . createTexture2D ( 0 , gl . LINEAR , gl . LINEAR , gl . REPEAT , gl . REPEAT , gl . RGBA , this . canvasBuffer , this . potWidth , this . potHeight ) ;
59+ } , this ) ;
7060 } ,
7161
7262 updateTileTexture : function ( )
@@ -84,9 +74,9 @@ var TileSprite = new Class({
8474 this . potWidth , this . potHeight
8575 ) ;
8676
87- if ( this . renderer )
77+ if ( this . renderer . gl )
8878 {
89- this . renderer . uploadCanvasToGPU ( this . canvasBuffer , this . tileTexture , false ) ;
79+ this . tileTexture = this . renderer . canvasToTexture ( this . canvasBuffer , this . tileTexture , ( this . tileTexture === null ) , this . scaleMode ) ;
9080 }
9181 else
9282 {
@@ -100,7 +90,7 @@ var TileSprite = new Class({
10090 {
10191 if ( this . renderer )
10292 {
103- this . renderer . gl . deleteTexture ( this . tileTexture ) ;
93+ this . renderer . deleteTexture ( this . tileTexture ) ;
10494 }
10595
10696 CanvasPool . remove ( this . canvasBuffer ) ;
0 commit comments