@@ -168,30 +168,32 @@ -(id)init
168
168
}
169
169
170
170
-(void )create
171
+ {
172
+ CGSize pixelSize = CGSizeMake (_contentSize.width * _contentScale, _contentSize.height * _contentScale);
173
+ [self createTextureAndFboWithPixelSize: pixelSize];
174
+ }
175
+
176
+ -(void )createTextureAndFboWithPixelSize : (CGSize)pixelSize
171
177
{
172
178
glPushGroupMarkerEXT (0 , " CCRenderTexture: Create" );
173
179
174
- int pixelW = _contentSize.width *_contentScale;
175
- int pixelH = _contentSize.height *_contentScale;
176
-
177
-
178
180
glGetIntegerv (GL_FRAMEBUFFER_BINDING, &_oldFBO);
179
181
180
182
// textures must be power of two
181
183
NSUInteger powW;
182
184
NSUInteger powH;
183
185
184
186
if ( [[CCConfiguration sharedConfiguration ] supportsNPOT ] ) {
185
- powW = pixelW ;
186
- powH = pixelH ;
187
+ powW = pixelSize. width ;
188
+ powH = pixelSize. height ;
187
189
} else {
188
- powW = CCNextPOT (pixelW );
189
- powH = CCNextPOT (pixelH );
190
+ powW = CCNextPOT (pixelSize. width );
191
+ powH = CCNextPOT (pixelSize. height );
190
192
}
191
193
192
194
void *data = calloc (powW*powH, 4 );
193
195
194
- CCTexture *texture = [[CCTexture alloc ] initWithData: data pixelFormat: _pixelFormat pixelsWide: powW pixelsHigh: powH contentSizeInPixels: CGSizeMake (pixelW, pixelH) contentScale: _contentScale];
196
+ CCTexture *texture = [[CCTexture alloc ] initWithData: data pixelFormat: _pixelFormat pixelsWide: powW pixelsHigh: powH contentSizeInPixels: pixelSize contentScale: _contentScale];
195
197
self.texture = texture;
196
198
197
199
free (data);
@@ -234,6 +236,10 @@ -(void)create
234
236
CC_CHECK_GL_ERROR_DEBUG ();
235
237
glPopGroupMarkerEXT ();
236
238
239
+ // XXX Thayer says: I think this is incorrect for any situations where the content
240
+ // size type isn't (points, points). The call to setTextureRect below eventually arrives
241
+ // at some code that assumes the supplied size is in points so, if the size is not in points,
242
+ // things break.
237
243
CGRect rect = CGRectMake (0 , 0 , _contentSize.width , _contentSize.height );
238
244
239
245
[self assignSpriteTexture ];
@@ -618,6 +624,10 @@ -(void) setContentSize:(CGSize)size
618
624
// TODO: Fix CCRenderTexture so that it correctly handles this
619
625
// NSAssert(NO, @"You cannot change the content size of an already created CCRenderTexture. Recreate it");
620
626
[super setContentSize: size];
627
+
628
+ // XXX Thayer says: I'm pretty sure this is broken since the supplied content size could
629
+ // be normalized, in points, in UI points, etc. We should get the size in points then convert
630
+ // to pixels and use that to make the ortho matrix.
621
631
_projection = GLKMatrix4MakeOrtho (0 .0f , size.width , 0 .0f , size.height , -1024 .0f , 1024 .0f );
622
632
_contentSizeChanged = YES ;
623
633
0 commit comments