Second blit fails after first blit succeeds

Hi all,

I’m wondering if someone might be able to help me with a problem with

I have a menu system which contains a std::map of options. Each option blits
itself onto the buffer via an iterator over the map:

bool MS_Menu::DrawMenu(SDL_Surface * dest, int x, int y)
// Paint the background… Cut out as not relevant…

// Now paint options over the top!
MS_MenuButtonMap::iterator iter;
for(iter = _option.begin() ; iter != _option.end() ; ++iter) {
	MS_MenuButton* opt = ((*iter).second);
	if(opt->DrawOption(dest) == false) {
		return false;

return true;


My problem is that I have one menu, a submenu that pops up off the main menu,
that blits the first of two options fine, but the second fails, with
SDL_BlitSurface returning -1. Here’s MS_MenuButton’s DrawOption:

inline bool MS_MenuButton::DrawOption(SDL_Surface * blitdest)
int n = SDL_BlitSurface(_images, &_myrect, blitdest, &_wndrect);
if(n != 0) {
return false;
return true;

_images, _myrect and _wndrect are members of MS_MenuButton, and are pre-loaded.
In the case of the option that fails to draw, I’ve checked its contents (which
are OK), and I’ve checked the surface, which again seems to be OK. It is, after
all, pretty much exactly the same surface passed to both, except the contents of
the first are blitted onto it.

The main menu uses the same code (but different images) and works correctly. Is
there something I might be inadvertently doing to the surface to make it fail?
SDL_BlitSurface is definitely working for the first option, since it’s
DrawOption wrapper is returning true…

BTW, the two blits occur onto two different points on the screen, and they are
both fully within the screen bounds.


Sorry, should have mentioned I’m using VC6 on WinXP and SDL development version
from about 3 weeks ago (not sure what actual version, sorry, other than