Ejemplo n.º 1
0
CCSPXFileData* CCSPXLoader::load(const char* spxPath) {
	unsigned long len;
	string mappedPath = CCUtils::mapLocalPath(spxPath);
	char* data = (char*)CCFileUtils::sharedFileUtils()->getFileData(mappedPath.c_str(), "rb", &len);
	CCSPXFileData* spx = load(data, (size_t)len, 1 / CC_CONTENT_SCALE_FACTOR());
	spx->m_path = spxPath;
	free(data);
	return spx;
}
void ccDrawPoint(const CCPoint& point)
{
	ccVertex2F p = {point.x * CC_CONTENT_SCALE_FACTOR(), point.y * CC_CONTENT_SCALE_FACTOR() };
	// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
	// Needed states: GL_VERTEX_ARRAY, 
	// Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY	
	glDisable(GL_TEXTURE_2D);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);
	
	glVertexPointer(2, GL_FLOAT, 0, &p);	
	glDrawArrays(GL_POINTS, 0, 1);

	// restore default state
	glEnableClientState(GL_COLOR_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glEnable(GL_TEXTURE_2D);	
}
Ejemplo n.º 3
0
void CCDirector::setProjection(ccDirectorProjection kProjection)
{
	CCSize size = m_obWinSizeInPixels;
	switch (kProjection)
	{
	case kCCDirectorProjection2D:
// 		glViewport((GLsizei)0, (GLsizei)0, (GLsizei)size.width, (GLsizei)size.height);
        CCDirector::sharedDirector()->getOpenGLView()->setViewPortInPoints(0, 0, size.width, size.height);
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		ccglOrtho(0, size.width, 0, size.height, -1024 * CC_CONTENT_SCALE_FACTOR(), 
			1024 * CC_CONTENT_SCALE_FACTOR());
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();
		break;

	case kCCDirectorProjection3D:
// 		glViewport(0, 0, (GLsizei)size.width, (GLsizei)size.height);
        CCDirector::sharedDirector()->getOpenGLView()->setViewPortInPoints(0, 0, size.width, size.height);
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		gluPerspective(60, (GLfloat)size.width/size.height, 0.5f, 1500.0f);
			
		glMatrixMode(GL_MODELVIEW);	
		glLoadIdentity();
		gluLookAt( size.width/2, size.height/2, getZEye(),
				 size.width/2, size.height/2, 0,
				 0.0f, 1.0f, 0.0f);				
		break;
			
	case kCCDirectorProjectionCustom:
		if (m_pProjectionDelegate)
		{
			m_pProjectionDelegate->updateProjection();
		}
		break;
			
	default:
		CCLOG("cocos2d: Director: unrecognized projecgtion");
		break;
	}

	m_eProjection = kProjection;
}
Ejemplo n.º 4
0
void CCNode::setPositionInPixels(CCPoint newPosition)
{
    m_tPositionInPixels = newPosition;

	if ( CC_CONTENT_SCALE_FACTOR() == 1)
	{
		m_tPosition = m_tPositionInPixels;
	}
	else
	{
		m_tPosition = ccpMult(newPosition, 1/CC_CONTENT_SCALE_FACTOR());
	}

	m_bIsTransformDirty = m_bIsInverseDirty = true;

#if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
	m_bIsTransformGLDirty = true;
#endif // CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
}
Ejemplo n.º 5
0
void CCCamera::setCenterXYZ(float fCenterX, float fCenterY, float fCenterZ)
{
	float scale = CC_CONTENT_SCALE_FACTOR();

	m_fCenterX = fCenterX * scale;
	m_fCenterY = fCenterY * scale;
	m_fCenterZ = fCenterZ * scale;

	m_bDirty = true;
}
Ejemplo n.º 6
0
//------------------------------------------------------------------
//
// Rookie Guide Layer
//
//------------------------------------------------------------------
void CommonRookieGuide::onEnter()
{
    CommonDemo::onEnter();
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
	
	CCSprite* g1 = CCSprite::create("Images/grossini.png");
	g1->setPosition(ccp(origin.x + visibleSize.width / 4,
                        origin.y + visibleSize.height / 2));
	addChild(g1);
    
    CCSprite* g2 = CCSprite::create("Images/grossini.png");
	g2->setPosition(ccp(origin.x + visibleSize.width * 3 / 4,
                        origin.y + visibleSize.height / 2));
	addChild(g2);
    
    // create rookie guide
    CCSimpleRookieGuide* rg = CCSimpleRookieGuide::create();
    
    // set bg
    rg->setBgColor(ccc4(0xff, 0, 0, 0x4f));
    
    // add region
    rg->addRegion(g2,
                  CCCallFunc::create(this, callfunc_selector(CommonRookieGuide::onGuideClicked)));
    
    // set arrow
    rg->setArrow(CCSprite::create("Images/f1.png"));
    rg->pointToRegionCenter(0, 100 / CC_CONTENT_SCALE_FACTOR(), 200);
    
    // set hint
    CCRichLabelTTF* hint = CCRichLabelTTF::create("[color=0xff0000ff]This is rookie guide, you MUST click it![/color]",
                                                  "Helvetica",
                                                  24 / CC_CONTENT_SCALE_FACTOR(),
                                                  CCSizeMake(150 / CC_CONTENT_SCALE_FACTOR(), 0),
                                                  kCCTextAlignmentLeft);
    rg->setHint(hint);
    rg->shiftHint(-80 / CC_CONTENT_SCALE_FACTOR(), -20 / CC_CONTENT_SCALE_FACTOR());
    
    // add guide layer, must add it after set
    addChild(rg);
}
Ejemplo n.º 7
0
bool CCLabelAtlas::initWithString(const char *theString, const char *fntFile)
{
  std::string pathStr = CCFileUtils::sharedFileUtils()->fullPathForFilename(fntFile);
  std::string relPathStr = pathStr.substr(0, pathStr.find_last_of("/"))+"/";
  CCDictionary *dict = CCDictionary::createWithContentsOfFile(pathStr.c_str());
  
  CCAssert(((CCString*)dict->objectForKey("version"))->intValue() == 1, "Unsupported version. Upgrade cocos2d version");
    
  std::string texturePathStr = relPathStr + ((CCString*)dict->objectForKey("textureFilename"))->getCString();
  CCString *textureFilename = CCString::create(texturePathStr);
  unsigned int width = ((CCString*)dict->objectForKey("itemWidth"))->intValue() / CC_CONTENT_SCALE_FACTOR();
  unsigned int height = ((CCString*)dict->objectForKey("itemHeight"))->intValue() / CC_CONTENT_SCALE_FACTOR();
  unsigned int startChar = ((CCString*)dict->objectForKey("firstChar"))->intValue();
  

  this->initWithString(theString, textureFilename->getCString(), width, height, startChar);
    
  return true;
}
Ejemplo n.º 8
0
void CCEGLView::setScissorInPoints(float x, float y, float w, float h) {
	//TODO
	if (bIsInit) {
		float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
		glScissor((GLint)(x * factor) + m_rcViewPort.origin.x,
				(GLint)(y * factor) + m_rcViewPort.origin.y,
				(GLint)(w * factor),
				(GLint)(h * factor));
	}
}
Ejemplo n.º 9
0
void CCCamera::setEyeXYZ(float fEyeX, float fEyeY, float fEyeZ)
{
	float scale = CC_CONTENT_SCALE_FACTOR();

	m_fEyeX = fEyeX * scale;
	m_fEyeY = fEyeY * scale;
	m_fEyeZ = fEyeZ * scale;

	m_bDirty = true;
}
Ejemplo n.º 10
0
void CCBlade::push(CCPoint v)
{
	if (isReset) 
	{
		return;
	}
    if (CC_CONTENT_SCALE_FACTOR() != 1.0f) {
        v = ccpMult(v, CC_CONTENT_SCALE_FACTOR());
    }

	#if USE_LAGRANGE

    if (path.size() == 0) 
	{
		path.insert(path.begin(),v);        
        return;
    }
    
    CCPoint first = path[0];
    if (ccpDistance(v, first) < DISTANCE_TO_INTERPOLATE) {
        path.insert(path.begin(),v);
        if (path.size() > pointLimit) {
            path.pop_back();
        }
    }else{
        int num = ccpDistance(v, first) / DISTANCE_TO_INTERPOLATE;
        CCPoint iv = ccpMult(ccpSub(v, first), (float)1./(num + 1));
		for (int i = 1; i <= num + 1; i++) {
            path.insert(path.begin(),ccpAdd(first, ccpMult(iv, i)));
		}
		while (path.size() > pointLimit) {
			path.pop_back();
		}
    }
#else // !USE_LAGRANGE
	path.push_front(v);
	if (path.size() > pointLimit) {
		path.pop_back();
	}
#endif // !USE_LAGRANGE
	this->populateVertices();
}
Ejemplo n.º 11
0
void CCGridBase::set2DProjection()
{
    CCDirector *director = CCDirector::sharedDirector();

    CCSize    size = director->getWinSizeInPixels();

    glViewport(0, 0, (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR()) );
    kmGLMatrixMode(KM_GL_PROJECTION);
    kmGLLoadIdentity();

    kmMat4 orthoMatrix;
    kmMat4OrthographicProjection(&orthoMatrix, 0, size.width * CC_CONTENT_SCALE_FACTOR(), 0, size.height * CC_CONTENT_SCALE_FACTOR(), -1, 1);
    kmGLMultMatrix( &orthoMatrix );

    kmGLMatrixMode(KM_GL_MODELVIEW);
    kmGLLoadIdentity();


    ccSetProjectionMatrixDirty();
}
Ejemplo n.º 12
0
void Label::updateBMFontScale()
{
    auto font = _fontAtlas->getFont();
    if (_currentLabelType == LabelType::BMFONT) {
        FontFNT *bmFont = (FontFNT*)font;
        float originalFontSize = bmFont->getOriginalFontSize();
        _bmfontScale = _bmFontSize * CC_CONTENT_SCALE_FACTOR() / originalFontSize;
    }else{
        _bmfontScale = 1.0f;
    }
}
Ejemplo n.º 13
0
bool CCLabelTTF::initWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize)
{
    CCAssert(label != NULL, "");
    if (CCSprite::init())
    {
        // shader program
        setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(SHADER_PROGRAM));

        m_tDimensions = CCSizeMake( dimensions.width * CC_CONTENT_SCALE_FACTOR(), dimensions.height * CC_CONTENT_SCALE_FACTOR() );
        m_eAlignment = alignment;

        CC_SAFE_DELETE(m_pFontName);
        m_pFontName = new std::string(fontName);

        m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR();
        this->setString(label);
        return true;
    }
    return false;
}
void CCEGLView::setViewPortInPoints(float x, float y, float w, float h)
{
    if (m_pEGL)
    {
        float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
        glViewport((GLint)(x * factor) + m_rcViewPort.X(),
            (GLint)(y * factor) + m_rcViewPort.Y(),
            (GLint)(w * factor),
            (GLint)(h * factor));
    }
}
Ejemplo n.º 15
0
/// override contentSize
void CCLayerColor::setContentSize(const CCSize& size)
{
	float scale = CC_CONTENT_SCALE_FACTOR();

	m_pSquareVertices[1].x = size.width * scale;
	m_pSquareVertices[2].y = size.height * scale;
	m_pSquareVertices[3].x = size.width * scale;
	m_pSquareVertices[3].y = size.height * scale;

	CCLayer::setContentSize(size);
}
Ejemplo n.º 16
0
void CCRenderTexture::end()
{
    glBindFramebuffer(GL_FRAMEBUFFER, m_nOldFBO);
    kmGLPopMatrix();

    CCDirector *director = CCDirector::sharedDirector();

    CCSize size = director->getWinSizeInPixels();

    // restore viewport
    glViewport(0, 0, GLsizei(size.width * CC_CONTENT_SCALE_FACTOR()), GLsizei(size.height * CC_CONTENT_SCALE_FACTOR()));

    // special viewport for 3d projection + retina display
    if ( director->getProjection() == kCCDirectorProjection3D && CC_CONTENT_SCALE_FACTOR() != 1 )
    {
        glViewport((GLsizei)(-size.width/2), (GLsizei)(-size.height/2), (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR()));
    }

    director->setProjection(director->getProjection());
}
Ejemplo n.º 17
0
bool LabelAtlas::initWithString(const std::string& theString, const std::string& fntFile)
{
    std::string pathStr = FileUtils::getInstance()->fullPathForFilename(fntFile);
    std::string relPathStr = pathStr.substr(0, pathStr.find_last_of("/"))+"/";
    
    ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(pathStr.c_str());

    CCASSERT(dict["version"].asInt() == 1, "Unsupported version. Upgrade cocos2d version");

    std::string textureFilename = relPathStr + dict["textureFilename"].asString();

    unsigned int width = dict["itemWidth"].asInt() / CC_CONTENT_SCALE_FACTOR();
    unsigned int height = dict["itemHeight"].asInt() / CC_CONTENT_SCALE_FACTOR();
    unsigned int startChar = dict["firstChar"].asInt();


    this->initWithString(theString, textureFilename.c_str(), width, height, startChar);

    return true;
}
Ejemplo n.º 18
0
void Label::enableShadow(const Color4B& shadowColor /* = Color4B::BLACK */,const Size &offset /* = Size(2 ,-2)*/, int blurRadius /* = 0 */)
{
    _shadowEnabled = true;
    _shadowDirty = true;

    auto contentScaleFactor = CC_CONTENT_SCALE_FACTOR();
    _shadowOffset.width = offset.width * contentScaleFactor;
    _shadowOffset.height = offset.height * contentScaleFactor;
    //TODO: support blur for shadow

    _shadowColor3B.r = shadowColor.r;
    _shadowColor3B.g = shadowColor.g;
    _shadowColor3B.b = shadowColor.b;
    _shadowOpacity = shadowColor.a;

    if (!_systemFontDirty && !_contentDirty && _textSprite)
    {
        auto fontDef = _getFontDefinition();
        if (_shadowNode)
        {
            if (shadowColor != _shadowColor4F)
            {
                _shadowNode->release();
                _shadowNode = nullptr;
                createShadowSpriteForSystemFont(fontDef);
            }
            else
            {
                _shadowNode->setPosition(_shadowOffset.width, _shadowOffset.height);
            }
        }
        else
        {
            createShadowSpriteForSystemFont(fontDef);
        }
    }

    _shadowColor4F.r = shadowColor.r / 255.0f;
    _shadowColor4F.g = shadowColor.g / 255.0f;
    _shadowColor4F.b = shadowColor.b / 255.0f;
    _shadowColor4F.a = shadowColor.a / 255.0f;

    if (_currentLabelType == LabelType::BMFONT || _currentLabelType == LabelType::CHARMAP)
    {
        if (_shadowEnabled)
        {
            setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
        } 
        else
        {
            setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP));
        }
    }
}
Ejemplo n.º 19
0
void CCEGLView::setScissorInPoints(float x, float y, float w, float h)
{
    if (m_pEGL)
    {
        float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
        glScissor((GLint)(x * factor) + m_rcViewPort.left,
            (GLint)(y * factor) + m_rcViewPort.top,
            (GLint)(w * factor),
            (GLint)(h * factor));
    }
}
Ejemplo n.º 20
0
EnergyContainer::EnergyContainer() :
_winSize(CCDirector::sharedDirector()->getWinSize()),
_manager(GameManager::sharedGameManager())
{
    _energyX = _winSize.width * 0.1f;
    _energyY = _winSize.height * 0.03f;
    
    
    glLineWidth(ENERGY_DRAW * CC_CONTENT_SCALE_FACTOR());
    
    
}
Ejemplo n.º 21
0
TimerSprite::TimerSprite(const float seconds) : seconds(seconds), secondsLeft(seconds), on(true), penalty(false)
{
    const float scale = CC_CONTENT_SCALE_FACTOR();
	const CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
    width = screenSize.width*3/5;

    const LineParams backgroundParams = {
        .start = vec2(-width/2*scale, 0),
        .end = vec2(width/2*scale, 0),
        .edgeCenterDistances = makeVector((float[]){scale, 3*scale + 1}),
        .edgeColors = makeVector((vec4[]){vec4(1,1,1,0), vec4(1,1,1,0.2f)})
    };
Ejemplo n.º 22
0
void CCEGLView::setViewPortInPoints(float x, float y, float w, float h) {
//	TODO
    CCLOG("%s(%d):%s called", __FILE__, __LINE__, __FUNCTION__);
//    if (bIsInit)
    {
		float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
        glViewport((GLint)(x * factor) + m_rcViewPort.origin.x,
                (GLint)(y * factor) + m_rcViewPort.origin.y,
				(GLint)(w * factor),
				(GLint)(h * factor));
	}
}
Ejemplo n.º 23
0
	bool CCLabelTTF::initWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize)
	{
		CCAssert(label != NULL, "");
		if (CCSprite::init())
		{
			m_tDimensions = CCSizeMake( dimensions.width * CC_CONTENT_SCALE_FACTOR(), dimensions.height * CC_CONTENT_SCALE_FACTOR() );
			m_eAlignment = alignment;

            if (m_pFontName)
            {
                delete m_pFontName;
                m_pFontName = NULL;
            }
            m_pFontName = new std::string(fontName);

			m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR();
			this->setString(label);
			return true;
		}
		return false;
	}
