Skip to content

Commit c264735

Browse files
committed
Fixes for headless.
1 parent 29938b4 commit c264735

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

CCRendererGLSupport.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,8 @@ -(instancetype)initWithTexture:(CCTexture *)texture depthStencilFormat:(GLuint)d
266266
// associate texture with FBO
267267
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.name, 0);
268268

269-
CGSize sizeInPixels = texture.contentSizeInPixels;
270-
GLuint width = ceil(sizeInPixels.width);
271-
GLuint height = ceil(sizeInPixels.height);
269+
GLuint width = texture.pixelWidth;
270+
GLuint height = texture.pixelHeight;
272271

273272
#if __CC_PLATFORM_ANDROID
274273

cocos2d-ios.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@
521521
D2FEB745194F6C9E00FC0574 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A06D9C131728D5F600704732 /* CoreText.framework */; };
522522
D2FEB747194F6C9E00FC0574 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
523523
D2FEB749194F6C9E00FC0574 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D3623EB0D0F72F000981E51 /* CoreGraphics.framework */; };
524+
D3027C8719D33FFB00006004 /* NSValue+CCRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = D34CAD6219C3A0FD009BED7A /* NSValue+CCRenderer.m */; };
524525
D309055018AC23110081BF11 /* CCRenderer_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D309054F18AC23110081BF11 /* CCRenderer_Private.h */; };
525526
D31C795019994126007921E1 /* CCMetalSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = D31C794F19994126007921E1 /* CCMetalSupport.m */; };
526527
D31C795219994197007921E1 /* CCMetalSupport_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D31C795119994197007921E1 /* CCMetalSupport_Private.h */; };
@@ -2334,6 +2335,7 @@
23342335
isa = PBXSourcesBuildPhase;
23352336
buildActionMask = 2147483647;
23362337
files = (
2338+
D3027C8719D33FFB00006004 /* NSValue+CCRenderer.m in Sources */,
23372339
57202D391970776100238D56 /* CCPlatformTextFieldAndroid.m in Sources */,
23382340
D2FEB6B9194F6C9E00FC0574 /* CCAction.m in Sources */,
23392341
D299CE7D19C2910B00519CBB /* CCEffectDFInnerGlow.m in Sources */,

cocos2d-tests-android/Headless.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,7 @@
983983
buildSettings = {
984984
ANDROID_MANIFEST = "$(SRCROOT)//Headless/src/main/AndroidManifest.xml";
985985
ANDROID_RES_DIRS = "$(SRCROOT)//Headless/src/main/res";
986+
APPORTABLE_TARGET = Android;
986987
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
987988
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
988989
FRAMEWORK_SEARCH_PATHS = (
@@ -1020,6 +1021,7 @@
10201021
buildSettings = {
10211022
ANDROID_MANIFEST = "$(SRCROOT)//Headless/src/main/AndroidManifest.xml";
10221023
ANDROID_RES_DIRS = "$(SRCROOT)//Headless/src/main/res";
1024+
APPORTABLE_TARGET = Android;
10231025
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
10241026
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
10251027
FRAMEWORK_SEARCH_PATHS = (

cocos2d/CCDirector.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ - (id) init
203203
_rendererPool = [NSMutableArray array];
204204
_globalShaderUniforms = [NSMutableDictionary dictionary];
205205

206+
// Force the graphics API to be selected if it hasn't already done so.
207+
// Startup code is annoyingly different for iOS/Mac/Android.
208+
[[CCConfiguration sharedConfiguration] graphicsAPI];
206209
_framebuffer = [[CCFrameBufferObjectClass alloc] init];
207210
}
208211

cocos2d/CCRenderer.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ +(void)bindRenderer:(CCRenderer *)renderer
272272

273273
-(void)prepareWithProjection:(const GLKMatrix4 *)projection framebuffer:(CCFrameBufferObject *)framebuffer
274274
{
275+
NSAssert(framebuffer, @"Framebuffer cannot be nil.");
275276
CCDirector *director = [CCDirector sharedDirector];
276277

277278
// Copy in the globals from the director.

cocos2d/Platforms/Mac/CCGLView.m

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,6 @@ - (void) prepareOpenGL
166166
GLint swapInt = 1;
167167
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
168168

169-
// Force the graphics API to be set up as early as possible.
170-
[[CCConfiguration sharedConfiguration] graphicsAPI];
171-
172169
// GLint order = -1;
173170
// [[self openGLContext] setValues:&order forParameter:NSOpenGLCPSurfaceOrder];
174171
}

0 commit comments

Comments
 (0)