CCPageTurnTransition missing triangles on iPad When Forward and Backward

Forums Programming cocos2d support (graphics engine) CCPageTurnTransition missing triangles on iPad When Forward and Backward

This topic contains 13 replies, has 5 voices, and was last updated by  abitofcode 3 years, 7 months ago.

Viewing 14 posts - 1 through 14 (of 14 total)
Author Posts
Author Posts
August 21, 2010 at 5:19 am #224150

ashmira
Participant
@ashlovemira

I got missing triangles for CCPageTurnTransition at the left side of Ipad when i replace the scene.

Note that I have used :

[[CCDirector sharedDirector] setDepthBufferFormat:kDepthBuffer16];

and put at delegate method but my app crash and shown this error

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'A Director was alloced. setDirectorType must be the first call to Director

i also try to change cocos2d/CCPageTurn3DAction.m but still got the triangle. Currently im using cocos2d version 0.99.4-rc3.

// Stop z coord from dropping beneath underlying page in a transition
if( p.z<0.9f )
p.z = 0.9f;

August 21, 2010 at 8:45 am #295243

neophit
@neophit

setDepthBufferFormat is deprecated in 0.99.4.

Here is the code I am using in 0.99.5 to set a 16-bit depth buffer:

window = UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds;
if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] )
[CCDirector setDirectorType:kCCDirectorTypeNSTimer];
CCDirector *director = [CCDirector sharedDirector];
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
[director setDisplayFPS:YES];
[director setAnimationInterval:1.0/60];
EAGLView *glView = [EAGLView viewWithFrame:[window bounds]
pixelFormat:kEAGLColorFormatRGB565
depthFormat:GL_DEPTH_COMPONENT16_OES
preserveBackbuffer:NO];
[director setOpenGLView:glView];
[window addSubview:glView];
[window makeKeyAndVisible];

I copied and modified code from the CC_DIRECTOR_INIT() function.

August 21, 2010 at 12:17 pm #295244

ashmira
Participant
@ashlovemira

Thanks neophit for the help…

and wanna to ask… should i copy all of this of code in order to set Depth Buffer?

Can i know why this code wont work?

[[CCDirector sharedDirector] setDepthBufferFormat:kDepthBuffer16];

after i copy you code and put into appDelegate after CC_DIRECTOR_INIT();

it shown error

Program received signal:  “SIGABRT”.
Assertion failed: (cls), function getName, file /SourceCache/objc4_Sim/objc4-427.1.1/runtime/objc-runtime-new.m, line 3939.

The error was mark at this code

if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] )
[CCDirector setDirectorType:kCCDirectorTypeNSTimer];

August 21, 2010 at 6:18 pm #295245

neophit
@neophit

CC_DIRECTOR_INIT() performs the following tasks on your behalf:

1. Initializes an EAGLView with 0-bit depth format, and RGB565 render buffer

2. EAGLView multiple touches: disabled

3. creates a UIWindow, and assign it to the “window” var (it must already be declared)

4. Parents EAGLView to the newly created window

5. Creates Display Link Director

5a. If it fails, it will use an NSTimer director

6. It will try to run at 60 FPS

7. Display FPS: NO

8. Device orientation: Portrait

9. Connects the director to the EAGLView

Since setDepthBufferFormat has been deprecated the API is no longer supported. The depth buffer is now set for you inside the CC_DIRECTOR_INIT() function. To set a different depth buffer, you could modify the CC_DIRECTOR_INIT() function or copy and modify the code like I showed in my last post. If you choose the latter, you need to comment out the call to CC_DIRECTOR_INIT() and paste the code below it.

If anyone knows an easier way to just set the depth buffer, please speak up.

August 22, 2010 at 5:07 am #295246

ashmira
Participant
@ashlovemira

So means i only set to this in the CCDirector.m

- (id) init
{
CCLOG(@"cocos2d: %@", cocos2dVersion() );

if( (self=[super init]) ) {

CCLOG(@"cocos2d: Using Director Type:%@", [self class]);

// default values
pixelFormat_ = kCCPixelFormatDefault;
//depthBufferFormat_ = 0;
depthBufferFormat_ = kDepthBuffer16;

// scenes
runningScene_ = nil;
nextScene_ = nil;

oldAnimationInterval = animationInterval = 1.0 / kDefaultFPS;
scenesStack_ = [[NSMutableArray alloc] initWithCapacity:10];

// landscape
deviceOrientation_ = CCDeviceOrientationPortrait;

// FPS
displayFPS = NO;
frames = 0;

// paused ?
isPaused_ = NO;

contentScaleFactor_ = 1;
screenSize_ = surfaceSize_ = CGSizeZero;
isHighResDevice_ = NO;
}

return self;
}