Ejemplo n.º 24
0
void LabelTTFLoader::onHandlePropTypePosition(cocos2d::Node * pNode,cocos2d:: Node * pParent, const char* pPropertyName, cocos2d::Point pPosition, CCBReader * ccbReader) {
    
    if(strcmp(pPropertyName, PROPERTY_SHADOWOFFSET) == 0) {
        auto contentScaleFactor = CC_CONTENT_SCALE_FACTOR();
        this->_shadowOffset = Size(pPosition.x / contentScaleFactor, pPosition.y / contentScaleFactor);
        
		((Label *)pNode)->enableShadow(this->_shadowColor, this->_shadowOffset, this->_shadowBlurRadius);
        
	} else {
        NodeLoader::onHandlePropTypePosition(pNode, pParent, pPropertyName, pPosition, ccbReader);
    }
}
Ejemplo n.º 25
0
void CCTransitionRadialCCW::onEnter()
{
	CCTransitionScene::onEnter();
	// create a transparent color layer
	// in which we are going to add our rendertextures
	CCSize size = CCDirector::sharedDirector()->getWinSize();

	// create the second render texture for outScene
	m_OutRT = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height);

	if (NULL == m_OutRT)
		return;
	
	m_OutRT->retain();

	m_OutRT->getSprite()->setAnchorPoint(ccp(0.5f,0.5f));
	m_OutRT->setPosition(ccp(size.width/2, size.height/2));
	m_OutRT->setAnchorPoint(ccp(0.5f,0.5f));

	//	We need the texture in RenderTexture.
	CCProgressTimer *outNode = CCProgressTimer::progressWithTexture(m_OutRT->getSprite()->getTexture());
	// but it's flipped upside down so we flip the sprite
	outNode->getSprite()->setFlipY(true);

	// fix content scale factor for radial texture
	CCRect rect = CCRectZero;
	rect.size = m_OutRT->getSprite()->getTexture()->getContentSize();
	outNode->getSprite()->setTextureRect(rect, false);
	float scale = 1.0f / CC_CONTENT_SCALE_FACTOR();
	rect.size.width *= scale;
	rect.size.height *= scale;
	outNode->setContentSize(rect.size);

	//	Return the radial type that we want to use
	outNode->setType(radialType());
	outNode->setPercentage(100.f);
	outNode->setPosition(ccp(size.width/2, size.height/2));
	outNode->setAnchorPoint(ccp(0.5f,0.5f));

	// create the blend action
	CCAction * layerAction = CCSequence::actions
	(
		CCProgressFromTo::actionWithDuration(m_fDuration, 100.0f, 0.0f),
		CCEventCall::actionWithTarget(NULL, createEventHandler(this, &CCTransitionScene::_finish)),
		NULL
	);
	// run the blend action
	outNode->runAction(layerAction);

	// add the layer (which contains our two rendertextures) to the scene
	this->addChild(outNode, 2, kSceneRadial);
}
Ejemplo n.º 26
0
	bool CCLabelTTF::initWithString(const char *label, const char *fontName, float fontSize)
	{
		assert(label != NULL);
		if (CCSprite::init())
		{
			m_tDimensions = CGSizeZero;
			m_sFontName = fontName;
			m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR();
			this->setString(label);
			return true;
		}
		return false;
	}
