Skip to content

Commit 4dacabf

Browse files
committed
Merge branch 'v3.1' into develop
Conflicts: cocos2d/CCEffectRenderer.m
2 parents 23710fa + 5d4fdb7 commit 4dacabf

19 files changed

+41
-86
lines changed

cocos2d-ui/CCBReader/CCAnimationManager.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ -(void) onEnter {
8585

8686
- (void)addNode:(CCNode*)node andSequences:(NSDictionary*)seq
8787
{
88-
#ifdef DEBUG
88+
#if DEBUG
8989
//Sanity check sequences;
9090

9191
for (NSMutableDictionary* seqNodeProps in seq.allValues) {

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/CCDirector.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ -(void) calculateDeltaTime
265265
_dt = MAX(0,_dt);
266266
}
267267

268-
#ifdef DEBUG
268+
#if DEBUG
269269
// If we are debugging our code, prevent big delta time
270270
if( _dt > 0.2f )
271271
_dt = 1/60.0f;
@@ -864,7 +864,8 @@ -(void) showStats
864864
NSString *fpsstr = [[NSString alloc] initWithFormat:@"%.1f", _frameRate];
865865
[_FPSLabel setString:fpsstr];
866866

867-
NSString *draws = [[NSString alloc] initWithFormat:@"%4lu", (unsigned long)__ccNumberOfDraws];
867+
// Subtract one for the stat label's own batch. This caused a lot of confusion on the forums...
868+
NSString *draws = [[NSString alloc] initWithFormat:@"%4lu", (unsigned long)__ccNumberOfDraws - 1];
868869
[_drawsLabel setString:draws];
869870
}
870871

cocos2d/CCDrawNode.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ @implementation CCDrawNode {
5656

5757
+(void)initialize
5858
{
59+
// +initialize may be called due to loading a subclass.
60+
if(self != [CCDrawNode class]) return;
61+
5962
SHADER = [[CCShader alloc] initWithFragmentShaderSource:FRAGMENT_SHADER_SOURCE];
6063
}
6164

cocos2d/CCEffectRenderer.m

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,11 @@ - (BOOL)setupGLResourcesWithSize:(CGSize)size
5252

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

55-
// Textures may need to be a power of two
56-
NSUInteger powW;
57-
NSUInteger powH;
58-
59-
if( [[CCConfiguration sharedConfiguration] supportsNPOT] )
60-
{
61-
powW = size.width;
62-
powH = size.height;
63-
}
64-
else
65-
{
66-
powW = CCNextPOT(size.width);
67-
powH = CCNextPOT(size.height);
68-
}
69-
7055
static const CCTexturePixelFormat kRenderTargetDefaultPixelFormat = CCTexturePixelFormat_RGBA8888;
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:[CCDirector sharedDirector].contentScaleFactor];
59+
_texture = [[CCTexture alloc] initWithData:nil pixelFormat:kRenderTargetDefaultPixelFormat pixelsWide:size.width pixelsHigh:size.height contentSizeInPixels:size contentScale:[CCDirector sharedDirector].contentScaleFactor];
7560
[_texture setAliasTexParameters];
7661

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

cocos2d/CCNode+Debug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#import "CCNode.h"
2727

28-
#ifdef DEBUG
28+
#if DEBUG
2929

3030
/** Debugging extensions of CCNode. They are available when the DEBUG macro is defined at compile time. */
3131
@interface CCNode (Debug)

cocos2d/CCNode+Debug.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#import "CCNode+Debug.h"
2727
#import "CCNode_Private.h"
2828

29-
#ifdef DEBUG
29+
#if DEBUG
3030

3131
@implementation CCNode (Debug)
3232

cocos2d/CCPhysicsBody.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ -(void)didRemoveFromPhysicsNode:(CCPhysicsNode *)physics
514514
//The following are properties which we track on the parent nodes in order to update the child nodes.
515515
NSString * kDependantProperties[2] = { @"position", @"rotation"};
516516

517-
#ifdef DEBUG
517+
#if DEBUG
518518
//The following are properties which cannot be animated. Changing their values after onEnter in unhandled.
519519
NSString * kRestrictedProperties[3] = { @"scale", @"scaleX", @"scaleY"};
520520
#endif
@@ -531,7 +531,7 @@ -(void)trackParentTransformations:(CCPhysicsNode *)physics
531531
[node addObserver:self forKeyPath:kDependantProperties[i] options:NSKeyValueObservingOptionNew context:nil];
532532
}
533533

534-
#ifdef DEBUG
534+
#if DEBUG
535535
for (int i = 0; i < sizeof(kRestrictedProperties)/sizeof(kRestrictedProperties[0]); i++)
536536
{
537537
[node addObserver:self forKeyPath:kRestrictedProperties[i] options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:nil];
@@ -552,7 +552,7 @@ -(void)removeParentTransformTracking:(CCPhysicsNode *)physics
552552
{
553553
[node removeObserver:self forKeyPath:kDependantProperties[i]];
554554
}
555-
#ifdef DEBUG
555+
#if DEBUG
556556
for (int i = 0; i < sizeof(kRestrictedProperties)/sizeof(kRestrictedProperties[0]); i++)
557557
{
558558
[node removeObserver:self forKeyPath:kRestrictedProperties[i]];
@@ -567,7 +567,7 @@ -(void)removeParentTransformTracking:(CCPhysicsNode *)physics
567567

568568
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
569569
{
570-
#ifdef DEBUG
570+
#if DEBUG
571571
for (int i = 0; i < sizeof(kRestrictedProperties)/sizeof(kRestrictedProperties[0]); i++)
572572
{
573573
if([kRestrictedProperties[i] isEqualToString:keyPath])

cocos2d/CCRenderTexture.m

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

178178
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &_oldFBO);
179179

180-
// textures must be power of two
181-
NSUInteger powW;
182-
NSUInteger powH;
183-
184-
if( [[CCConfiguration sharedConfiguration] supportsNPOT] ) {
185-
powW = pixelW;
186-
powH = pixelH;
187-
} else {
188-
powW = CCNextPOT(pixelW);
189-
powH = CCNextPOT(pixelH);
190-
}
191-
192-
void *data = calloc(powW*powH, 4);
193-
194-
CCTexture *texture = [[CCTexture alloc] initWithData:data pixelFormat:_pixelFormat pixelsWide:powW pixelsHigh:powH contentSizeInPixels:CGSizeMake(pixelW, pixelH) contentScale:_contentScale];
180+
void *data = calloc(pixelW*pixelH, 4);
181+
CCTexture *texture = [[CCTexture alloc] initWithData:data pixelFormat:_pixelFormat pixelsWide:pixelW pixelsHigh:pixelH contentSizeInPixels:CGSizeMake(pixelW, pixelH) contentScale:_contentScale];
195182
self.texture = texture;
196183

197184
free(data);
@@ -212,7 +199,7 @@ -(void)create
212199
//create and attach depth buffer
213200
glGenRenderbuffers(1, &depthRenderBuffer);
214201
glBindRenderbuffer(GL_RENDERBUFFER, depthRenderBuffer);
215-
glRenderbufferStorage(GL_RENDERBUFFER, _depthStencilFormat, (GLsizei)powW, (GLsizei)powH);
202+
glRenderbufferStorage(GL_RENDERBUFFER, _depthStencilFormat, (GLsizei)pixelW, (GLsizei)pixelH);
216203
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderBuffer);
217204

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

0 commit comments

Comments
 (0)