Skip to content

Commit ad3f526

Browse files
committed
Adding assertions for not-yet-implemented functionality for Metal.
1 parent e4563bd commit ad3f526

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

cocos2d/CCClippingNode.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#import "CCNode_Private.h"
3636
#import "CCRenderDispatch.h"
37+
#import "CCConfiguration.h"
3738

3839
static GLint _stencilBits = -1;
3940

@@ -69,6 +70,8 @@ - (id)init
6970

7071
- (id)initWithStencil:(CCNode *)stencil
7172
{
73+
NSAssert([CCConfiguration sharedConfiguration].graphicsAPI == CCGraphicsAPIGL, @"CCClippingNode is not supported by the Metal renderer yet.");
74+
7275
if (self = [super init]) {
7376
self.stencil = stencil;
7477
self.alphaThreshold = 1;

cocos2d/CCRenderTexture.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#import "CCRenderer_Private.h"
4040
#import "CCRenderTexture_Private.h"
4141
#import "CCRenderDispatch.h"
42+
#import "CCMetalSupport_Private.h"
4243

4344
#if __CC_PLATFORM_MAC
4445
#import <ApplicationServices/ApplicationServices.h>
@@ -385,6 +386,10 @@ -(void)draw:(CCRenderer *)renderer transform:(const GLKMatrix4 *)transform
385386

386387
-(CGImageRef) newCGImage
387388
{
389+
// TODO need to find out why getting pixels from a Metal texture doesn't seem to work.
390+
// Workaround - use pixel buffers and a copy encoder?
391+
NSAssert([CCConfiguration sharedConfiguration].graphicsAPI == CCGraphicsAPIGL, @"[CCRenderTexture -newCGImage] is only supported for GL.");
392+
388393
NSAssert(_pixelFormat == CCTexturePixelFormat_RGBA8888,@"only RGBA8888 can be saved as image");
389394

390395
CGSize s = [self.texture contentSizeInPixels];
@@ -415,7 +420,7 @@ -(CGImageRef) newCGImage
415420
[self end];
416421

417422
// make data provider with data.
418-
423+
// TODO find out why iref can't be used as the return value.
419424
CGBitmapInfo bitmapInfo = kCGImageAlphaPremultipliedLast | kCGBitmapByteOrderDefault;
420425
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, buffer, myDataLength, NULL);
421426
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();

cocos2d/CCTexturePVR.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ - (BOOL)unpackPVRv3Data:(unsigned char*)dataPointer PVRLen:(NSUInteger)dataLengt
506506

507507
- (BOOL)createGLTexture
508508
{
509+
NSAssert([CCConfiguration sharedConfiguration].graphicsAPI == CCGraphicsAPIGL, @"PVR textures are not yet supported by Metal.");
509510
__block BOOL retVal = NO;
510511

511512
CCRenderDispatch(NO, ^{

0 commit comments

Comments
 (0)