I'm wondering if anyone can help me. I'm learning c++ and SDL by writing a game (currently for the Pandora, but I'll port it to the pyra (probably a simple recompile) when I get one) and I cant get SDL_SetColorKey to work :/
The texture loading code is taken almost asis from lazyfoo's page, and looks like this:
	
	
	
		
and the render code:
	
	
	
		
I'm not quite sure why it isnt working :/ but i'm still getting the cyan background displayed :/
Any advice?
thanks in advance
				
			The texture loading code is taken almost asis from lazyfoo's page, and looks like this:
		Code:
	
	bool LTexture::loadFromFile( std::string path )
{
    //Get rid of preexisting texture
    free();
    //The final texture
    SDL_Texture* newTexture = NULL;
    //Load image at specified path
    SDL_Surface* loadedSurface = SDL_LoadBMP( path.c_str() );
    if( loadedSurface == NULL )
    {
        printf( "Unable to load image %s! SDL_image Error: %s\n", path.c_str(), SDL_GetError() );
    }
    else
    {
        //SDL_Surface loaded2 = SDL_DisplayFormatAlpha(loadedSurface);
        //Color key image
        SDL_SetColorKey( loadedSurface, SDL_TRUE, SDL_MapRGB( loadedSurface->format, 0, 255, 255 ) );
        //Create texture from surface pixels
        newTexture = SDL_CreateTextureFromSurface( gRenderer, loadedSurface );
        if( newTexture == NULL )
        {
            printf( "Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError() );
        }
        else
        {
            //Get image dimensions
            mWidth = loadedSurface->w;
            mHeight = loadedSurface->h;
        }
        //Get rid of old loaded surface
        SDL_FreeSurface( loadedSurface );
    }
    //Return success
    mTexture = newTexture;
    return mTexture != NULL;
}and the render code:
		Code:
	
	void LTexture::render( int x, int y, SDL_Rect* clip )
{
    //Set rendering space and render to screen
    SDL_Rect renderQuad = { x, y, mWidth, mHeight };
    //Set clip rendering dimensions
    if( clip != NULL )
    {
        renderQuad.w = clip->w;
        renderQuad.h = clip->h;
    }
    //Render to screen
    SDL_RenderCopy( gRenderer, mTexture, clip, &renderQuad );
}I'm not quite sure why it isnt working :/ but i'm still getting the cyan background displayed :/
Any advice?
thanks in advance
 
	
 
 
		 
 
		 
 
		 
 
		 
 
		