after i change into this i still can see the page flip transition still got missing triangle on simulator. if there any missing code that should i insert?

August 22, 2010 at 5:08 am #295247

ashmira
Participant
@ashlovemira

So means i only set to this in the CCDirector.m

- (id) init
{
CCLOG(@"cocos2d: %@", cocos2dVersion() );

if( (self=[super init]) ) {

CCLOG(@"cocos2d: Using Director Type:%@", [self class]);

// default values
pixelFormat_ = kCCPixelFormatDefault;
//depthBufferFormat_ = 0;
depthBufferFormat_ = kDepthBuffer16;

// scenes
runningScene_ = nil;
nextScene_ = nil;

oldAnimationInterval = animationInterval = 1.0 / kDefaultFPS;
scenesStack_ = [[NSMutableArray alloc] initWithCapacity:10];

// landscape
deviceOrientation_ = CCDeviceOrientationPortrait;

// FPS
displayFPS = NO;
frames = 0;

// paused ?
isPaused_ = NO;

contentScaleFactor_ = 1;
screenSize_ = surfaceSize_ = CGSizeZero;
isHighResDevice_ = NO;
}

return self;
}

after i change into this i still can see the page flip transition still got missing triangle on simulator. if there any missing code that should i insert?

August 22, 2010 at 6:58 am #295248

neophit
@neophit

Are you seeing the triangles on the device? I also see artifacts in the simulator, but they do not appear on my device.

August 22, 2010 at 10:37 am #295249

abitofcode
Moderator
@abitofcode

I’m using cocos2d v0.99.4, the depthFormat settings is in ccMacros.h in the CC_DIRECTOR_INIT() macro

August 22, 2010 at 2:34 pm #295250

ashmira
Participant
@ashlovemira

thanks alot abitofcode and neophit spending your time to solve my problem. yeah the code that neophit talk about i can see in CCMacros.h

#define CC_DIRECTOR_INIT()																		
do {
window = UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds;
if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] )
[CCDirector setDirectorType:kCCDirectorTypeNSTimer];
CCDirector *__director = [CCDirector sharedDirector];
[__director setDeviceOrientation:kCCDeviceOrientationPortrait];
[__director setDisplayFPS:NO];
[__director setAnimationInterval:1.0/60];
EAGLView *__glView = [EAGLView viewWithFrame:[window bounds]
pixelFormat:kEAGLColorFormatRGB565
depthFormat:0
preserveBackbuffer:NO];
[__director setOpenGLView:__glView];
[window addSubview:__glView];
[window makeKeyAndVisible];
} while(0)

i just changed depthFormat:0 to depthFormat:GL_DEPTH_COMPONENT24_OES and it works.

But if i change to GL_DEPTH_COMPONENT16_OES it also works but the frame rate drops alot. i testing on simulator… will be tested on device tomorrow. :)

September 3, 2010 at 10:01 pm #295251

kelcel
@kelcel

Hi All! Can anyone post some example source code to show how the CCPageTurnTransition function works on a real apps? Thanks!

September 3, 2010 at 11:04 pm #295252

abitofcode
Moderator
@abitofcode

There is sample code in the tests directory when you down load cocos2d. Use Shift + Command + F to search across the whole project and you’ll find it.

September 7, 2010 at 6:20 pm #295253

kelcel
@kelcel

I downloaded and installed cocos2d in xcode and the only sample I have is the “Cocos2DSimpleGame”. I searched thru the directory and couldn’t find any “tests directory” that you mentioned. Please help! Thanks!

September 7, 2010 at 7:32 pm #295254

dany
Participant
@daniele1988

http://www.cocos2d-iphone.org/archives/663

or step 2 here

http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:lesson_1._install_test

September 7, 2010 at 8:54 pm #295255

abitofcode
Moderator
@abitofcode

Open the project file in the cocos2d directory rather than creating a cocos2d application from the template, the templates will not add the test code to a project.

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.