Exemplo n.º 1
0
bool CCGridBase::initWithSize(const CCSize& gridSize, CCTexture2D *pTexture, bool bFlipped)
{
    bool bRet = true;

    m_bActive = false;
    m_nReuseGrid = 0;
    m_sGridSize = gridSize;

    m_pTexture = pTexture;
    CC_SAFE_RETAIN(m_pTexture);
    m_bIsTextureFlipped = bFlipped;

    CCSize texSize = m_pTexture->getContentSize();
    m_obStep.x = texSize.width / m_sGridSize.width;
    m_obStep.y = texSize.height / m_sGridSize.height;

    m_pGrabber = new CCGrabber();
    if (m_pGrabber)
    {
        m_pGrabber->grab(m_pTexture);
    }
    else
    {
        bRet = false;
    }
    
    m_pShaderProgram = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTexture);
    calculateVertexPoints();

    return bRet;
}
	bool CCGridBase::initWithSize(ccGridSize gridSize, CCTexture2D *pTexture, bool bFlipped)
	{
		bool bRet = true;

		m_bActive = false;
		m_nReuseGrid = 0;
		m_sGridSize = gridSize;

		m_pTexture = pTexture;
		CC_SAFE_RETAIN(m_pTexture);
		m_bIsTextureFlipped = bFlipped;

		CCSize texSize = m_pTexture->getContentSizeInPixels();
		m_obStep.x = texSize.width / m_sGridSize.x;
		m_obStep.y = texSize.height / m_sGridSize.y;

		m_pGrabber = new CCGrabber();
		if (m_pGrabber)
		{
			m_pGrabber->grab(m_pTexture);
		}
		else
		{
            bRet = false;
		}
		

		calculateVertexPoints();

		return bRet;
	}
Exemplo n.º 3
0
bool GridBase::initWithSize(const Size& gridSize, Texture2D *texture, bool bFlipped)
{
    bool bRet = true;

    _active = false;
    _reuseGrid = 0;
    _gridSize = gridSize;

    _texture = texture;
    CC_SAFE_RETAIN(_texture);
    _isTextureFlipped = bFlipped;

    Size texSize = _texture->getContentSize();
    _step.x = texSize.width / _gridSize.width;
    _step.y = texSize.height / _gridSize.height;

    _grabber = new Grabber();
    if (_grabber)
    {
        _grabber->grab(_texture);
    }
    else
    {
        bRet = false;
    }
    
    _shaderProgram = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE);
    calculateVertexPoints();

    return bRet;
}
Exemplo n.º 4
0
bool GridBase::initWithSize(const Size& gridSize, Texture2D *texture, bool bFlipped)
{
    bool bRet = true;

    m_bActive = false;
    m_nReuseGrid = 0;
    m_tGridSize = gridSize;

    m_pTexture = texture;
    CC_SAFE_RETAIN(m_pTexture);
    m_bIsTextureFlipped = bFlipped;

    Size texSize = m_pTexture->getContentSize();
    m_tStep.x = texSize.width / m_tGridSize.width;
    m_tStep.y = texSize.height / m_tGridSize.height;

    m_pGrabber = new Grabber();
    if (m_pGrabber)
    {
        m_pGrabber->grab(m_pTexture);
    }
    else
    {
        bRet = false;
    }
    
    m_pShaderProgram = ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE);
    calculateVertexPoints();

    return bRet;
}
Exemplo n.º 5
0
void GridBase::setTextureFlipped(bool flipped)
{
    if (_isTextureFlipped != flipped)
    {
        _isTextureFlipped = flipped;
        calculateVertexPoints();
    }
}
Exemplo n.º 6
0
void CCGridBase::setTextureFlipped(bool bFlipped)
{
    if (m_bIsTextureFlipped != bFlipped)
    {
        m_bIsTextureFlipped = bFlipped;
        calculateVertexPoints();
    }
}
Exemplo n.º 7
0
bool GridBase::initWithSize(const Size& gridSize, Texture2D *texture, bool flipped, const Rect& rect)
{
    bool ret = true;
    
    _active = false;
    _reuseGrid = 0;
    _gridSize = gridSize;
    
    _texture = texture;
    CC_SAFE_RETAIN(_texture);
    _isTextureFlipped = flipped;
    
    if (rect.equals(Rect::ZERO)) {
        auto size = _texture->getContentSize();
        _gridRect.setRect(0, 0, size.width, size.height);
    }
    else{
        _gridRect = rect;
    }
    _step.x = _gridRect.size.width/_gridSize.width;
    _step.y = _gridRect.size.height/_gridSize.height;
    
    _grabber = new (std::nothrow) Grabber();
    if (_grabber)
    {
        _grabber->grab(_texture);
    }
    else
    {
        ret = false;
    }
    
    _shaderProgram = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE);
    calculateVertexPoints();
    
    return ret;
}
Exemplo n.º 8
0
wyGrid3D::wyGrid3D(float w, float h, int c, int r) : wyBaseGrid(w, h, c, r) {
	calculateVertexPoints();
}