Coulor key setting in ()

Started by
2 comments, last by Rob Loach 19 years, 5 months ago
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
____________________________"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
Advertisement
yes, but since it is a one-time operation, don't do it in your rendering/blitting function.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
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]
____________________________"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
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.
Rob Loach [Website] [Projects] [Contact]

This topic is closed to new replies.

Advertisement