void CCGridBase::afterDraw(cocos2d::CCNode *pTarget) { m_pGrabber->afterRender(m_pTexture); set3DProjection(); applyLandscape(); if (pTarget->getCamera()->getDirty()) { const CCPoint& offset = pTarget->getAnchorPointInPixels(); // // XXX: Camera should be applied in the AnchorPoint // ccglTranslate(offset.x, offset.y, 0); pTarget->getCamera()->locate(); ccglTranslate(-offset.x, -offset.y, 0); } glBindTexture(GL_TEXTURE_2D, m_pTexture->getName()); // restore projection for default FBO .fixed bug #543 #544 CCDirector::sharedDirector()->setProjection(CCDirector::sharedDirector()->getProjection()); CCDirector::sharedDirector()->applyOrientation(); blit(); }
void CCGridBase::afterDraw(cocos2d::CCNode *pTarget) { m_pGrabber->afterRender(m_pTexture); set3DProjection(); applyLandscape(); if (pTarget->getCamera()->getDirty()) { CCPoint offset = pTarget->getAnchorPointInPixels(); // // XXX: Camera should be applied in the AnchorPoint // ccglTranslate(offset.x, offset.y, 0); pTarget->getCamera()->locate(); ccglTranslate(-offset.x, -offset.y, 0); } glBindTexture(GL_TEXTURE_2D, m_pTexture->getName()); blit(); }
void CCNode::transform() { // transformations #if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX // BEGIN alternative -- using cached transform // if( m_bIsTransformGLDirty ) { CCAffineTransform t = this->nodeToParentTransform(); CGAffineToGL(&t, m_pTransformGL); m_bIsTransformGLDirty = false; } glMultMatrixf(m_pTransformGL); if( m_fVertexZ ) { glTranslatef(0, 0, m_fVertexZ); } // XXX: Expensive calls. Camera should be integrated into the cached affine matrix if (m_pCamera && !(m_pGrid && m_pGrid->isActive())) { bool translate = (m_tAnchorPointInPixels.x != 0.0f || m_tAnchorPointInPixels.y != 0.0f); if( translate ) { ccglTranslate(RENDER_IN_SUBPIXEL(m_tAnchorPointInPixels.x), RENDER_IN_SUBPIXEL(m_tAnchorPointInPixels.y), 0); } m_pCamera->locate(); if( translate ) { ccglTranslate(RENDER_IN_SUBPIXEL(-m_tAnchorPointInPixels.x), RENDER_IN_SUBPIXEL(-m_tAnchorPointInPixels.y), 0); } } // END alternative #else // BEGIN original implementation // // translate if ( m_bIsRelativeAnchorPoint && (m_tAnchorPointInPixels.x != 0 || m_tAnchorPointInPixels.y != 0 ) ) glTranslatef( RENDER_IN_SUBPIXEL(-m_tAnchorPointInPixels.x), RENDER_IN_SUBPIXEL(-m_tAnchorPointInPixels.y), 0); if (m_tAnchorPointInPixels.x != 0 || m_tAnchorPointInPixels.y != 0) glTranslatef( RENDER_IN_SUBPIXEL(m_tPositionInPixels.x + m_tAnchorPointInPixels.x), RENDER_IN_SUBPIXEL(m_tPositionInPixels.y + m_tAnchorPointInPixels.y), m_fVertexZ); else if ( m_tPositionInPixels.x !=0 || m_tPositionInPixels.y !=0 || m_fVertexZ != 0) glTranslatef( RENDER_IN_SUBPIXEL(m_tPositionInPixels.x), RENDER_IN_SUBPIXEL(m_tPositionInPixels.y), m_fVertexZ ); // rotate if (m_fRotation != 0.0f ) glRotatef( -m_fRotation, 0.0f, 0.0f, 1.0f ); // scale if (m_fScaleX != 1.0f || m_fScaleY != 1.0f) glScalef( m_fScaleX, m_fScaleY, 1.0f ); if ( m_pCamera && !(m_pGrid && m_pGrid->isActive()) ) m_pCamera->locate(); // restore and re-position point if (m_tAnchorPointInPixels.x != 0.0f || m_tAnchorPointInPixels.y != 0.0f) glTranslatef(RENDER_IN_SUBPIXEL(-m_tAnchorPointInPixels.x), RENDER_IN_SUBPIXEL(-m_tAnchorPointInPixels.y), 0); // // END original implementation #endif }