Skip to content

Commit 1bd2e11

Browse files
committed
Removing NPOT checks since it’s required by GLES2 and has been universally supported by Macs since at least 2007.
1 parent d4ff491 commit 1bd2e11

File tree

6 files changed

+6
-71
lines changed

6 files changed

+6
-71
lines changed

cocos2d/CCConfiguration.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ typedef NS_ENUM(NSUInteger, CCDevice) {
7575

7676
GLint _maxTextureSize;
7777
BOOL _supportsPVRTC;
78-
BOOL _supportsNPOT;
7978
BOOL _supportsBGRA8888;
8079
BOOL _supportsDiscardFramebuffer;
8180
BOOL _supportsShareableVAO;
@@ -92,12 +91,6 @@ typedef NS_ENUM(NSUInteger, CCDevice) {
9291
*/
9392
@property (nonatomic, readonly) GLint maxTextureUnits;
9493

95-
/** Whether or not the GPU supports NPOT (Non Power Of Two) textures.
96-
OpenGL ES 2.0 already supports NPOT (iOS).
97-
98-
*/
99-
@property (nonatomic, readonly) BOOL supportsNPOT;
100-
10194
/** Whether or not PVR Texture Compressed is supported */
10295
@property (nonatomic, readonly) BOOL supportsPVRTC;
10396

cocos2d/CCConfiguration.m

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ @implementation CCConfiguration
4444

4545
@synthesize maxTextureSize = _maxTextureSize, maxTextureUnits=_maxTextureUnits;
4646
@synthesize supportsPVRTC = _supportsPVRTC;
47-
@synthesize supportsNPOT = _supportsNPOT;
4847
@synthesize supportsBGRA8888 = _supportsBGRA8888;
4948
@synthesize supportsDiscardFramebuffer = _supportsDiscardFramebuffer;
5049
@synthesize supportsShareableVAO = _supportsShareableVAO;
@@ -182,12 +181,6 @@ -(void) getOpenGLvariables
182181
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &_maxTextureSize);
183182
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &_maxTextureUnits );
184183

185-
#ifdef __CC_PLATFORM_IOS
186-
_supportsNPOT = YES;
187-
#elif defined(__CC_PLATFORM_MAC)
188-
_supportsNPOT = [self checkForGLExtension:@"GL_ARB_texture_non_power_of_two"];
189-
#endif
190-
191184
_supportsPVRTC = [self checkForGLExtension:@"GL_IMG_texture_compression_pvrtc"];
192185

193186
// It seems that somewhere between firmware iOS 3.0 and 4.2 Apple renamed
@@ -222,14 +215,6 @@ -(GLint) maxTextureUnits
222215
return _maxTextureUnits;
223216
}
224217

225-
-(BOOL) supportsNPOT
226-
{
227-
if( ! _openGLInitialized )
228-
[self getOpenGLvariables];
229-
230-
return _supportsNPOT;
231-
}
232-
233218
-(BOOL) supportsPVRTC
234219
{
235220
if( ! _openGLInitialized )
@@ -308,7 +293,6 @@ -(void) dumpInfo
308293
printf("cocos2d: GL_MAX_SAMPLES: %d\n", _maxSamplesAllowed);
309294
printf("cocos2d: GL supports PVRTC: %s\n", (_supportsPVRTC ? "YES" : "NO") );
310295
printf("cocos2d: GL supports BGRA8888 textures: %s\n", (_supportsBGRA8888 ? "YES" : "NO") );
311-
printf("cocos2d: GL supports NPOT textures: %s\n", (_supportsNPOT ? "YES" : "NO") );
312296
printf("cocos2d: GL supports discard_framebuffer: %s\n", (_supportsDiscardFramebuffer ? "YES" : "NO") );
313297
printf("cocos2d: GL supports shareable VAO: %s\n", (_supportsShareableVAO ? "YES" : "NO") );
314298

cocos2d/CCEffectRenderer.m

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,27 +51,12 @@ - (BOOL)setupGLResourcesWithSize:(CGSize)size
5151

5252
glPushGroupMarkerEXT(0, "CCEffectRenderTarget: allocateRenderTarget");
5353

54-
// Textures may need to be a power of two
55-
NSUInteger powW;
56-
NSUInteger powH;
57-
58-
if( [[CCConfiguration sharedConfiguration] supportsNPOT] )
59-
{
60-
powW = size.width;
61-
powH = size.height;
62-
}
63-
else
64-
{
65-
powW = CCNextPOT(size.width);
66-
powH = CCNextPOT(size.height);
67-
}
68-
6954
static const CCTexturePixelFormat kRenderTargetDefaultPixelFormat = CCTexturePixelFormat_RGBA8888;
7055
static const float kRenderTargetDefaultContentScale = 1.0f;
7156

7257
// Create a new texture object for use as the color attachment of the new
7358
// FBO.
74-
_texture = [[CCTexture alloc] initWithData:nil pixelFormat:kRenderTargetDefaultPixelFormat pixelsWide:powW pixelsHigh:powH contentSizeInPixels:size contentScale:kRenderTargetDefaultContentScale];
59+
_texture = [[CCTexture alloc] initWithData:nil pixelFormat:kRenderTargetDefaultPixelFormat pixelsWide:size.width pixelsHigh:size.height contentSizeInPixels:size contentScale:kRenderTargetDefaultContentScale];
7560
[_texture setAliasTexParameters];
7661

7762
// Save the old FBO binding so it can be restored after we create the new

cocos2d/CCRenderTexture.m

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -157,21 +157,8 @@ -(void)create
157157

158158
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO);
159159

