• Advertisement
Sign in to follow this  

Coulor key setting in ()

This topic is 4838 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

my debugger keeps pointing me back to this function void TempRectBlit(SDL_Surface* src,SDL_Surface* dst,SDL_Rect Parent_Rect) { SDL_Rect TempRect = Parent_Rect; SDL_SetColorKey(src, SDL_SRCCOLORKEY, SDL_MapRGB(src->format, 0, 0,0)); SDL_BlitSurface(src,NULL,dst,&TempRect); }; and im wondering if its okay to set a color key within a function thanks [grin] C++ Dev-Cpp API:SDL

Share this post


Link to post
Share on other sites
Advertisement
yes, but since it is a one-time operation, don't do it in your rendering/blitting function.

Share this post


Link to post
Share on other sites
yes but what if the image is constantly being re-asigned and its former state is being push into a vector?? complicated i know

thanks for the reply [smile]

Share this post


Link to post
Share on other sites
You could overload it and have something like this:


void TempRectBlit(SDL_Surface* src,SDL_Surface* dst,SDL_Rect Parent_Rect)
{
SDL_Rect TempRect = Parent_Rect;
SDL_BlitSurface(src,NULL,dst,&TempRect);
};

void TempRectBlit(SDL_Surface* src,SDL_Surface* dst,SDL_Rect Parent_Rect, int transR, int transG, int transB)
{
SDL_Rect TempRect = Parent_Rect;
SDL_SetColorKey(src, SDL_SRCCOLORKEY, SDL_MapRGB(src->format, transR, transG, transB));
SDL_BlitSurface(src,NULL,dst,&TempRect);
}

void TempRectBlit(SDL_Surface* src,SDL_Surface* dst,SDL_Rect Parent_Rect, bool BlackTrans)
{
SDL_Rect TempRect = Parent_Rect;
SDL_SetColorKey(src, SDL_SRCCOLORKEY, SDL_MapRGB(src->format, 0, 0, 0));
SDL_BlitSurface(src,NULL,dst,&TempRect);
}



I haven't tried compiling it so be warned.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement