Retina graphics error on iOS
Re: Retina graphics error on iOS
thanks, sounds great!
Re: Retina graphics error on iOS
I spent a while on this but I don't think it requires a separate sample loader after all. It comes down to the first line you changed, where contentSizeInPixels is no longer available. It seems that v2 removes the need to use contentScaleFactor all over the place to handle the different device types. Basically, anywhere in the RUBE sample code that you see contentScaleFactor used, you can ignore it.
Specifically there are two lines that need to be changed. The first is the one you identified already:
Before:
[sprite setScale:img->scale / [sprite contentSizeInPixels].height * contentScaleFactor ];
After:
[sprite setScale:img->scale / [sprite contentSize].height ];
Actually, if you don't want to use debug draw, that's all you should need to change. If you do want to use debug draw (and I highly recommend having it available to see what's happening), you will also need to change the other place where contentScaleFactor is used, in BasicRUBELayer.mm:
Before:
m_debugDraw = new GLESDebugDraw( [[CCDirector sharedDirector] contentScaleFactor] );
After:
m_debugDraw = new GLESDebugDraw( 1 );
Of course, to actually get the debug draw rendering with the newer shader model method, you'll also need to copy the way it is done in the HelloWorldLayer from the template, but I guess you have figured that out already. In any case, I ended up with something like this:
I understand how tricky these things can be, so thanks for sticking with it. Even when there is a 50/50 chance it's still easy to go the wrong way, and things get more confusing when you start changing places that didn't actually need to be changed, because somebody who sounded like they knew what they were talking about suggested it 
Specifically there are two lines that need to be changed. The first is the one you identified already:
Before:
[sprite setScale:img->scale / [sprite contentSizeInPixels].height * contentScaleFactor ];
After:
[sprite setScale:img->scale / [sprite contentSize].height ];
Actually, if you don't want to use debug draw, that's all you should need to change. If you do want to use debug draw (and I highly recommend having it available to see what's happening), you will also need to change the other place where contentScaleFactor is used, in BasicRUBELayer.mm:
Before:
m_debugDraw = new GLESDebugDraw( [[CCDirector sharedDirector] contentScaleFactor] );
After:
m_debugDraw = new GLESDebugDraw( 1 );
Of course, to actually get the debug draw rendering with the newer shader model method, you'll also need to copy the way it is done in the HelloWorldLayer from the template, but I guess you have figured that out already. In any case, I ended up with something like this:
Code: Select all
-(void) draw
{
if ( !m_world )
return;
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
kmGLPushMatrix();
m_world->DrawDebugData();
if ( m_mouseJoint ) {
b2Vec2 p1 = m_mouseJoint->GetAnchorB();
b2Vec2 p2 = m_mouseJoint->GetTarget();
b2Color c;
c.Set(0.0f, 1.0f, 0.0f);
m_debugDraw->DrawPoint(p1, 4.0f, c);
m_debugDraw->DrawPoint(p2, 4.0f, c);
c.Set(0.8f, 0.8f, 0.8f);
m_debugDraw->DrawSegment(p1, p2, c);
}
kmGLPopMatrix();
}

Re: Retina graphics error on iOS
finally! it works and looks great!
I had the correct draw method so I only had to change two lines of code... crazy!
thanks a lot for your efforts mate! appreciate it.
I had the correct draw method so I only had to change two lines of code... crazy!
thanks a lot for your efforts mate! appreciate it.

Re: Retina graphics error on iOS
I updated the Cocos2d sample loader to build for both v1 and v2. This meant that the Cocos2d source code itself is now removed from the download, which was probably a better idea anyway.
RUBE with Cocos2d setup
http://www.youtube.com/watch?v=UT-uGUcnMW0
RUBE with Cocos2d setup
http://www.youtube.com/watch?v=UT-uGUcnMW0
Re: Retina graphics error on iOS
just watched the video, great job!