Multiple Surfaces blitting problem, SurfaceLocked?


I’m working on a framework for a gamingplatform…
Now, ofcourse I have run into som trouble.

I want to have one SDL_Surface that’s the screen, and then have other
"modules" have their own SDL_Surfaces that works like the screen for them.
All those Surfaces are then checked and drawn to the “main” SDL_Surface.
Now, I have the following class:

struct sSurface
SDL_Surface* m_pkSurface;

//Display Settings
int iAlpha;
int iXPos;
int iYPos;
int iWidth;
int iHeight;
bool m_bVisible;

class SurfaceManager
static SurfaceManager* ms_pkInstance;

map m_kSurfaces;
SDL_Surface* m_pkScreen;

Options kOptions;

SDL_Surface* GetSurface (string kSurfaceName);
bool AddSurface (string kKey, SDL_Surface* kSurface);
bool AddSurface(string kKey, int iWidth = 0, int iHeight = 0, int
iColorDepth = 0);
void SetActiveSurface(string kKey);
void InitSDL();

void Render( float iFrameTime );

SurfaceManager* GetInstance() { return ms_pkInstance; }


Now, when I try to blit to the virtual-screen surface SDL tells me it’s
locked. And it doesn’t help to call SDL_UnlockSurface on it either.

My whole point for having this thing with virtual screens is to make it
possible for others that make modules for our platform to choose their own
resolution etc. and remember the old settings and, if dessired, draw the
other screens in the background… Alpha blended…

I use the simple SDL example blitroutine as of now and call it like this:

display_bmp(“JeepBdy2.bmp”, SM.GetSurface(“Screen1”) );

Doesn’t work… However… If I choose SM.m_pkScreen (the screen Surface)
it works fine…

My draw function, as of now, is very simple (I ran into this problem at
the very start):

void SurfaceManager::Render( float fFrameTime )
map::iterator kIterator;

for( kIterator = m_kSurfaces.begin(); kIterator != m_kSurfaces.end();
++kIterator )
if( (*kIterator).second.m_bVisible )
SDL_BlitSurface( (*kIterator).second.m_pkSurface, NULL, m_pkScreen, NULL);

SDL_Flip( m_pkScreen );


Might be pretty much to grasp… I’m new here so have patience :wink:

Well, any thoughts would be appriciated…

Best Regards
Daniel Liljeberg----------------------------------------------------------------------

Help STOP SPAM with the new MSN 8 and get 2 months FREE*

If you want answers better turn HTML mailing of when mailing to ML’s.