160-
// textures must be power of two
161-
NSUInteger powW;
162-
NSUInteger powH;
163-
164-
if( [[CCConfiguration sharedConfiguration] supportsNPOT] ) {
165-
powW = pixelW;
166-
powH = pixelH;
167-
} else {
168-
powW = CCNextPOT(pixelW);
169-
powH = CCNextPOT(pixelH);
170-
}
171-
172-
void *data = calloc(powW*powH, 4);
173-
174-
CCTexture *texture = [[CCTexture alloc] initWithData:data pixelFormat:_pixelFormat pixelsWide:powW pixelsHigh:powH contentSizeInPixels:CGSizeMake(pixelW, pixelH) contentScale:_contentScale];
160+
void *data = calloc(pixelW*pixelH, 4);
161+
CCTexture *texture = [[CCTexture alloc] initWithData:data pixelFormat:_pixelFormat pixelsWide:pixelW pixelsHigh:pixelH contentSizeInPixels:CGSizeMake(pixelW, pixelH) contentScale:_contentScale];
175162
self.texture = texture;
176163

177164
free(data);
@@ -192,7 +179,7 @@ -(void)create
192179
//create and attach depth buffer
193180
glGenRenderbuffers(1, &depthRenderBuffer);
194181
glBindRenderbuffer(GL_RENDERBUFFER, depthRenderBuffer);
195-
glRenderbufferStorage(GL_RENDERBUFFER, _depthStencilFormat, (GLsizei)powW, (GLsizei)powH);
182+
glRenderbufferStorage(GL_RENDERBUFFER, _depthStencilFormat, (GLsizei)pixelW, (GLsizei)pixelH);
196183
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderBuffer);
197184

198185
// if depth format is the one with stencil part, bind same render buffer as stencil attachment

cocos2d/CCTexture.m

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -396,16 +396,8 @@ - (id) initWithCGImage:(CGImageRef)cgImage contentScale:(CGFloat)contentScale
396396
pixelFormat = CCTexturePixelFormat_A8;
397397
}
398398

399-
if( ! [conf supportsNPOT] )
400-
{
401-
textureWidth = CCNextPOT(CGImageGetWidth(cgImage));
402-
textureHeight = CCNextPOT(CGImageGetHeight(cgImage));
403-
}
404-
else
405-
{
406-
textureWidth = CGImageGetWidth(cgImage);
407-
textureHeight = CGImageGetHeight(cgImage);
408-
}
399+
textureWidth = CGImageGetWidth(cgImage);
400+
textureHeight = CGImageGetHeight(cgImage);
409401

410402
#ifdef __CC_PLATFORM_IOS
411403

cocos2d/CCTexturePVR.m

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,6 @@ - (BOOL)unpackPVRv2Data:(unsigned char*)data PVRLen:(NSUInteger)len
299299
if( flipped )
300300
CCLOGWARN(@"cocos2d: WARNING: Image is flipped. Regenerate it using PVRTexTool");
301301

302-
if( ! [configuration supportsNPOT] &&
303-
( header->width != CCNextPOT(header->width) || header->height != CCNextPOT(header->height ) ) ) {
304-
CCLOGWARN(@"cocos2d: ERROR: Loding an NPOT texture (%dx%d) but is not supported on this device", header->width, header->height);
305-
return NO;
306-
}
307-
308302
for( NSUInteger i=0; i < (unsigned int)PVR2_MAX_TABLE_ELEMENTS ; i++) {
309303
if( v2_pixel_formathash[i].pixelFormat == formatFlags ) {
310304

0 commit comments

Comments
 (0)