Example #1
0
void CCTextureManager::invalidateAllTextureHandles()
{
    currentGLTexture = NULL;
    totalTexturesLoaded = 0;
    totalUsedTextureSpace = 0;

    for( int i=0; i<textureHandles.length; ++i )
    {
        CCTextureHandle *handle = textureHandles.list[i];
        if( handle->texture != NULL )
        {
            totalUsedTextureSpace -= handle->texture->getBytes();
            delete handle->texture;
            handle->texture = NULL;
        }
    }

    // Load in a 1x1 white texture to use for untextured draws
    assignTextureIndex( "transparent.png", Resource_Packaged, false, true, true );
    assignTextureIndex( "white.png", Resource_Packaged, false, true, true );

    setTextureIndex( 0 );

    CCSetTexCoords( NULL );
	CCDefaultTexCoords();
}
CCTextureManager::CCTextureManager()
{
	currentGLTexture = 0;
    totalTexturesLoaded = 0;
    totalUsedTextureSpace = 0;
    totalTexturesLoadedThisFrame = 0;
	
	CCDefaultTexCoords();
}
Example #3
0
CCTextureManager::CCTextureManager()
{
	currentGLTexture = NULL;
    totalTexturesLoaded = 0;
    totalUsedTextureSpace = 0;
    textureSprites = new CCTextureSprites();

	CCDefaultTexCoords();
}
Example #4
0
CCTextureManager::CCTextureManager()
{
	currentTextureHandle = 0;
    totalTexturesLoaded = 0;
    totalTextureSpace = 0;
    totalTexturesLoadedThisFrame = 0;
    textureSprites = new CCTextureSprites();
	
	CCDefaultTexCoords();
}
Example #5
0
void CCTextureManager::invalidateAllTextureHandles()
{
    for( int i=0; i<textureHandles.length; ++i )
    {
        CCTextureHandle *handle = textureHandles.list[i];
        if( handle->texture != NULL )
        {
            totalUsedTextureSpace -= handle->texture->getBytes();
            delete handle->texture;
            handle->texture = NULL;
        }
    }

    setTextureIndex( 0 );

    CCSetTexCoords( NULL );
	CCDefaultTexCoords();
}
void CCPrimitiveSquare::renderVertices(const bool textured)
{	
#if defined PROFILEON
    CCProfiler profile( "CCPrimitiveSquare::renderVertices()" );
#endif

	if( customUVs != NULL )
	{
		CCSetTexCoords( customUVs->uvs );
	}
	else
	{
		CCDefaultTexCoords();
	}
	
    CCSetViewMatrix();
    GLVertexPointer( 3, GL_FLOAT, 0, vertices );
    glDrawArrays( GL_TRIANGLE_STRIP, 0, 4 );
}
Example #7
0
void CCModelBase::render(const bool alpha)
{
#if defined PROFILEON
    CCProfiler profile( "CCModelBase::render()" );
#endif

    if( shouldRender )
    {
        GLPushMatrix();
        {
            refreshModelMatrix();
            GLMultMatrixf( modelMatrix );
            
            gEngine->renderer->setShader( shader );

            if( colourOutline != NULL )
            {
#if defined PROFILEON
            	CCProfiler profile( "CCModelBase::render()::colourOutline" );
#endif
                CCSetColour( *colourOutline );
                if( alpha == false && ( CCGetColour().alpha > 0.0f ) )
                {
                    GLEnableBlend();
                }

                CCDefaultTexCoords();
                gEngine->textureManager->setTextureIndex( 0 );
                for( int i=0; i<primitives.length; ++i )
                {
                    primitives.list[i]->renderOutline();
                }

                if( alpha == false && ( CCGetColour().alpha > 0.0f ) )
                {
                    GLDisableBlend();
                }
            }

            if( colour != NULL )
            {
                CCSetColour( *colour );
            }

            if( alpha == false || colour == NULL || ( colour != NULL && colour->alpha > 0.0f ) )
            {
                for( int i=0; i<primitives.length; ++i )
                {
                    CCPrimitiveBase *primitive = primitives.list[i];
                    primitive->render();
                }
            }

            for( int i=0; i<models.length; ++i )
            {
                CCModelBase *model = models.list[i];
                model->render( alpha );
                if( colour != NULL )
                {
                    CCSetColour( *colour );
                }
            }
        }
        GLPopMatrix();
    }
}
Example #8
0
const bool CCWidgetBase::render(const bool foreground)
{	
	if( inView && enabled && foreground == renderForeground )
	{
		if( colour == NULL )
		{
            static CCColour colour( 1.0f, 1.0f, 1.0f, 0.75f );
			CCSetColour( colour );
		}
		else
		{
			CCSetColour( *colour );
		}
		
		if( renderButton )
		{
            if( textureIndex != 0 )
			{
				gEngine->textureManager->setTextureIndex( textureIndex );
				
				if( customUVs != NULL )
				{
					CCSetTexCoords( customUVs->uvs );
				}
				else
				{
					CCDefaultTexCoords();
				}
			}
			else
			{
				gEngine->textureManager->setTextureIndex( 0 );
			}
			
			CCRenderRectanglePoint( position, size.width, -size.height );
			
			if( renderOutline )
			{
				if( colour == NULL )
				{
                    static CCColour colour( 0.5f, 0.5f, 0.5f, 0.75f );
					CCSetColour( colour );
				}
				else
				{
                    CCColour colourObject( colour->red * 0.5f, colour->green * 0.5f, colour->blue * 0.5f, colour->alpha );
					CCSetColour( colourObject );
				}
				CCRenderRectanglePoint( position, size.width, -size.height, true );
			}
			
			if( distortEffect )
			{
                static CCColour colour( 1.0f, 1.0f, 1.0f, 0.5f );
				CCSetColour( colour );
				CCRenderRectanglePoint( position, size.width + distortTarget.x, size.height + distortTarget.y );
			}
		}
		
		return true;
	}
	
	return false;
}