Ejemplo n.º 27
0
void CCNode::setContentSize(CCSize size)
{
	if( ! CCSize::CCSizeEqualToSize(size, m_tContentSize) ) 
	{
		m_tContentSize = size;

        if( CC_CONTENT_SCALE_FACTOR() == 1 )
        {
            m_tContentSizeInPixels = m_tContentSize;
        }
        else
        {
            m_tContentSizeInPixels = CCSizeMake( size.width * CC_CONTENT_SCALE_FACTOR(), size.height * CC_CONTENT_SCALE_FACTOR() );
        }

		m_tAnchorPointInPixels = ccp( m_tContentSizeInPixels.width * m_tAnchorPoint.x, m_tContentSizeInPixels.height * m_tAnchorPoint.y );
		m_bIsTransformDirty = m_bIsInverseDirty = true;
#ifdef CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
		m_bIsTransformGLDirty = true;
#endif
	}
}
Ejemplo n.º 28
0
void ccDrawLine(const CCPoint& origin, const CCPoint& destination)
{
	ccVertex2F vertices[2] = 
    {
        {origin.x * CC_CONTENT_SCALE_FACTOR(), origin.y * CC_CONTENT_SCALE_FACTOR()},
        {destination.x * CC_CONTENT_SCALE_FACTOR(), destination.y * CC_CONTENT_SCALE_FACTOR()},
    };
	
	// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
	// Needed states: GL_VERTEX_ARRAY, 
	// Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY	
	glDisable(GL_TEXTURE_2D);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);
	
	glVertexPointer(2, GL_FLOAT, 0, vertices);	
	glDrawArrays(GL_LINES, 0, 2);
	
	// restore default state
	glEnableClientState(GL_COLOR_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glEnable(GL_TEXTURE_2D);	
}
Ejemplo n.º 29
0
const std::string LHSettings::imagePath(const std::string& image){
        
    std::string computedFile = image;
    if(isIpad())
    {
       // CCLog("IS IPAD");
        
        if(device != 1 && device != 3)//if ipad only then we dont need to apply transformations
        {
            if(CC_CONTENT_SCALE_FACTOR() == 2)
            {
                //we have ipad retina
                size_t found;
                found=computedFile.find_last_of(".");
                
                #if COCOS2D_VERSION < 0x00020000
                computedFile.insert(found, hd2xSuffix);
                #endif
            }
            else {
                //we have normal ipad - lets use the HD image
                
                size_t found;
                found=computedFile.find_last_of(".");
                #if COCOS2D_VERSION < 0x00020000
                computedFile.insert(found, hdSuffix);
                #endif
            }
        }
        
#if COCOS2D_VERSION >= 0x00020100
        const char* fullpath = CCFileUtils::sharedFileUtils()->fullPathForFilename(computedFile.c_str()).c_str();        
#elif COCOS2D_VERSION >= 0x00020000
        const char* fullpath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(computedFile.c_str());
#else
        const char* fullpath = CCFileUtils::fullPathFromRelativePath(computedFile.c_str());
#endif
        
        std::ifstream infile;
        infile.open (fullpath);
        if(true == infile.is_open()){ //IF THIS FAILS IT MEANS WE HAVE NO -hd file
            infile.close();
            return std::string(fullpath);
        }
    }
    
//    CCLog("RETURNING %s", image.c_str());
    
    return image;
}
Ejemplo n.º 30
0
void CCProgressHUD::draw() {
    CCLayerColor::draw();
    
    // draw panel
    const CCSize& contentSize = getContentSize();
	CCPoint size = ccp(m_panelSize.width, m_panelSize.height);
	if(m_forceSquare) {
		size.x = size.y = MAX(size.x, size.y);
	}
    CCPoint origin = ccp(contentSize.width / 2 - size.x / 2,
                         contentSize.height / 2 - size.y / 2);
    CCPoint dest = ccpAdd(origin, size);
    ccDrawSolidRoundRect(origin, dest, 15 / CC_CONTENT_SCALE_FACTOR(), m_panelColor);
}