Original Post
I've tried setting up a color key, but it doesn't seem to work. I'm not using sprites of any kind, just drawing rectangles to a surface. Here's what I have so far:
Set-up code
The constructor for the Screen object initializes the SDL_Surface pointer, and attempts to make transparency work, logging any errors in the process.
Drawing code:
It gets the SDL_Surface from the Screen object, then creates a rectangle to draw, and draws it (logging an error if things don't work).
Any ideas?
Thanks/
Set-up code
Screen::Screen(unsigned int _width, unsigned int _height) : width(_width), height(_height), bgColor(0, 0, 0){ // "screen" is of type SDL_Surface* screen = SDL_SetVideoMode(width, height, 0, SDL_ANYFORMAT | SDL_SWSURFACE); if(screen == NULL) logger.Fatal(boost::format("Error creating screen: %1%") % SDL_GetError()); if(SDL_SetColorKey(screen, SDL_SRCCOLORKEY, transparent.GetRGBMap(screen)) != 0) logger.Fatal("Error setting color key");}The constructor for the Screen object initializes the SDL_Surface pointer, and attempts to make transparency work, logging any errors in the process.
Drawing code:
void WorldObject::Draw(Screen& target) const{ SDL_Surface* surface = target.GetSurface(); SDL_Rect rect; rect.w = bounds.max.x - bounds.min.x; rect.h = bounds.max.y - bounds.min.y; rect.x = bounds.min.x; rect.y = bounds.min.y; if(SDL_FillRect(surface, ▭, color.GetRGBMap(surface)) != 0) { string error = "Error drawing to screen: "; error += SDL_GetError(); logger.Fatal(error.c_str()); }}It gets the SDL_Surface from the Screen object, then creates a rectangle to draw, and draws it (logging an error if things don't work).
Any ideas?
Thanks/