void GLWindow::setScaleFactor( float scaleFactor )
{
	mScaleFactor = scaleFactor;
	updateTextureCoords();
	updateGL();
	emit scaleFactorChange( scaleFactor );
}
Exemple #2
0
/**
 * Allocate the render data necessary to render this node.
 *
 * This method allocates the Triangles data used by the TrianglesCommand
 * in the rendering pipeline.
 */
void PolygonNode::generateRenderData() {
    clearRenderData();
    
    allocTriangles(_polygon);
    updateColor();
    updateTextureCoords();
}
Exemple #3
0
void wySpriteEx::updateTransform() {
    if(!m_useBatchNode) {
        LOGW("This func only applies to sprite using batchnode");
        return;
    }

    if(!m_texDirty && !m_colorDirty && !m_transformDirty) {
        return;
    }

    if(m_texDirty || m_transformDirty) {
        if(m_transformDirty) {
            wyAffineTransform t = getNodeToBatchNodeTransform();
            updateVertices(t);
        }

        if(m_texDirty)
            updateTextureCoords();

        m_batchNode->m_atlas->updateQuad(m_texCoords, m_vertices, m_atlasIndex);
    }

    if(m_colorDirty) {
        updateColor();
    }

    m_texDirty = m_colorDirty = m_transformDirty = false;
}
Exemple #4
0
    void Sprite::setTextureRect(const fzRect& rect, const fzSize& untrimmedSize, bool rotated)
    {    
        m_textureRect = rect;
        m_rectRotated = rotated;
        
        setContentSize(untrimmedSize);
        updateTextureCoords(rect);

        
        // Calculate final offset
        fzPoint relativeOffset(m_unflippedOffset);
        if( m_flipX )
            relativeOffset.x *= -1;
        
        if( m_flipY )
            relativeOffset.y *= -1;

        m_offset = relativeOffset + (m_contentSize - m_textureRect.size)/2;
        
        
        // Generate untransformed vertices
        fzPoint xy2 = m_offset + m_textureRect.size;        

        m_vertices[0] = m_offset;
        m_vertices[1] = fzVec2(xy2.x, m_offset.y);
        m_vertices[2] = fzVec2(m_offset.x, xy2.y);
        m_vertices[3] = xy2;

        makeDirty(kFZDirty_transform_absolute);
    }
void CC3DSprite::setTextureRect(const CCRect& rect, bool rotated)
{
	this->setContentSize(rect.size);

	//TextureCoords
	updateTextureCoords(rect, rotated);
	
	 m_bTransformDirty = m_bInverseDirty = true;
}
Exemple #6
0
    void Sprite::setTexture(Texture2D* texture)
    {
        FZ_ASSERT( m_mode == kFZSprite_SelfRendering, "Sprite mode is not kFZSprite_SelfRendering.");

        if(m_mode != kFZSprite_SelfRendering)
            return;
        
        FZRETAIN_TEMPLATE(texture, mode.A.p_texture);
        
        updateTextureCoords(m_textureRect);
    }
void GLWindow::resizeGL( int w, int h )
{
	glViewport( 0, 0, w, h );

	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
	glOrtho( 0, w, 0, h, 0.0, 16.0 );

	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();

	updateTextureCoords();
}
Exemple #8
0
 void Sprite::useBatchRender(SpriteBatch* batch)
 {
     FZ_ASSERT(batch != NULL, "Batch node cannot be NULL.");
     
     if(m_mode == kFZSprite_BatchRendering)
         return;
     
     if(m_mode == kFZSprite_SelfRendering)
         setTexture(NULL);
     
     makeDirty(kFZDirty_all);
     mode.B.p_currentQuad = NULL;
     mode.B.p_batchNode = batch;
     m_mode = kFZSprite_BatchRendering;
     updateTextureCoords(m_textureRect);
 }
Exemple #9
0
void CCSprite::setTextureRectInPixels(CGRect rect, bool rotated, CGSize size)
{
	m_obRectInPixels = rect;
	m_obRect = CC_RECT_PIXELS_TO_POINTS(rect);
	m_bRectRotated = rotated;

	setContentSizeInPixels(size);
	updateTextureCoords(m_obRectInPixels);

	CGPoint relativeOffsetInPixels = m_obUnflippedOffsetPositionFromCenter;

	// issue #732
	if (m_bFlipX)
	{
		relativeOffsetInPixels.x = -relativeOffsetInPixels.x;
	}
	if (m_bFlipY)
	{
		relativeOffsetInPixels.y = -relativeOffsetInPixels.y;
	}

	m_obOffsetPositionInPixels.x = relativeOffsetInPixels.x + (m_tContentSizeInPixels.width - m_obRectInPixels.size.width) / 2;
	m_obOffsetPositionInPixels.y = relativeOffsetInPixels.y + (m_tContentSizeInPixels.height - m_obRectInPixels.size.height) / 2;

	// rendering using SpriteSheet
	if (m_bUsesBatchNode)
	{
		// update dirty_, don't update recursiveDirty_
		m_bDirty = true;
	}
	else
	{
		// self rendering
		
		// Atlas: Vertex
		float x1 = 0 + m_obOffsetPositionInPixels.x;
		float y1 = 0 + m_obOffsetPositionInPixels.y;
		float x2 = x1 + m_obRectInPixels.size.width;
		float y2 = y1 + m_obRectInPixels.size.height;

		// Don't update Z.
		m_sQuad.bl.vertices = vertex3(x1, y1, 0);
		m_sQuad.br.vertices = vertex3(x2, y1, 0);
		m_sQuad.tl.vertices = vertex3(x1, y2, 0);
		m_sQuad.tr.vertices = vertex3(x2, y2, 0);
	}
}
void GLWindow::showImage( TexInfo texInfo )
{
	if( texInfo.handle == 0 )
		return;
	
	mCurrentTexture = texInfo;
	mTextureValid = true;

	// Make it the current texture
	glEnable( mTextureMode );
	glBindTexture(mTextureMode, texInfo.handle);

#ifdef COMPILE_CG
	// Set the texture to be used by the shader program
	if( mUseCG )
		cgGLSetTextureParameter(cgImageParam, texInfo.handle);
#endif

	updateTextureCoords();
	updateGL();
}
void GLWindow::setScaleMode( int scaleMode )
{
	mScaleMode = scaleMode;
	updateTextureCoords();
	updateGL();
}